diff options
author | Bill King <bill.king@nokia.com> | 2009-07-29 01:53:50 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-07-29 01:56:10 (GMT) |
commit | 2c9bf5d611cbc293851c80d4df5a46c36eac41f7 (patch) | |
tree | c6c54ef6a912e9602149cbd9113499e90ae0e19e | |
parent | e8b1b11731b6cb52985af35d9aaaa680859f99c2 (diff) | |
download | Qt-2c9bf5d611cbc293851c80d4df5a46c36eac41f7.zip Qt-2c9bf5d611cbc293851c80d4df5a46c36eac41f7.tar.gz Qt-2c9bf5d611cbc293851c80d4df5a46c36eac41f7.tar.bz2 |
Fixes various db2 autotest issues.
-rw-r--r-- | src/qt3support/sql/q3sqlcursor.cpp | 2 | ||||
-rw-r--r-- | src/sql/drivers/db2/qsql_db2.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qsqldatabase/tst_databases.h | 10 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/qt3support/sql/q3sqlcursor.cpp b/src/qt3support/sql/q3sqlcursor.cpp index 6b0c69f..aa6aae2 100644 --- a/src/qt3support/sql/q3sqlcursor.cpp +++ b/src/qt3support/sql/q3sqlcursor.cpp @@ -879,7 +879,7 @@ QString Q3SqlCursor::toString(const QString& prefix, QSqlField* field, const QSt { QString f; if (field && driver()) { - f = (prefix.length() > 0 ? prefix + QLatin1Char('.') : QString()) + field->name(); + f = (prefix.length() > 0 ? prefix + QLatin1Char('.') : QString()) + driver()->escapeIdentifier(field->name(), QSqlDriver::FieldName); f += QLatin1Char(' ') + fieldSep + QLatin1Char(' '); if (field->isNull()) { f += QLatin1String("NULL"); diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/sql/drivers/db2/qsql_db2.cpp index 474c53d..a32b3aa 100644 --- a/src/sql/drivers/db2/qsql_db2.cpp +++ b/src/sql/drivers/db2/qsql_db2.cpp @@ -868,11 +868,13 @@ bool QDB2Result::fetch(int i) SQL_FETCH_ABSOLUTE, actualIdx); } - if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) { + if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r != SQL_NO_DATA) { setLastError(qMakeError(QCoreApplication::translate("QDB2Result", "Unable to fetch record %1").arg(i), QSqlError::StatementError, d)); return false; } + else if (r == SQL_NO_DATA) + return false; setAt(i); return true; } diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h index 9c8c313..8253541 100644 --- a/tests/auto/qsqldatabase/tst_databases.h +++ b/tests/auto/qsqldatabase/tst_databases.h @@ -335,7 +335,7 @@ public: 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); + dbtables.removeAll(table2); } } } @@ -430,8 +430,8 @@ public: return "IDENTITY"; /* if ( db.driverName().startsWith( "QPSQL" ) ) return "SERIAL";*/ - if ( db.driverName().startsWith( "QDB2" ) ) - return "GENERATED BY DEFAULT AS IDENTITY"; +// if ( db.driverName().startsWith( "QDB2" ) ) +// return "GENERATED BY DEFAULT AS IDENTITY"; return QString(); } @@ -483,6 +483,10 @@ public: { return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL") ); } + static bool isDB2( QSqlDatabase db ) + { + return db.driverName().startsWith("QDB2") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("db2") ); + } // -1 on fail, else Oracle version static int getOraVersion( QSqlDatabase db ) |