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

QSqlField::isAutoValue return always false when using ODBC driver

    XMLWordPrintable

Details

    • da72e5538ebcc7e6008d0c4b3538d2a994f02a7e (qtbase/dev, 27.10.2014, 5.5)

    Description

      Documentation of QSqlField::isAutoValue says "Returns true if the value is auto-generated by the database, for example auto-increment primary key values."
      But when ODBC driver is used return value is always false. Seems that qsql_odbc.cpp implementation is missing the auto-increment part.

      Patch proposal attached but it doesn't work in every cases.
      The reason: The SQLColAttribute() function returns descriptor information for a column in a result_set.
      There is no way (or a least, I did not find any way) to get column information without doing a SELECT.

      A note should be added to the documentation of QSqlField::isAutoValue() stating that for the QODBC driver, this value is only set in QSqlRecord objects resulting of a SELECT:

      Note: When using the ODBC driver, due to limitations in ODBC, the autoValue() field is only valid in QSqlResult::record() resulting of a SELECT query.
      It is always false in records from QSqlDatabase::record() and
      QSqlDatabase::primaryIndex().

      Sample application attached.

      Steps how to reproduce:
      1. Create an empty mysql database
      2. Install myODBC connector(Tested with 5.1 and 5.3 versions)
      http://dev.mysql.com/downloads/connector/odbc/5.1.html
      http://dev.mysql.com/downloads/connector/odbc/5.3.html
      3. Open "Data Sources (ODBC) from control panel and add an entry for your database. Name it "mydb" or change the definition in main.cpp.
      4. Run the example and see the "isAutoValue" outputs.

      Original driver output is:
      record.autovalues: no no (should be: yes no)
      primaryIndex.autovalues: no (should be: yes)
      select.autovalues: no (should be: yes)

      Patched driver output:
      record.autovalues: no no (should be: yes no)
      primaryIndex.autovalues: no (should be: yes)
      select.autovalues: yes (OK)

      Attachments

        1. odbcautovalue.zip
          2 kB
        2. qodbc.patch
          0.9 kB
        3. qtbug39388.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            anylitok Antti Yli-Tokola (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes