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

Incorrect example code for documentation for QSqlResult class

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.12.0 Beta 1
    • 5.11.1
    • SQL Support
    • None
    • All
    • 5f9a0d64b324abb8bf9baffabd7accb61a83a7e7 (qt/qtbase/5.12)

    Description

      There is following invalid example code in following page:

      http://doc.qt.io/qt-5/qsqlresult.html

      QSqlQuery query = ...
      QVariant v = query.result()->handle();
      if (v.isValid() && qstrcmp(v.typeName(), "sqlite3_stmt*")) {
          // v.data() returns a pointer to the handle
          sqlite3_stmt *handle = *static_cast<sqlite3_stmt **>(v.data());
          if (handle != 0) { // check that it is not NULL
              ...
          }
      }
      

      it should be something like this:

      QSqlQuery query = ...
      QVariant v = query.result()->handle();
      if (v.isValid() && (v.typeName() == QString("sqlite3_stmt*"))) {
          // v.data() returns a pointer to the handle
          sqlite3_stmt *handle = *static_cast<sqlite3_stmt **>(v.data());
          if (handle != 0) { // check that it is not NULL
              ...
          }
      }
      

      Attachments

        For Gerrit Dashboard: QTBUG-70598
        # Subject Branch Project Status CR V

        Activity

          People

            chehrlic Christian Ehrlicher
            josip.sumecki Josip Šumečki
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes