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. Change-Id: I9d216e770733af8b0771280276dba0775209a802 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Dheerendra Purohit <dheerendra@pthinks.com> (cherry picked from commit af760da54190d96b315ea8edeec00c86871af0d8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
78051d03ca
commit
cdfd686714
@ -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);
|
||||
model.setQuery(std::move(query));
|
||||
}
|
||||
|
||||
QCOMPARE(model.rowCount(), 1);
|
||||
QCOMPARE(model.data(model.index(0, 0)).toString(), QString("harry"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user