summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBill King <bking@trolltech.com>2009-10-13 02:00:42 (GMT)
committerBill King <bking@trolltech.com>2009-10-13 03:21:49 (GMT)
commit99e7dcf532b1c84aa64a7ab9af9a5fd14fd64033 (patch)
tree62933ef2a7afc448ecf42677536dde8f4ea398a3 /tests
parentbee70a74465ef837b446ef2d2309a002da5bfe30 (diff)
downloadQt-99e7dcf532b1c84aa64a7ab9af9a5fd14fd64033.zip
Qt-99e7dcf532b1c84aa64a7ab9af9a5fd14fd64033.tar.gz
Qt-99e7dcf532b1c84aa64a7ab9af9a5fd14fd64033.tar.bz2
Fixes autotests now for MS Access via ODBC.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp8
-rw-r--r--tests/auto/qsqldatabase/tst_databases.h1
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp21
-rw-r--r--tests/auto/qsqldriver/tst_qsqldriver.cpp12
-rw-r--r--tests/auto/qsqlthread/tst_qsqlthread.cpp2
5 files changed, 34 insertions, 10 deletions
diff --git a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp
index 5893687..237f29d 100644
--- a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp
+++ b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp
@@ -108,8 +108,12 @@ void tst_Q3SqlSelectCursor::createTestTables( QSqlDatabase db )
return;
QSqlQuery q( db );
// please never ever change this table; otherwise fix all tests ;)
- QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null,"
- "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" ));
+ if (tst_Databases::isMSAccess(db))
+ QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null,"
+ "t_char char(40), t_numeric number, primary key (id, t_varchar) )" ));
+ else
+ QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null,"
+ "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" ));
}
void tst_Q3SqlSelectCursor::dropTestTables( QSqlDatabase db )
diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h
index c5c3663..25b1e2f 100644
--- a/tests/auto/qsqldatabase/tst_databases.h
+++ b/tests/auto/qsqldatabase/tst_databases.h
@@ -258,6 +258,7 @@ public:
// 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( "QODBC", "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\dbs\\access\\testdb.mdb", "", "", "" );
}
void open()
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index c9c8f5e..ed13340 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -792,8 +792,8 @@ void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db)
if (val1.type() == QVariant::DateTime || val1.type() == QVariant::Time)
qDebug("Received Time: " + val1.toTime().toString("hh:mm:ss.zzz"));
QFAIL(QString(" Expected: '%1' Received: '%2' for field %3 (etype %4 rtype %5) in checkValues").arg(
- val2.toString()).arg(
- val1.toString()).arg(
+ val2.type() == QVariant::ByteArray ? val2.toByteArray().toHex() : val2.toString()).arg(
+ val1.type() == QVariant::ByteArray ? val1.toByteArray().toHex() : val1.toString()).arg(
fieldDefs[ i ].fieldName()).arg(
val2.typeName()).arg(
val1.typeName())
@@ -1292,9 +1292,9 @@ void tst_QSqlDatabase::recordAccess()
FieldDef("varchar(20)", QVariant::String, QString("Blah1")),
FieldDef("single", QVariant::Double, 1.12345),
FieldDef("double", QVariant::Double, 1.123456),
- FieldDef("byte", QVariant::Int, 255),
+ FieldDef("byte", QVariant::UInt, 255),
#ifdef QT3_SUPPORT
- FieldDef("binary", QVariant::ByteArray, Q3CString("Blah2")),
+ FieldDef("binary(5)", QVariant::ByteArray, Q3CString("Blah2")),
#endif
FieldDef("long", QVariant::Int, 2147483647),
FieldDef("memo", QVariant::String, memo),
@@ -1643,7 +1643,10 @@ void tst_QSqlDatabase::precisionPolicy()
QSKIP("Driver or database doesn't support setting precision policy", SkipSingle);
// Create a test table with some data
- QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id smallint, num numeric(18,5))").arg(tableName)));
+ if(tst_Databases::isMSAccess(db))
+ QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id smallint, num number)").arg(tableName)));
+ else
+ QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id smallint, num numeric(18,5))").arg(tableName)));
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES (?, ?)").arg(tableName)));
q.bindValue(0, 1);
q.bindValue(1, 123);
@@ -2007,6 +2010,7 @@ void tst_QSqlDatabase::odbc_bindBoolean()
QSKIP("MySql has inconsistent behaviour of bit field type across versions.", SkipSingle);
return;
}
+
QSqlQuery q(db);
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool") + "(id int, boolvalue bit)"));
@@ -2038,6 +2042,8 @@ void tst_QSqlDatabase::odbc_testqGetString()
QSqlQuery q(db);
if (tst_Databases::isSqlServer(db))
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(MAX))"));
+ else if(tst_Databases::isMSAccess(db))
+ QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue memo)"));
else
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))"));
@@ -2264,7 +2270,10 @@ void tst_QSqlDatabase::odbc_uintfield()
unsigned int val = 4294967295U;
QSqlQuery q(db);
- q.exec(QString("CREATE TABLE %1(num numeric(10))").arg(tableName));
+ if ( tst_Databases::isMSAccess( db ) )
+ QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(num number)").arg(tableName)));
+ else
+ QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(num numeric(10))").arg(tableName)));
q.prepare(QString("INSERT INTO %1 VALUES(?)").arg(tableName));
q.addBindValue(val);
QVERIFY_SQL(q, exec());
diff --git a/tests/auto/qsqldriver/tst_qsqldriver.cpp b/tests/auto/qsqldriver/tst_qsqldriver.cpp
index f463c9e..8fc38a7 100644
--- a/tests/auto/qsqldriver/tst_qsqldriver.cpp
+++ b/tests/auto/qsqldriver/tst_qsqldriver.cpp
@@ -160,7 +160,11 @@ void tst_QSqlDriver::record()
//check that we can't get records using incorrect tablename casing that's been quoted
rec = db.driver()->record(db.driver()->escapeIdentifier(tablename,QSqlDriver::TableName));
- if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db))
+ if (tst_Databases::isMySQL(db)
+ || db.driverName().startsWith("QSQLITE")
+ || db.driverName().startsWith("QTDS")
+ || tst_Databases::isSqlServer(db)
+ || tst_Databases::isMSAccess(db))
QCOMPARE(rec.count(), 4); //mysql, sqlite and tds will match
else
QCOMPARE(rec.count(), 0);
@@ -208,7 +212,11 @@ void tst_QSqlDriver::primaryIndex()
tablename = tablename.toUpper();
index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName));
- if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db))
+ if (tst_Databases::isMySQL(db)
+ || db.driverName().startsWith("QSQLITE")
+ || db.driverName().startsWith("QTDS")
+ || tst_Databases::isSqlServer(db)
+ || tst_Databases::isMSAccess(db))
QCOMPARE(index.count(), 1); //mysql will always find the table name regardless of casing
else
QCOMPARE(index.count(), 0);
diff --git a/tests/auto/qsqlthread/tst_qsqlthread.cpp b/tests/auto/qsqlthread/tst_qsqlthread.cpp
index c088a47..be66e9e 100644
--- a/tests/auto/qsqlthread/tst_qsqlthread.cpp
+++ b/tests/auto/qsqlthread/tst_qsqlthread.cpp
@@ -404,6 +404,8 @@ void tst_QSqlThread::readWriteThreading()
if (db.databaseName() == ":memory:")
QSKIP("does not work with in-memory databases", SkipSingle);
+ else if (tst_Databases::isMSAccess(db))
+ QSKIP("does not work with MS Access databases", SkipSingle);
SqlProducer producer(db);
SqlConsumer consumer(db);