summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2024-12-14 20:40:48 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2024-12-16 21:18:02 +0100
commitaf760da54190d96b315ea8edeec00c86871af0d8 (patch)
treede0bad1f228cbca51ebd68fb2204be4063ff1895 /tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
parentd884abaf8bdc1be74ee52306948c0be1986d738d (diff)
QSqlQueryModel test: don't copy a QSqlQuery
Move the query into the model, and use a local scope to make sure that we don't use the moved-from query later. Pick-to: 6.9 Change-Id: I9d216e770733af8b0771280276dba0775209a802 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Dheerendra Purohit <dheerendra@pthinks.com>
Diffstat (limited to 'tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp')
-rw-r--r--tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
index dbe1f998cf2..81aed273e18 100644
--- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -694,11 +694,13 @@ void tst_QSqlQueryModel::refreshQueryWithBoundValues()
QSqlDatabase db = QSqlDatabase::database(dbName);
QSqlQueryModel model;
- QSqlQuery query(db);
- query.prepare("SELECT name FROM " + qTableName("test", __FILE__, db) + " WHERE id = :id");
- query.bindValue(":id", 1);
- query.exec();
- model.setQuery(query);
+ {
+ QSqlQuery query(db);
+ query.prepare("SELECT name FROM " + qTableName("test", __FILE__, db) + " WHERE id = :id");
+ query.bindValue(":id", 1);
+ query.exec();
+ model.setQuery(std::move(query));
+ }
QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.data(model.index(0, 0)).toString(), QString("harry"));