From 2b682972c2266e52b1510080a56b574e9ffd4db0 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 23 Sep 2018 17:21:21 +0200 Subject: QSqlQuery: add another testcase for bindBool() tst_QSqlQuery::bindBool() did not check if the bool is correctly bound as part of the WHERE statement. Add a new test to query for the bool column and check if there is exactly one row returned. Fixes: QTBUG-38891 Change-Id: I0bd1ceb1b30e50f67f44f5b06d68683195b78b29 Reviewed-by: Andy Shaw --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 4ce1009c90..c4cf2e752f 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -633,13 +633,20 @@ void tst_QSqlQuery::bindBool() QVERIFY_SQL(q, exec()); } - QVERIFY_SQL(q, exec("SELECT id, flag FROM " + tableName)); + QVERIFY_SQL(q, exec("SELECT id, flag FROM " + tableName + " ORDER BY id")); for (int i = 0; i < 2; ++i) { bool flag = i; QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), i); QCOMPARE(q.value(1).toBool(), flag); } + QVERIFY_SQL(q, prepare("SELECT flag FROM " + tableName + " WHERE flag = :filter")); + const bool filter = true; + q.bindValue(":filter", filter); + QVERIFY_SQL(q, exec()); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toBool(), filter); + QFAIL_SQL(q, next()); QVERIFY_SQL(q, exec("DROP TABLE " + tableName)); } -- cgit v1.2.3