summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-09-23 17:21:21 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-11-02 08:27:12 +0000
commit2b682972c2266e52b1510080a56b574e9ffd4db0 (patch)
treea6553a0495146c309b531d11f07a81274963e822 /tests/auto/sql
parente3c84b6da1cbef7ed779ba5eec6ae3ed8e4e5d59 (diff)
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 <andy.shaw@qt.io>
Diffstat (limited to 'tests/auto/sql')
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp9
1 files changed, 8 insertions, 1 deletions
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));
}