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

QSqlQuery using SQLite can't use bind values when using PRAGMA

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Invalid
    • Affects Version/s: 5.12.5
    • Fix Version/s: None
    • Component/s: SQL Support
    • Labels:
      None
    • Platform/s:
      Linux/X11

      Description

      When setting the application_id header field of an SQLite database using "PRAGMA application_id", one can't use bind values.

      Executing a query via a literal request works as expected. if you do

          QSqlQuery query(m_db);
          query.exec(QStringLiteral("PRAGMA application_id = 123"));

      the header field is set, one can query it via "PRAGMA application_id" and e. g. file shows it on the console.

      When I try to use a bind value like so:

          constexpr int APPLICATION_ID = 123;
          QSqlQuery query(m_db);
          query.prepare(QStringLiteral("PRAGMA application_id = ?"));
          query.bindValue(0, APPLICATION_ID);
          query.exec();

      the query fails with query.lastError() showing an empty databaseText and driverText set to "Parameter count mismatch".

        Attachments

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

          Activity

            People

            Assignee:
            mabrand Mark Brand
            Reporter:
            l3u Tobias Leupold
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes