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>
This commit is contained in:
Christian Ehrlicher 2018-09-23 17:21:21 +02:00
parent e3c84b6da1
commit 2b682972c2

View File

@ -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));
}