summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBill King <bking@trolltech.com>2009-07-08 01:17:40 (GMT)
committerBill King <bking@trolltech.com>2009-07-08 01:17:40 (GMT)
commitb2e62931f1b2968a69aa013b27a50d2e6beb4e27 (patch)
tree81e01b6ad99c48fd90ac797a07870f8522327312 /tests/auto
parent5ff22b1ed4da11dc16a236825c939b5ae38d27cc (diff)
downloadQt-b2e62931f1b2968a69aa013b27a50d2e6beb4e27.zip
Qt-b2e62931f1b2968a69aa013b27a50d2e6beb4e27.tar.gz
Qt-b2e62931f1b2968a69aa013b27a50d2e6beb4e27.tar.bz2
Cleanup more SQL autotest failures.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qsqldatabase/tst_databases.h13
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp7
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp20
3 files changed, 28 insertions, 12 deletions
diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h
index bd51b97..8ee74df 100644
--- a/tests/auto/qsqldatabase/tst_databases.h
+++ b/tests/auto/qsqldatabase/tst_databases.h
@@ -249,12 +249,15 @@ public:
// addDb( "QODBC3", "DRIVER={SQL Native Client};SERVER=silence.nokia.troll.no\\SQLEXPRESS", "troll", "trond", "" );
// addDb( "QODBC", "DRIVER={MySQL ODBC 3.51 Driver};SERVER=mysql5-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" );
+// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=mysql4-nokia.trolltech.com.au;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( "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_", "" );
}
void open()
@@ -438,6 +441,16 @@ public:
return db.databaseName().contains( "Access Driver", Qt::CaseInsensitive );
}
+ static bool isPostgreSQL( QSqlDatabase db )
+ {
+ return db.driverName().startsWith("QPSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("PostgreSQL") );
+ }
+
+ static bool isMySQL( QSqlDatabase db )
+ {
+ return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL") );
+ }
+
// -1 on fail, else Oracle version
static int getOraVersion( QSqlDatabase db )
{
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index 21064c3..025e895 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -256,6 +256,8 @@ static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db)
QString autoName = tst_Databases::autoFieldName(db);
if (tst_Databases::isMSAccess(db))
qs.append(" (id int not null");
+ else if (tst_Databases::isPostgreSQL(db))
+ qs.append(" (id serial not null");
else
qs.append(QString("(id integer not null %1 primary key").arg(autoName));
@@ -1350,6 +1352,8 @@ void tst_QSqlDatabase::transaction()
}
QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 41"));
+ if(db.driverName().startsWith("QODBC") && dbName.contains("MySQL"))
+ QEXPECT_FAIL("", "Some odbc drivers don't actually roll back despite telling us they do, especially the mysql driver", Continue);
QVERIFY(!q.next());
populateTestTables(db);
@@ -1427,7 +1431,8 @@ void tst_QSqlDatabase::caseSensivity()
bool cs = false;
if (db.driverName().startsWith("QMYSQL")
|| db.driverName().startsWith("QSQLITE")
- || db.driverName().startsWith("QTDS"))
+ || db.driverName().startsWith("QTDS")
+ || db.driverName().startsWith("QODBC"))
cs = true;
QSqlRecord rec = db.record(qTableName("qtest"));
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 30b85e8..5e782ca 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -188,7 +188,7 @@ private slots:
void task_205701_data() { generic_data("QMYSQL"); }
void task_205701();
- void task_233829_data() { generic_data(); }
+ void task_233829_data() { generic_data("QPSQL"); }
void task_233829();
@@ -322,7 +322,10 @@ void tst_QSqlQuery::createTestTables( QSqlDatabase db )
// in the MySQL server startup script
q.exec( "set table_type=innodb" );
- QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) );
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) );
+ else
+ QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) );
if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) )
QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null" ) + " (id int null, t_varchar varchar(20) null)" ) );
@@ -1874,7 +1877,7 @@ void tst_QSqlQuery::invalidQuery()
QVERIFY( !q.next() );
QVERIFY( !q.isActive() );
- if ( !db.driverName().startsWith( "QOCI" ) && !db.driverName().startsWith( "QDB2" ) ) {
+ if ( !db.driverName().startsWith( "QOCI" ) && !db.driverName().startsWith( "QDB2" ) && !db.driverName().startsWith( "QODBC" ) ) {
// oracle and db2 just prepares everything without complaining
if ( db.driver()->hasFeature( QSqlDriver::PreparedQueries ) )
QVERIFY( !q.prepare( "blahfasel" ) );
@@ -2034,7 +2037,7 @@ void tst_QSqlQuery::oraArrayBind()
q.bindValue( 0, list, QSql::In );
- QVERIFY_SQL( q, execBatch( QSqlQuery::ValuesAsRows ) );
+ QVERIFY_SQL( q, execBatch( QSqlQuery::ValuesAsColumns ) );
QVERIFY_SQL( q, prepare( "BEGIN "
"ora_array_test.get_table(?); "
@@ -2046,7 +2049,7 @@ void tst_QSqlQuery::oraArrayBind()
q.bindValue( 0, list, QSql::Out );
- QVERIFY_SQL( q, execBatch( QSqlQuery::ValuesAsRows ) );
+ QVERIFY_SQL( q, execBatch( QSqlQuery::ValuesAsColumns ) );
QVariantList out_list = q.boundValue( 0 ).toList();
@@ -2593,7 +2596,7 @@ void tst_QSqlQuery::blobsPreparedQuery()
if ( db.driverName().startsWith( "QPSQL" ) )
typeName = "BYTEA";
- else if ( db.driverName().startsWith( "QODBC" ) )
+ else if ( db.driverName().startsWith( "QODBC" ) && tst_Databases::isSqlServer( db ))
typeName = "IMAGE";
QVERIFY_SQL( q, exec( QString( "CREATE TABLE %1(id INTEGER, data %2)" ).arg( tableName ).arg( typeName ) ) );
@@ -2826,13 +2829,8 @@ void tst_QSqlQuery::task_233829()
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if (!db.driverName().startsWith( "QPSQL" )) {
- QSKIP( "This is a PostgreSQL specific test", SkipSingle );
- }
-
QSqlQuery q( db );
QString tableName = qTableName("task_233829");
- q.exec("DROP TABLE " + tableName);
QVERIFY_SQL(q,exec("CREATE TABLE " + tableName + " (dbl1 double precision,dbl2 double precision) without oids;"));
QString queryString("INSERT INTO " + tableName +"(dbl1, dbl2) VALUES(?,?)");