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

Add support for default field value in MySQL driver

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Out of scope
    • Icon: P2: Important P2: Important
    • None
    • 4.0.0, 4.7.3
    • SQL Support
    • None

      Default field values does not work correctly with Qt 4.x for MySQL databases. The feature was working in Qt 3.x

      This means the code as follows does not work anymore with Qt4:

      const QSqlRecord &tableInfo = GetDatabase().record(QString(m_strTableName));
      QVariant xDefaultValue = tableInfo.field(uiIndex).defaultValue();
      

      For MySQL databases the defaultValue() call in above code will always return an invalid variant, whereas the following call produces the expected result:

      QString strName = tableInfo.field(uiIndex).name();
      

      The defaultValue API does not work because QSqlField::setDefaultValue method is not called in the MySQL driver in qToField method.
      For other database types such as SQLite or PSQL the QSqlField::setDefaultValue is called in corresponding places.

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

            mabrand Mark Brand
            e0101981 Janne Anttila
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes