summaryrefslogtreecommitdiff
path: root/src/sql
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-07-11 00:11:11 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-13 11:54:45 +0200
commitf8edd0bad1f41267a1805297a5bc8717685cad2a (patch)
tree84935e3d5fc85f0997a1644393ae4fe46839d31d /src/sql
parentea718a55f119381df25fc9d62126bb76a677ba95 (diff)
downloadqt4-tools-f8edd0bad1f41267a1805297a5bc8717685cad2a.tar.gz
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 d2b9427287..a313014abc 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));
}
}