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

QSqlQuery constructor unusable with QPSQL driver

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: P2: Important 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

      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.

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes