diff options
author | Jesus Fernandez <jesus.fernandez@qt.io> | 2017-12-13 13:43:49 +0100 |
---|---|---|
committer | Jesus Fernandez <Jesus.Fernandez@qt.io> | 2019-01-30 23:08:04 +0000 |
commit | 9501e92841d0a97ff5083f0000947a2e795f61a2 (patch) | |
tree | 19c999db75051f14de8f6d44d294dd8f7b7bbfdf /tests | |
parent | 0bde49bd92b0d4366b91c5cdd1585e0e1fb623bc (diff) |
Replace executedQuery when executing a new query
Only the first successful query was stored in the variable. When a new
query is executed the function QSqlResult::setActive was not replacing
the last executed query.
Fixes: QTBUG-28883
Change-Id: Ib4938c42e6264f9edd0764b4a392da7988f68fc0
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index c4cf2e752f..710f26b72d 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -158,6 +158,8 @@ private slots: void lastInsertId(); void lastQuery_data() { generic_data(); } void lastQuery(); + void lastQueryTwoQueries_data() { generic_data(); } + void lastQueryTwoQueries(); void bindBool_data() { generic_data(); } void bindBool(); void psql_bindWithDoubleColonCastOperator_data() { generic_data("QPSQL"); } @@ -2813,6 +2815,25 @@ void tst_QSqlQuery::lastQuery() QCOMPARE( q.executedQuery(), sql ); } +void tst_QSqlQuery::lastQueryTwoQueries() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + + QString sql = QLatin1String("select * from ") + qtest; + QVERIFY_SQL(q, exec(sql)); + QCOMPARE(q.lastQuery(), sql); + QCOMPARE(q.executedQuery(), sql); + + sql = QLatin1String("select id from ") + qtest; + QVERIFY_SQL(q, exec(sql)); + QCOMPARE(q.lastQuery(), sql); + QCOMPARE(q.executedQuery(), sql); +} + void tst_QSqlQuery::psql_bindWithDoubleColonCastOperator() { QFETCH( QString, dbName ); |