summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-07-10 22:11:11 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-07-13 09:54:45 (GMT)
commitf8edd0bad1f41267a1805297a5bc8717685cad2a (patch)
tree84935e3d5fc85f0997a1644393ae4fe46839d31d /src/sql
parentea718a55f119381df25fc9d62126bb76a677ba95 (diff)
downloadQt-f8edd0bad1f41267a1805297a5bc8717685cad2a.zip
Qt-f8edd0bad1f41267a1805297a5bc8717685cad2a.tar.gz
Qt-f8edd0bad1f41267a1805297a5bc8717685cad2a.tar.bz2
QSqlTM: respect generated flag in insertRecord() and setRecord()
These methods failed to respect the setting of the generated flag on the fields of source record. INSERT and UPDATE statements should only include fields where generated is TRUE. Test included. Follow-up to 0f15ab4e750690bdb2b649332d5c3276bf24c440. Change-Id: I2f10dbcd7e5e5123489b38a123effe43a673a427 Task-number: QTBUG-23592 Reviewed-by: Bill King <bill.king@nokia.com> Reviewed-by: Jason Dolan <jason.t.dolan@gmail.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/models/qsqltablemodel.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index d2b9427..a313014 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -80,6 +80,8 @@ bool QSqlTableModelPrivate::setRecord(int row, const QSqlRecord &record)
if (strategy == QSqlTableModel::OnFieldChange)
strategy = QSqlTableModel::OnRowChange;
for (int i = 0; i < record.count(); ++i) {
+ if (!record.isGenerated(i))
+ continue;
int idx = nameToIndex(record.fieldName(i));
if (idx == -1)
continue;
@@ -1353,7 +1355,8 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record)
if (idx == -1) {
isOk = false;
} else {
- QSqlTableModelPrivate::setGeneratedValue(mrow.rec, idx, record.value(i));
+ mrow.rec.setValue(idx, record.value(i));
+ mrow.rec.setGenerated(idx, record.isGenerated(i));
}
}