From 46b7c91c81de2d830e7a7c993ea3e94e5d182124 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Mon, 11 Feb 2013 21:14:00 +0100 Subject: QSqlQuery tests: fix bool test for postgresql Change-Id: I60634f89841cbc81058588e435c6482c6c0efed6 Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 764b29dc85..8972524a0f 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -580,9 +580,10 @@ void tst_QSqlQuery::mysqlOutValues() void tst_QSqlQuery::bindBool() { // QTBUG-27763: bool value got converted to int 127 by mysql driver because sizeof(bool) < sizeof(int). - // The problem was the way the bool value from the application was handled. It doesn't matter - // whether the table column type is BOOL or INT. Use INT here because all DBMSs have it and all - // should pass this test. + // The problem was the way the bool value from the application was handled. For our purposes here, it + // doesn't matter whether the column type is BOOLEAN or INT. All DBMSs have INT, and this usually + // works for this test. Postresql is an exception because its INT type does not accept BOOLEAN + // values and its BOOLEAN columns do not accept INT values. QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); @@ -590,7 +591,8 @@ void tst_QSqlQuery::bindBool() const QString tableName(qTableName( "bindBool", __FILE__ )); q.exec("DROP TABLE " + tableName); - QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INT, flag INT NOT NULL, PRIMARY KEY(id))")); + QString colType = db.driverName().startsWith("QPSQL") ? QLatin1String("BOOLEAN") : QLatin1String("INT"); + QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INT, flag " + colType + " NOT NULL, PRIMARY KEY(id))")); for (int i = 0; i < 2; ++i) { bool flag = i; -- cgit v1.2.3