summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-09-28 10:10:29 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-05 03:16:19 +0200
commit10ff9de91bedf93852f13a58287afd8831644759 (patch)
treef26fa943dda21f1a4a4ee3d782e06867fefea6e6 /tests/auto/sql
parent838eadba0b79eab32cdf9e5d04bc2ab3541731d1 (diff)
QSqlTableModel: don't cache unchanged value in setData()
This is good for performance in terms of avoiding unnecessary database activity and keeping the cache smaller. Detail: This change was not included in the big refactoring of QSqlTM. The idea was that the model shouldn't second guess the intention of the application and maybe the application wants to cause a submit. It was a marginal consideration. Now I think it's clear that our interest in not unnecessarily expanding the cache outweighs that. In addition, applications can now call selectRow() if they worry that the database values for the row have changed and want to set a value back again. Test added. Change-Id: I63814dcb63a96c6ba1c8cc227807725a954a0b68 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests/auto/sql')
-rw-r--r--tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
index a4e1fa1c0d..d40ccebefc 100644
--- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -1146,6 +1146,14 @@ void tst_QSqlTableModel::isDirty()
QVERIFY_SQL(model, select());
QFAIL_SQL(model, isDirty());
+ // check that setting the current value does not add to the cache
+ {
+ QModelIndex i = model.index(0, 1);
+ QVariant v = model.data(i, Qt::EditRole);
+ QVERIFY_SQL(model, setData(i, v));
+ QFAIL_SQL(model, isDirty());
+ }
+
if (submitpolicy != QSqlTableModel::OnFieldChange) {
// setData() followed by revertAll()
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));