Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.2.1, 5.3.0
-
None
-
4deea4b905ea1ad32fde317f8556a5c8cdd775cd
Description
Code like this (with a MYSQL backend) worked fine with Qt 4.8:
m_supportTableModel = new QSqlTableModel(this);
m_supportTableModel->setTable("...");
m_supportTableModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
m_supportTableModel->insertRow(0);
QSqlRecord record = m_supportTableModel->record(0);
qDebug() << record; // all fields had generated: yes
record.setValue("CODE_SUPPORT", m_codeSupport);
m_supportTableModel->setRecord(0, record);
m_supportTableModel->submitAll(); // returned true
With Qt 5.2, all fields have "generated: no", and therefore the value for CODE_SUPPORT isn't stored (and the submitAll fails since this is a required value).
Since I use QDataWidgetMapper for the other fields, they go through QSqlTableModel::setData which calls ModifiedRow::setValue which sets generated to true. Why doesn't QSqlRecord::setValue do the same, for the case of values set by the application?
The documentation for QSqlTableModel::setRecord says "remember to set generated to false if the db is meant to supply the value"... well, I'm supplying all the values, so I didn't expect to have to set it to true, it sounds like it's the default – and it was, in Qt 4.8.