Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlDatabase::tables(QSql::Tables) includes sqlite_sequence
Forum Updated to NodeBB v4.3 + New Features

QSqlDatabase::tables(QSql::Tables) includes sqlite_sequence

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Al__
    wrote on 28 Dec 2012, 12:18 last edited by
    #1

    Hi
    A call to QSqlDatabase::tables(QSql::Tables) returns in addition to the user tables also sqlite_sequence. This table is used by sqlite3 to manage autoincrement values. Thus, sqlite_sequence is in my opinion an internal table and should be returned only by a call QSqlDatabase::tables(QSql::SystemTables) and not by QSqlDatabase::tables(QSql::Tables).
    Do I miss something or is this a bug?
    Best
    Al_

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on 31 Dec 2012, 08:46 last edited by
      #2

      SQLite itself does not treat it as a system table, and so does Qt. Only sqlite_master is considered beeing a system table.

      I, however, admit that the line for sqlite_sequence is quite blurry, but the choice for SQLite consistency sounds reasonable. Maybe the documentation should be updated to reflect this situation.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Al__
        wrote on 31 Dec 2012, 10:26 last edited by
        #3

        Thanks for your reply, Lukas. Why do you conclude that sqlite_master is the only system table? The commandline tool sqlite3 (as tested on linux) offers a command .tables . This command does not return sqlite_sequence nor, of course, sqlite_master (but sqlite_sequence exists in the test database, as confirmed by "select * from sqlite_sequence;"). Thus, this tool, to my knowledge from the authors of the database specs, considers sqlite_sequence a system table.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on 31 Dec 2012, 11:38 last edited by
          #4

          In SQLite there are just two tables, sqlite_master and sqlite_temp_master, which are not of type table (<code>SELECT name FROM sqlite_master WHERE type = 'table'</code>).

          The decision was made to interpret <code>QSql::Tables - All the tables visible to the user</code> in a way that it lists all of the database objects of type table, because these are the tables visible and modifiable by the user - and I find this decision reasonable (but not necessarily correct).

          But as said, the line is quite blurry. It is absolutely valid to be of the opinion that those tables should not be included in <code>QSql::Tables</code>, but rather in <code>QSql::SystemTables</code>.

          Feel free to file a "bug report":https://bugreports.qt-project.org/. "Patches":https://codereview.qt-project.org/ are welcome as well.

          Until then just mask out <code>sqlite_</code> database objects as the <code>.tables</code> command does (<code>... AND name NOT LIKE 'sqlite_%'</code> resp. <code>tables().filter(QRegularEpression("^(?!sqlite_).+"))</code>).

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Al__
            wrote on 31 Dec 2012, 12:46 last edited by
            #5

            You convinced me that this is a peculiarity (bug?) of sqlite, not of Qt. I filed a bug-report suggesting a hint in the Qt documentation. See https://bugreports.qt-project.org/browse/QTBUG-28887

            1 Reply Last reply
            0

            1/5

            28 Dec 2012, 12:18

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved