diff options
author | Mark Brand <mabrand@mabrand.nl> | 2013-02-11 21:14:00 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-12 10:56:00 +0100 |
commit | 46b7c91c81de2d830e7a7c993ea3e94e5d182124 (patch) | |
tree | 2b2045f8f9058c1b563038d2cf59805e5553b362 /tests/auto/sql | |
parent | f01caaf64a6798e805ce5df9f735a5b86bfe8eb8 (diff) |
QSqlQuery tests: fix bool test for postgresql
Change-Id: I60634f89841cbc81058588e435c6482c6c0efed6
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'tests/auto/sql')
-rw-r--r-- | tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
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; |