summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql/models/qsqlquerymodel
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-03-16 10:53:24 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-03-21 10:16:56 +0100
commit14f9f00fdb2dc428610c08e3d9d03e38e9602166 (patch)
tree6cbd9a748d3907d66d1033a5a5050af7f5e80fd3 /tests/auto/sql/models/qsqlquerymodel
parent37e0953613ef9a3db137bc8d3076441d9ae317d9 (diff)
QSqlQuery: make it a move only type
QSqlQuery is a broken value class. Copying one object would mean copying database state (the result set, the cursor position, etc.) which isn't generally available for all database drivers. For that reason, the current implementation does not honor value semantics -- modifying a QSqlQuery object has visible side effects on its existing copies (!). The correct solution is to accept that QSqlQuery is a move only type, not a value type. Add move semantics to it, and deprecate its copies. (We can't just *remove* copies in Qt 6 due to SC/BC constraints). [ChangeLog][QtSql][QSqlQuery] QSqlQuery copy operations have been deprecated. QSqlQuery copy semantics cannot be implemented correctly, as it's not generally possible to copy a result set of a query when copying the corresponding QSqlQuery object. This resulted in modifications on a QSqlQuery having visible (and unintended) side effects on its copies. Instead, treat QSqlQuery as a move-only type. Fixes: QTBUG-91766 Change-Id: Iabd3aa605332a5c15c524303418bf17a21ed520b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/sql/models/qsqlquerymodel')
-rw-r--r--tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
index f323c8b984..ce65dcf674 100644
--- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -573,7 +573,7 @@ void tst_QSqlQueryModel::setQueryWithNoRowsInResultSet()
// The query's result set will be empty so no signals should be emitted!
QSqlQuery query(db);
QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test", __FILE__, db) + " where 0 = 1"));
- model.setQuery(query);
+ model.setQuery(std::move(query));
QCOMPARE(modelRowsAboutToBeInsertedSpy.count(), 0);
QCOMPARE(modelRowsInsertedSpy.count(), 0);
}