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

QODBC: QSqlQuery::isNull returns false for SELECT NULL

    XMLWordPrintable

Details

    • All
    • 44ac742f73 (qt/qtbase/dev) 44ac742f73 (qt/tqtc-qtbase/dev) d01500c7f3 (qt/tqtc-qtbase/6.2) 7d452d17a4 (qt/qtbase/6.4) 7d452d17a4 (qt/tqtc-qtbase/6.4)

    Description

      #include <QtSql/QSqlDatabase>
      #include <QtSql/QSqlQuery>
      #include <QtCore/QVariant>
      #include <QtCore/QDebug>
      
      int main() {
          auto db = QSqlDatabase::addDatabase("QODBC");
          for (auto cs : { "Driver={PostgreSQL Unicode};          ;Server=127.0.0.1;   ;Database=POLL_TEST",
                           "Driver={ODBC Driver 18 for SQL Server};Server=192.168.1.249;Database=POLL_TEST;TrustServerCertificate=YES" }) {
              db.setDatabaseName(cs);
              if (!db.open("PSO_login", "123")) continue;
              QSqlQuery qry("SELECT NULL, 1234", db);
              if (!qry.next()) continue;
              auto v0 = qry.value(0), v1 = qry.value(1); //doc says "call isNull after data access"
              if(v0.toInt() == 0 && v1.toInt() == 1234)
                  qInfo() << QString(cs).split(';').first() << ((qry.isNull(0) && !qry.isNull(1)) ? ": PASSED" : ": FAILED");
          }
      }
      

      Expected behavior (Qt 5):

      07:24:58: Starting ...-Desktop_Qt_5_15_2_GCC_64bit-Debug/sql_null... 
      "Driver={PostgreSQL Unicode}" : PASSED 
      "Driver={ODBC Driver 18 for SQL Server}" : PASSED
      

      Qt 6 unexpected behavior:

      07:25:17: Starting ...Desktop_Qt_6_4_0_GCC_64bit-Debug/sql_null...
      "Driver={PostgreSQL Unicode}" : FAILED
      "Driver={ODBC Driver 18 for SQL Server}" : PASSED
      

      Attachments

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

        Activity

          People

            chehrlic Christian Ehrlicher
            youry_pershin Ur Pe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes