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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.12.5
    • SQL Support
    • None
    • 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

            mabrand Mark Brand
            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