summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp1
-rw-r--r--tests/auto/qsqldatabase/tst_databases.h59
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp4
3 files changed, 44 insertions, 20 deletions
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index 2d89639b5b..fa786f1cc3 100644
--- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
+++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
@@ -135,6 +135,7 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db )
if (tst_Databases::isSqlServer(db)) {
QVERIFY_SQL(q, exec("SET ANSI_DEFAULTS ON"));
+ QVERIFY_SQL(q, exec("SET IMPLICIT_TRANSACTIONS OFF"));
}
// please never ever change this table; otherwise fix all tests ;)
diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h
index b81182af23..c6b65a4804 100644
--- a/tests/auto/qsqldatabase/tst_databases.h
+++ b/tests/auto/qsqldatabase/tst_databases.h
@@ -217,7 +217,7 @@ 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", "iceblink.nokia.troll.no" ); // MySQL 5.0.13 Windows
// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "mysql4-nokia.trolltech.com.au" ); // MySQL 4.1.22-2.el4 linux
-// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "mysql5-nokia.trolltech.com.au" ); // MySQL 5.0.45-7.el5 linux
+// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "mysql5-nokia.trolltech.com.au" ); // MySQL 5.0.45-7.el5 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
@@ -239,7 +239,7 @@ public:
// use in-memory database to prevent local files
// addDb("QSQLITE", ":memory:");
- addDb( "QSQLITE", QDir::toNativeSeparators(QDir::tempPath()+"/foo.db") );
+ addDb( "QSQLITE", QDir::toNativeSeparators(QDir::tempPath()+"/foo.db") );
// addDb( "QSQLITE2", QDir::toNativeSeparators(QDir::tempPath()+"/foo2.db") );
// 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", "" );
@@ -251,6 +251,8 @@ public:
// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "testuser", "Ee4Gabf6_", "" );
// 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()
@@ -316,20 +318,28 @@ public:
QSqlQuery q( db );
QStringList dbtables=db.tables();
- foreach(QString tableName, tableNames)
+ foreach(const QString &tableName, tableNames)
{
wasDropped = true;
QString table=tableName;
if ( db.driver()->isIdentifierEscaped(table, QSqlDriver::TableName))
table = db.driver()->stripDelimiters(table, QSqlDriver::TableName);
- if ( dbtables.contains( table, Qt::CaseSensitive ) )
- wasDropped = q.exec( "drop table " + tableName);
- else if ( dbtables.contains( table, Qt::CaseInsensitive ) )
- wasDropped = q.exec( "drop table " + tableName);
-
- if ( !wasDropped )
- qWarning() << dbToString(db) << "unable to drop table" << tableName << ':' << q.lastError().text() << "tables:" << dbtables;
+ if ( dbtables.contains( table, Qt::CaseInsensitive ) ) {
+ foreach(const QString &table2, dbtables.filter(table, Qt::CaseInsensitive)) {
+ if(table2.compare(table.section('.', -1, -1), Qt::CaseInsensitive) == 0) {
+ table=db.driver()->escapeIdentifier(table2, QSqlDriver::TableName);
+ wasDropped = q.exec( "drop table " + table);
+ dbtables.removeAll(table);
+ }
+ }
+ }
+ if ( !wasDropped ) {
+ qWarning() << dbToString(db) << "unable to drop table" << tableName << ':' << q.lastError();
+// qWarning() << "last query:" << q.lastQuery();
+// qWarning() << "dbtables:" << dbtables;
+// qWarning() << "db.tables():" << db.tables();
+ }
}
}
@@ -343,19 +353,32 @@ public:
if ( isMSAccess( db ) ) // Access is sooo stupid.
safeDropTables( db, viewNames );
+ bool wasDropped;
+ QSqlQuery q( db );
QStringList dbtables=db.tables(QSql::Views);
foreach(QString viewName, viewNames)
{
- if ( dbtables.contains( viewName, Qt::CaseInsensitive ) ) {
- QSqlQuery q( "drop view " + viewName, db );
-
- if ( !q.isActive() )
- qWarning() << "unable to drop view" << viewName << ':' << q.lastError().text();
- } else if ( db.driverName().startsWith( "QMYSQL" )
- && dbtables.contains( viewName, Qt::CaseInsensitive ) ) { // MySql is a bit stupid too
- QSqlQuery q( "drop view " + viewName, db );
+ wasDropped = true;
+ QString view=viewName;
+ if ( db.driver()->isIdentifierEscaped(view, QSqlDriver::TableName))
+ view = db.driver()->stripDelimiters(view, QSqlDriver::TableName);
+
+ if ( dbtables.contains( view, Qt::CaseInsensitive ) ) {
+ foreach(const QString &view2, dbtables.filter(view, Qt::CaseInsensitive)) {
+ if(view2.compare(view.section('.', -1, -1), Qt::CaseInsensitive) == 0) {
+ view=db.driver()->escapeIdentifier(view2, QSqlDriver::TableName);
+ wasDropped = q.exec( "drop view " + view);
+ dbtables.removeAll(view);
+ }
+ }
}
+
+ if ( !wasDropped )
+ qWarning() << dbToString(db) << "unable to drop view" << viewName << ':' << q.lastError();
+// << "\nlast query:" << q.lastQuery()
+// << "\ndbtables:" << dbtables
+// << "\ndb.tables(QSql::Views):" << db.tables(QSql::Views);
}
}
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index f6974881fe..23b1eb552e 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -298,6 +298,7 @@ void tst_QSqlDatabase::createTestTables(QSqlDatabase db)
q.exec("set table_type=innodb");
if (tst_Databases::isSqlServer(db)) {
QVERIFY_SQL(q, exec("SET ANSI_DEFAULTS ON"));
+ QVERIFY_SQL(q, exec("SET IMPLICIT_TRANSACTIONS OFF"));
}
// please never ever change this table; otherwise fix all tests ;)
@@ -354,10 +355,9 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
q.exec("drop schema " + qTableName("qtestschema") + " cascade");
if (testWhiteSpaceNames(db.driverName()))
- tableNames << (qTableName("qtest") + " test");
+ tableNames << db.driver()->escapeIdentifier(qTableName("qtest") + " test", QSqlDriver::TableName);
tst_Databases::safeDropTables(db, tableNames);
- tst_Databases::safeDropView(db, qTableName("qtest_view"));
}
void tst_QSqlDatabase::populateTestTables(QSqlDatabase db)