diff options
Diffstat (limited to 'tests/auto/sql/kernel')
-rw-r--r-- | tests/auto/sql/kernel/qsqldatabase/tst_databases.h | 36 | ||||
-rw-r--r-- | tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp | 2 | ||||
-rw-r--r-- | tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 52 |
3 files changed, 55 insertions, 35 deletions
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h index 9e3b37ed53..9d3523576f 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h +++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h @@ -232,7 +232,7 @@ public: // addDb( "QOCI8", "//horsehead.nokia.troll.no:1521/ustest.troll.no", "scott", "tiger", "" ); // Oracle 9i on horsehead // addDb( "QOCI8", "//iceblink.nokia.troll.no:1521/ice.troll.no", "scott", "tiger", "" ); // Oracle 8 on iceblink (not currently working) // addDb( "QOCI", "//silence.nokia.troll.no:1521/testdb", "scott", "tiger" ); // Oracle 10g on silence -// addDb( "QOCI", "//bq-oracle10g.apac.nokia.com:1521/XE", "scott", "tiger" ); // Oracle 10gexpress +// addDb( "QOCI", "//bq-oracle10g.qt-project.org:1521/XE", "scott", "tiger" ); // Oracle 10gexpress // This requires a local ODBC data source to be configured( pointing to a MySql database ) // addDb( "QODBC", "mysqlodbc", "troll", "trond" ); @@ -247,9 +247,9 @@ public: // addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.nokia.troll.no", 3309, "CLIENT_COMPRESS=1;CLIENT_SSL=1" ); // MySQL 5.0.18 Linux // addDb( "QMYSQL3", "testdb", "troll", "trond", "silence.nokia.troll.no" ); // MySQL 5.1.36 Windows -// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "bq-mysql41.apac.nokia.com" ); // MySQL 4.1.22-2.el4 linux -// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "bq-mysql50.apac.nokia.com" ); // MySQL 5.0.45-7.el5 linux -// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "bq-mysql51.apac.nokia.com" ); // MySQL 5.1.36-6.7.2.i586 linux +// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "bq-mysql41.qt-project.org" ); // MySQL 4.1.22-2.el4 linux +// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "bq-mysql50.qt-project.org" ); // MySQL 5.0.45-7.el5 linux +// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "bq-mysql51.qt-project.org" ); // MySQL 5.1.36-6.7.2.i586 linux // addDb( "QPSQL7", "testdb", "troll", "trond", "horsehead.nokia.troll.no" ); // V7.2 NOT SUPPORTED! // addDb( "QPSQL7", "testdb", "troll", "trond", "horsehead.nokia.troll.no", 5434 ); // V7.2 NOT SUPPORTED! Multi-byte @@ -258,14 +258,14 @@ public: // addDb( "QPSQL7", "testdb", "troll", "trond", "horsehead.nokia.troll.no", 5437 ); // V8.0.3 // addDb( "QPSQL7", "testdb", "troll", "trond", "silence.nokia.troll.no" ); // V8.2.1, UTF-8 -// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-postgres74.apac.nokia.com" ); // Version 7.4.19-1.el4_6.1 -// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-pgsql81.apac.nokia.com" ); // Version 8.1.11-1.el5_1.1 -// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-pgsql84.apac.nokia.com" ); // Version 8.4.1-2.1.i586 -// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-pgsql90.apac.nokia.com" ); // Version 9.0.0 +// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-postgres74.qt-project.org" ); // Version 7.4.19-1.el4_6.1 +// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-pgsql81.qt-project.org" ); // Version 8.1.11-1.el5_1.1 +// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-pgsql84.qt-project.org" ); // Version 8.4.1-2.1.i586 +// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-pgsql90.qt-project.org" ); // Version 9.0.0 // addDb( "QDB2", "testdb", "troll", "trond", "silence.nokia.troll.no" ); // DB2 v9.1 on silence -// addDb( "QDB2", "testdb", "testuser", "Ee4Gabf6_", "bq-db2-972.apac.nokia.com" ); // DB2 +// addDb( "QDB2", "testdb", "testuser", "Ee4Gabf6_", "bq-db2-972.qt-project.org" ); // DB2 // yes - interbase really wants the physical path on the host machine. // addDb( "QIBASE", "/opt/interbase/qttest.gdb", "SYSDBA", "masterkey", "horsehead.nokia.troll.no" ); @@ -274,8 +274,8 @@ public: // addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "firebird1-nokia.trolltech.com.au" ); // Firebird 1.5.5 // addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "firebird2-nokia.trolltech.com.au" ); // Firebird 2.1.1 -// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "bq-firebird1.apac.nokia.com" ); // Firebird 1.5.5 -// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "bq-firebird2.apac.nokia.com" ); // Firebird 2.1.1 +// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "bq-firebird1.qt-project.org" ); // Firebird 1.5.5 +// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "bq-firebird2.qt-project.org" ); // Firebird 2.1.1 // use in-memory database to prevent local files // addDb("QSQLITE", ":memory:"); @@ -284,18 +284,18 @@ public: // addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=iceblink.nokia.troll.no\\ICEBLINK", "troll", "trond", "" ); // addDb( "QODBC3", "DRIVER={SQL Native Client};SERVER=silence.nokia.troll.no\\SQLEXPRESS", "troll", "trond", "" ); -// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=bq-mysql50.apac.nokia.com;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); -// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=bq-mysql51.apac.nokia.com;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=bq-mysql50.qt-project.org;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=bq-mysql51.qt-project.org;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); // addDb( "QODBC", "DRIVER={FreeTDS};SERVER=horsehead.nokia.troll.no;DATABASE=testdb;PORT=4101;UID=troll;PWD=trondk", "troll", "trondk", "" ); // addDb( "QODBC", "DRIVER={FreeTDS};SERVER=silence.nokia.troll.no;DATABASE=testdb;PORT=2392;UID=troll;PWD=trond", "troll", "trond", "" ); -// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" ); -// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" ); +// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2003-x86-01.qt-project.org;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" ); +// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2008-x86-01.qt-project.org;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" ); // addDb( "QTDS7", "testdb", "testuser", "Ee4Gabf6_", "bq-winserv2003" ); // addDb( "QTDS7", "testdb", "testuser", "Ee4Gabf6_", "bq-winserv2008" ); -// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" ); -// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2003-x86-01.qt-project.org;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2008-x86-01.qt-project.org;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" ); // addDb( "QODBC", "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\dbs\\access\\testdb.mdb", "", "", "" ); -// addDb( "QODBC", "DRIVER={Postgresql};SERVER=bq-pgsql84.apac.nokia.com;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={Postgresql};SERVER=bq-pgsql84.qt-project.org;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); } void open() diff --git a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp index 1302aedb14..bee4441c0f 100644 --- a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp +++ b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp @@ -102,7 +102,7 @@ void tst_QSqlError::construction() QCOMPARE(obj1.databaseText(), QString("databasetext")); QCOMPARE(obj1.type(), QSqlError::UnknownError); QCOMPARE(obj1.number(), 123); - obj1.isValid(); + QVERIFY(obj1.isValid()); QSqlError obj2(obj1); QCOMPARE(obj2.driverText(), obj1.driverText()); diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 4e821dacc5..1d2a60506f 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -420,9 +420,11 @@ void tst_QSqlQuery::char1Select() { QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "char1Select", __FILE__ ) + " (id char(1))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "char1Select", __FILE__ ) + " values ('a')" ) ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "char1Select", __FILE__ ) ) ); + const QString tbl = qTableName("char1Select", __FILE__); + q.exec( "drop table " + tbl); + QVERIFY_SQL(q, exec("create table " + tbl + " (id char(1))")); + QVERIFY_SQL(q, exec("insert into " + tbl + " values ('a')")); + QVERIFY_SQL(q, exec("select * from " + tbl)); QVERIFY( q.next() ); if ( db.driverName().startsWith( "QIBASE" ) ) @@ -540,7 +542,7 @@ void tst_QSqlQuery::mysqlOutValues() q.exec( "drop function " + hello ); - QVERIFY_SQL( q, exec( "create function " + hello + " (s char(20)) returns varchar(50) return concat('Hello ', s)" ) ); + QVERIFY_SQL(q, exec("create function " + hello + " (s char(20)) returns varchar(50) READS SQL DATA return concat('Hello ', s)")); QVERIFY_SQL( q, exec( "select " + hello + "('world')" ) ); QVERIFY_SQL( q, next() ); @@ -580,9 +582,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 +593,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; @@ -1487,6 +1491,7 @@ void tst_QSqlQuery::precision() // need a new scope for SQLITE QSqlQuery q( db ); + q.exec("drop table " + qtest_precision); if ( tst_Databases::isMSAccess( db ) ) QVERIFY_SQL( q, exec( "create table " + qtest_precision + " (col1 number)" ) ); else @@ -1751,6 +1756,7 @@ void tst_QSqlQuery::prepare_bind_exec() else createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200), name2 varchar(200))"; + q.exec("drop table " + qtest_prepare); QVERIFY_SQL( q, exec( createQuery ) ); QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (:id, :name)" ) ); @@ -2284,8 +2290,10 @@ void tst_QSqlQuery::execErrorRecovery() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr", __FILE__ ) + " (id int not null primary key)" ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_exerr", __FILE__ ) + " values (?)" ) ); + const QString tbl = qTableName("qtest_exerr", __FILE__); + q.exec("drop table " + tbl); + QVERIFY_SQL(q, exec("create table " + tbl + " (id int not null primary key)")); + QVERIFY_SQL(q, prepare("insert into " + tbl + " values (?)" )); q.addBindValue( 1 ); QVERIFY_SQL( q, exec() ); @@ -2788,8 +2796,10 @@ void tst_QSqlQuery::emptyTableNavigate() { QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_empty", __FILE__ ) + " (id char(10))" ) ); - QVERIFY_SQL( q, prepare( "select * from " + qTableName( "qtest_empty", __FILE__ ) ) ); + const QString tbl = qTableName("qtest_empty", __FILE__); + q.exec("drop table " + tbl); + QVERIFY_SQL(q, exec("create table " + tbl + " (id char(10))")); + QVERIFY_SQL(q, prepare("select * from " + qTableName("qtest_empty", __FILE__ ))); QVERIFY_SQL( q, exec() ); QVERIFY( !q.next() ); QCOMPARE( q.lastError().isValid(), false ); @@ -2804,6 +2814,7 @@ void tst_QSqlQuery::task_217003() QSqlQuery q( db ); const QString Planet(qTableName( "Planet", __FILE__)); + q.exec("drop table " + Planet); QVERIFY_SQL( q, exec( "create table " + Planet + " (Name varchar(20))" ) ); QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Mercury')" ) ); QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Venus')" ) ); @@ -3580,7 +3591,7 @@ void tst_QSqlQuery::aggregateFunctionTypes() CHECK_DATABASE(db); QVariant::Type intType = QVariant::Int; // QPSQL uses LongLong for manipulation of integers - if (db.driverName().startsWith("QPSQL")) + if (db.driverName().startsWith("QPSQL") || db.driverName().startsWith("QMYSQL")) intType = QVariant::LongLong; { const QString tableName(qTableName("numericFunctionsWithIntValues", __FILE__)); @@ -3594,6 +3605,8 @@ void tst_QSqlQuery::aggregateFunctionTypes() QVERIFY(q.next()); if (db.driverName().startsWith("QSQLITE")) QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + else if (db.driverName().startsWith("QMYSQL")) + QCOMPARE(q.record().field(0).type(), QVariant::Double); else QCOMPARE(q.record().field(0).type(), intType); @@ -3603,11 +3616,15 @@ void tst_QSqlQuery::aggregateFunctionTypes() QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); QVERIFY(q.next()); QCOMPARE(q.value(0).toInt(), 3); - QCOMPARE(q.record().field(0).type(), intType); + if (db.driverName().startsWith("QMYSQL")) + QCOMPARE(q.record().field(0).type(), QVariant::Double); + else + QCOMPARE(q.record().field(0).type(), intType); QVERIFY_SQL(q, exec("SELECT AVG(id) FROM " + tableName)); QVERIFY(q.next()); - if (db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QPSQL")) { + if (db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QPSQL") + || (db.driverName().startsWith("QMYSQL"))) { QCOMPARE(q.value(0).toDouble(), 1.5); QCOMPARE(q.record().field(0).type(), QVariant::Double); } else { @@ -3682,7 +3699,10 @@ void tst_QSqlQuery::aggregateFunctionTypes() QVERIFY_SQL(q, exec("SELECT ROUND(id, 0) FROM " + tableName + " WHERE id=2.5")); QVERIFY(q.next()); - QCOMPARE(q.value(0).toDouble(), 3.0); + if (db.driverName().startsWith("QMYSQL")) + QCOMPARE(q.value(0).toDouble(), 2.0); + else + QCOMPARE(q.value(0).toDouble(), 3.0); QCOMPARE(q.record().field(0).type(), QVariant::Double); } } |