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

QSqlQuery constructor unusable with QPSQL driver

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.11.1
    • SQL Support
    • None
    • Linux 4.18.0 x86_64, debian testing
      Qt 5.11.1
      Postgre C client 10.5 (libpq5)
      Postgre server 10.5
    • Linux/Wayland, Linux/X11

    Description

      Issue

      Whenever one uses the QSqlQuery constructor that takes a string:

      QSqlQuery query("SELECT * FROM table");
      if (!query.exec())
        qDebug() << query.lastError().text();
      

       

      the execution through the QPSQL driver fails with:

      ERROR: syntax error at end of input
      LINE 1: EXECUTE
      ^
      (42601) QPSQL: Unable to create query
      

       

      Workarounds

      Preparing the query manually and then executing:

      QSqlQuery query;
      if (!query.prepare("SELECT * FROM table"))
        qDebug() << query.lastError().text();
      if (!query.exec())
         qDebug() << query.lastError().text();

       

      or executing the query directly:

      if (!query.exec("SELECT * FROM table"))
        qDebug() << query.lastError().text();

       

      work without issue.

      Attachments

        Issue Links

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

          Activity

            People

              chehrlic Christian Ehrlicher
              kshegunov Konstantin Shegunov
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes