Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-120382

QSqlTableModel does not include GENERATED columns in SQLite

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.10, 6.2, 6.5, 6.6
    • sqlite
    • None
    • All

    Description

      When using QSqlTableModel (or QSqlRelationalTableModel) with a table in SQLite that contains GENERATED columns, those columns will not appear in the result set.

      My best guess is, that PRAGMA table_info is used internally to get the columns of the table, and that function will not show GENERATED columns. If PRAGMA table_xinfo was used instead, the GENERATED columns would be visible.

      Edit:

      QSQLiteDriverPrivate::getTableInfo in src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp uses

      query.exec("PRAGMA "_L1 + schema + "table_info ("_L1 + table + u')');

      table_xinfo should be used there in my opinion.

      There is one thing to keep in mind: the GENERATED columns should not be included in INSERT or UPDATE statements.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            andysh Andy Shaw
            rgrellmann Robert Grellmann
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes