From f84b00c6d26eb7a3a6802210d2a8b12ddbf815aa Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Tue, 16 Sep 2014 10:03:14 -0400 Subject: [PATCH] Expose QSqlDriverPrivate dbmsType in public QSqlDriver api dbmsType was previously kept as a private variable in QSqlDriverPrivate, however it's particularly useful for QODBC users. [ChangeLog][QtSql][QSqlDriver] Add support for determining DBMS type from SQL driver. Change-Id: If1c221520da9ac4ccef85a02db078679d76eac92 Reviewed-by: Mark Brand --- src/sql/drivers/db2/qsql_db2.cpp | 2 +- src/sql/drivers/ibase/qsql_ibase.cpp | 2 +- src/sql/drivers/mysql/qsql_mysql.cpp | 2 +- src/sql/drivers/oci/qsql_oci.cpp | 2 +- src/sql/drivers/odbc/qsql_odbc.cpp | 30 ++-- src/sql/drivers/psql/qsql_psql.cpp | 2 +- src/sql/drivers/sqlite/qsql_sqlite.cpp | 2 +- src/sql/drivers/sqlite2/qsql_sqlite2.cpp | 2 +- src/sql/drivers/tds/qsql_tds.cpp | 2 +- src/sql/kernel/qsqldriver.cpp | 26 +++ src/sql/kernel/qsqldriver.h | 14 ++ src/sql/kernel/qsqldriver_p.h | 6 +- src/sql/kernel/qsqlresult.cpp | 4 +- .../sql/kernel/qsqldatabase/tst_databases.h | 42 ++--- .../kernel/qsqldatabase/tst_qsqldatabase.cpp | 106 +++++------ .../sql/kernel/qsqldriver/tst_qsqldriver.cpp | 44 ++--- .../sql/kernel/qsqlquery/tst_qsqlquery.cpp | 168 +++++++++--------- .../sql/kernel/qsqlresult/testsqldriver.h | 5 - .../sql/kernel/qsqlresult/tst_qsqlresult.cpp | 8 +- .../qsqlquerymodel/tst_qsqlquerymodel.cpp | 16 +- .../tst_qsqlrelationaltablemodel.cpp | 88 ++++----- .../qsqltablemodel/tst_qsqltablemodel.cpp | 12 +- .../benchmarks/sql/kernel/qsqlquery/main.cpp | 28 +-- 23 files changed, 323 insertions(+), 290 deletions(-) diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/sql/drivers/db2/qsql_db2.cpp index a7508963f9..09ac5bda46 100644 --- a/src/sql/drivers/db2/qsql_db2.cpp +++ b/src/sql/drivers/db2/qsql_db2.cpp @@ -66,7 +66,7 @@ static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL class QDB2DriverPrivate : public QSqlDriverPrivate { public: - QDB2DriverPrivate() : QSqlDriverPrivate(), hEnv(0), hDbc(0) { dbmsType = DB2; } + QDB2DriverPrivate() : QSqlDriverPrivate(), hEnv(0), hDbc(0) { dbmsType = QSqlDriver::DB2; } SQLHANDLE hEnv; SQLHANDLE hDbc; QString user; diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index 4ca1edbde0..bb3ffe619e 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -306,7 +306,7 @@ class QIBaseDriverPrivate : public QSqlDriverPrivate { Q_DECLARE_PUBLIC(QIBaseDriver) public: - QIBaseDriverPrivate() : QSqlDriverPrivate(), ibase(0), trans(0), tc(0) { dbmsType = Interbase; } + QIBaseDriverPrivate() : QSqlDriverPrivate(), ibase(0), trans(0), tc(0) { dbmsType = QSqlDriver::Interbase; } bool isError(const char *msg, QSqlError::ErrorType typ = QSqlError::UnknownError) { diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index b4dd6773e0..db54ce84da 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -78,7 +78,7 @@ public: #else tc(0), #endif - preparedQuerysEnabled(false) { dbmsType = MySqlServer; } + preparedQuerysEnabled(false) { dbmsType = QSqlDriver::MySqlServer; } MYSQL *mysql; QTextCodec *tc; diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index cf5ea7aa90..284fee8ccb 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -508,7 +508,7 @@ QOCIDriverPrivate::QOCIDriverPrivate() : QSqlDriverPrivate(), env(0), svc(0), srvhp(0), authp(0), err(0), transaction(false), serverVersion(-1), prefetchRows(-1), prefetchMem(QOCI_PREFETCH_MEM) { - dbmsType = Oracle; + dbmsType = QSqlDriver::Oracle; } void QOCIDriverPrivate::allocErrorHandle() diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 8e7f2f5025..f95fb8868e 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -1660,14 +1660,14 @@ QVariant QODBCResult::lastInsertId() const QString sql; switch (d->driverPrivate->dbmsType) { - case QODBCDriverPrivate::MSSqlServer: - case QODBCDriverPrivate::Sybase: + case QSqlDriver::MSSqlServer: + case QSqlDriver::Sybase: sql = QLatin1String("SELECT @@IDENTITY;"); break; - case QODBCDriverPrivate::MySqlServer: + case QSqlDriver::MySqlServer: sql = QLatin1String("SELECT LAST_INSERT_ID();"); break; - case QODBCDriverPrivate::PostgreSQL: + case QSqlDriver::PostgreSQL: sql = QLatin1String("SELECT lastval();"); break; default: @@ -1807,14 +1807,14 @@ bool QODBCDriver::hasFeature(DriverFeature f) const case CancelQuery: return false; case LastInsertId: - return (d->dbmsType == QODBCDriverPrivate::MSSqlServer) - || (d->dbmsType == QODBCDriverPrivate::Sybase) - || (d->dbmsType == QODBCDriverPrivate::MySqlServer) - || (d->dbmsType == QODBCDriverPrivate::PostgreSQL); + return (d->dbmsType == MSSqlServer) + || (d->dbmsType == Sybase) + || (d->dbmsType == MySqlServer) + || (d->dbmsType == PostgreSQL); case MultipleResultSets: return d->hasMultiResultSets; case BLOB: { - if (d->dbmsType == QODBCDriverPrivate::MySqlServer) + if (d->dbmsType == MySqlServer) return true; else return false; @@ -1911,7 +1911,7 @@ bool QODBCDriver::open(const QString & db, d->checkDateTimePrecision(); setOpen(true); setOpenError(false); - if (d->dbmsType == QODBCDriverPrivate::MSSqlServer) { + if (d->dbmsType == MSSqlServer) { QSqlQuery i(createResult()); i.exec(QLatin1String("SET QUOTED_IDENTIFIER ON")); } @@ -2097,15 +2097,15 @@ void QODBCDriverPrivate::checkDBMS() serverType = QString::fromUtf8((const char *)serverString.constData(), t); #endif if (serverType.contains(QLatin1String("PostgreSQL"), Qt::CaseInsensitive)) - dbmsType = PostgreSQL; + dbmsType = QSqlDriver::PostgreSQL; else if (serverType.contains(QLatin1String("Oracle"), Qt::CaseInsensitive)) - dbmsType = Oracle; + dbmsType = QSqlDriver::Oracle; else if (serverType.contains(QLatin1String("MySql"), Qt::CaseInsensitive)) - dbmsType = MySqlServer; + dbmsType = QSqlDriver::MySqlServer; else if (serverType.contains(QLatin1String("Microsoft SQL Server"), Qt::CaseInsensitive)) - dbmsType = MSSqlServer; + dbmsType = QSqlDriver::MSSqlServer; else if (serverType.contains(QLatin1String("Sybase"), Qt::CaseInsensitive)) - dbmsType = Sybase; + dbmsType = QSqlDriver::Sybase; } r = SQLGetInfo(hDbc, SQL_DRIVER_NAME, diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index aa09191c71..e76dcc26a0 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -130,7 +130,7 @@ public: sn(0), pendingNotifyCheck(false), hasBackslashEscape(false) - { dbmsType = PostgreSQL; } + { dbmsType = QSqlDriver::PostgreSQL; } PGconn *connection; bool isUtf8; diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 33f504c49f..cbde2bfa9c 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -131,7 +131,7 @@ private: class QSQLiteDriverPrivate : public QSqlDriverPrivate { public: - inline QSQLiteDriverPrivate() : QSqlDriverPrivate(), access(0) { dbmsType = SQLite; } + inline QSQLiteDriverPrivate() : QSqlDriverPrivate(), access(0) { dbmsType = QSqlDriver::SQLite; } sqlite3 *access; QList results; }; diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp index 299810969a..760ece915f 100644 --- a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp +++ b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp @@ -86,7 +86,7 @@ public: QSQLite2DriverPrivate::QSQLite2DriverPrivate() : QSqlDriverPrivate(), access(0) { utf8 = (qstrcmp(sqlite_encoding, "UTF-8") == 0); - dbmsType = SQLite; + dbmsType = QSqlDriver::SQLite; } class QSQLite2ResultPrivate; diff --git a/src/sql/drivers/tds/qsql_tds.cpp b/src/sql/drivers/tds/qsql_tds.cpp index 933228f88e..5449930ae3 100644 --- a/src/sql/drivers/tds/qsql_tds.cpp +++ b/src/sql/drivers/tds/qsql_tds.cpp @@ -132,7 +132,7 @@ QSqlError qMakeError(const QString& err, QSqlError::ErrorType type, int errNo = class QTDSDriverPrivate : public QSqlDriverPrivate { public: - QTDSDriverPrivate() : QSqlDriverPrivate(), login(0), initialized(false) { dbmsType = Sybase; } + QTDSDriverPrivate() : QSqlDriverPrivate(), login(0), initialized(false) { dbmsType = QSqlDriver::Sybase; } LOGINREC* login; // login information QString hostName; QString db; diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index fdeb10e915..736fe310e3 100644 --- a/src/sql/kernel/qsqldriver.cpp +++ b/src/sql/kernel/qsqldriver.cpp @@ -236,6 +236,22 @@ bool QSqlDriver::isOpenError() const \value OtherSource The notification source is another connection */ +/*! + \enum QSqlDriver::DBMSType + + This enum contains DBMS types. + + \value UnknownDBMS + \value MSSqlServer + \value MySqlServer + \value PostgreSQL + \value Oracle + \value Sybase + \value SQLite + \value Interbase + \value DB2 +*/ + /*! \fn bool QSqlDriver::hasFeature(DriverFeature feature) const @@ -766,6 +782,16 @@ QSql::NumericalPrecisionPolicy QSqlDriver::numericalPrecisionPolicy() const return d_func()->precisionPolicy; } +/*! + \since 5.4 + + Returns the current DBMS type for the database connection. +*/ +QSqlDriver::DBMSType QSqlDriver::dbmsType() const +{ + return d_func()->dbmsType; +} + /*! \since 5.0 \internal diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h index 659279a3b3..767c1ac74d 100644 --- a/src/sql/kernel/qsqldriver.h +++ b/src/sql/kernel/qsqldriver.h @@ -71,6 +71,18 @@ public: enum NotificationSource { UnknownSource, SelfSource, OtherSource }; + enum DBMSType { + UnknownDBMS, + MSSqlServer, + MySqlServer, + PostgreSQL, + Oracle, + Sybase, + SQLite, + Interbase, + DB2 + }; + explicit QSqlDriver(QObject *parent=0); ~QSqlDriver(); virtual bool isOpen() const; @@ -111,6 +123,8 @@ public: void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy); QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const; + DBMSType dbmsType() const; + public Q_SLOTS: virtual bool cancelQuery(); diff --git a/src/sql/kernel/qsqldriver_p.h b/src/sql/kernel/qsqldriver_p.h index bb44a831a3..427e3984fa 100644 --- a/src/sql/kernel/qsqldriver_p.h +++ b/src/sql/kernel/qsqldriver_p.h @@ -56,21 +56,19 @@ class QSqlDriverPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QSqlDriver) public: - enum DBMSType {UnknownDB, MSSqlServer, MySqlServer, PostgreSQL, Oracle, Sybase, SQLite, Interbase, DB2}; - QSqlDriverPrivate() : QObjectPrivate(), isOpen(false), isOpenError(false), precisionPolicy(QSql::LowPrecisionDouble), - dbmsType(UnknownDB) + dbmsType(QSqlDriver::UnknownDBMS) { } uint isOpen; uint isOpenError; QSqlError error; QSql::NumericalPrecisionPolicy precisionPolicy; - DBMSType dbmsType; + QSqlDriver::DBMSType dbmsType; }; QT_END_NAMESPACE diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index 074e630394..4cd4e6fec4 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -87,7 +87,7 @@ QString QSqlResultPrivate::positionalToNamedBinding(const QString &query) const result.reserve(n * 5 / 4); QChar closingQuote; int count = 0; - bool ignoreBraces = (sqldriver->d_func()->dbmsType == QSqlDriverPrivate::PostgreSQL); + bool ignoreBraces = (sqldriver->d_func()->dbmsType == QSqlDriver::PostgreSQL); for (int i = 0; i < n; ++i) { QChar ch = query.at(i); @@ -128,7 +128,7 @@ QString QSqlResultPrivate::namedToPositionalBinding(const QString &query) QChar closingQuote; int count = 0; int i = 0; - bool ignoreBraces = (sqldriver->d_func()->dbmsType == QSqlDriverPrivate::PostgreSQL); + bool ignoreBraces = (sqldriver->d_func()->dbmsType == QSqlDriver::PostgreSQL); while (i < n) { QChar ch = query.at(i); diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h index 23596eae02..d5ccc194bb 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h +++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h @@ -99,7 +99,7 @@ inline QString fixupTableName(const QString &tableName, QSqlDatabase db) QString tbName = tableName; // On Oracle we are limited to 30 character tablenames QSqlDriverPrivate *d = static_cast(QObjectPrivate::get(db.driver())); - if (d && d->dbmsType == QSqlDriverPrivate::Oracle) + if (d && d->dbmsType == QSqlDriver::Oracle) tbName.truncate(30); return tbName; } @@ -385,7 +385,7 @@ public: bool wasDropped; QSqlQuery q( db ); QStringList dbtables=db.tables(); - QSqlDriverPrivate::DBMSType dbType = getDatabaseType(db); + QSqlDriver::DBMSType dbType = getDatabaseType(db); foreach(const QString &tableName, tableNames) { wasDropped = true; @@ -397,7 +397,7 @@ public: 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); - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) wasDropped = q.exec( "drop table " + table + " cascade"); else wasDropped = q.exec( "drop table " + table); @@ -462,26 +462,26 @@ public: // blobSize is only used if the db doesn't have a generic blob type static QString blobTypeName( QSqlDatabase db, int blobSize = 10000 ) { - const QSqlDriverPrivate::DBMSType dbType = getDatabaseType(db); - if (dbType == QSqlDriverPrivate::MySqlServer) + const QSqlDriver::DBMSType dbType = getDatabaseType(db); + if (dbType == QSqlDriver::MySqlServer) return "longblob"; - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) return "bytea"; - if (dbType == QSqlDriverPrivate::Sybase - || dbType == QSqlDriverPrivate::MSSqlServer + if (dbType == QSqlDriver::Sybase + || dbType == QSqlDriver::MSSqlServer || isMSAccess( db ) ) return "image"; - if (dbType == QSqlDriverPrivate::DB2) + if (dbType == QSqlDriver::DB2) return QString( "blob(%1)" ).arg( blobSize ); - if (dbType == QSqlDriverPrivate::Interbase) + if (dbType == QSqlDriver::Interbase) return QString( "blob sub_type 0 segment size 4096" ); - if (dbType == QSqlDriverPrivate::Oracle - || dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::Oracle + || dbType == QSqlDriver::SQLite) return "blob"; qDebug() << "tst_Databases::blobTypeName: Don't know the blob type for" << dbToString( db ); @@ -491,24 +491,24 @@ public: static QString dateTimeTypeName(QSqlDatabase db) { - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::PostgreSQL) + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::PostgreSQL) return QLatin1String("timestamp"); - if (dbType == QSqlDriverPrivate::Oracle && getOraVersion(db) >= 9) + if (dbType == QSqlDriver::Oracle && getOraVersion(db) >= 9) return QLatin1String("timestamp(0)"); return QLatin1String("datetime"); } static QString autoFieldName( QSqlDatabase db ) { - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::MySqlServer) + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::MySqlServer) return "AUTO_INCREMENT"; - if (dbType == QSqlDriverPrivate::Sybase || dbType == QSqlDriverPrivate::MSSqlServer) + if (dbType == QSqlDriver::Sybase || dbType == QSqlDriver::MSSqlServer) return "IDENTITY"; -/* if (dbType == QSqlDriverPrivate::PostgreSQL) +/* if (dbType == QSqlDriver::PostgreSQL) return "SERIAL";*/ -// if (dbType == QSqlDriverPrivate::DB2) +// if (dbType == QSqlDriver::DB2) // return "GENERATED BY DEFAULT AS IDENTITY"; return QString(); @@ -538,7 +538,7 @@ public: return result.toLocal8Bit(); } - static QSqlDriverPrivate::DBMSType getDatabaseType(QSqlDatabase db) + static QSqlDriver::DBMSType getDatabaseType(QSqlDatabase db) { QSqlDriverPrivate *d = static_cast(QObjectPrivate::get(db.driver())); return d->dbmsType; diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 8d88b9d839..6faf8b7ed5 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -234,7 +234,7 @@ struct FieldDef { // excluding the primary key field static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db) { - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); const QString tableName = qTableName("qtestfields", __FILE__, db); tst_Databases::safeDropTable(db, tableName); QSqlQuery q(db); @@ -243,7 +243,7 @@ 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 (dbType == QSqlDriverPrivate::PostgreSQL) + else if (dbType == QSqlDriver::PostgreSQL) qs.append(" (id serial not null"); else qs.append(QString("(id integer not null %1 primary key").arg(autoName)); @@ -251,7 +251,7 @@ static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db) int i = 0; for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { qs += QString(",\n %1 %2").arg(fieldDefs[ i ].fieldName()).arg(fieldDefs[ i ].typeName); - if ((dbType == QSqlDriverPrivate::Sybase || dbType == QSqlDriverPrivate::MSSqlServer) && fieldDefs[i].nullable) + if ((dbType == QSqlDriver::Sybase || dbType == QSqlDriver::MSSqlServer) && fieldDefs[i].nullable) qs += " null"; } @@ -281,15 +281,15 @@ void tst_QSqlDatabase::createTestTables(QSqlDatabase db) return; const QString tableName = qTableName("qtest", __FILE__, db); QSqlQuery q(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::MySqlServer) { + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::MySqlServer) { // ### stupid workaround until we find a way to hardcode this // in the MySQL server startup script q.exec("set table_type=innodb"); - } else if (dbType == QSqlDriverPrivate::MSSqlServer) { + } else if (dbType == QSqlDriver::MSSqlServer) { QVERIFY_SQL(q, exec("SET ANSI_DEFAULTS ON")); QVERIFY_SQL(q, exec("SET IMPLICIT_TRANSACTIONS OFF")); - } else if (dbType == QSqlDriverPrivate::PostgreSQL) { + } else if (dbType == QSqlDriver::PostgreSQL) { QVERIFY_SQL( q, exec("set client_min_messages='warning'")); } // please never ever change this table; otherwise fix all tests ;) @@ -318,8 +318,8 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) if (!db.isValid()) return; - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::PostgreSQL) { + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::PostgreSQL) { QSqlQuery q(db); QVERIFY_SQL( q, exec("set client_min_messages='warning'")); } @@ -350,7 +350,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) << qTableName("bug_249059", __FILE__, db); QSqlQuery q(0, db); - if (dbType == QSqlDriverPrivate::PostgreSQL) { + if (dbType == QSqlDriver::PostgreSQL) { q.exec("drop schema " + qTableName("qtestschema", __FILE__, db) + " cascade"); q.exec("drop schema " + qTableName("qtestScHeMa", __FILE__, db) + " cascade"); } @@ -360,7 +360,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) tst_Databases::safeDropTables(db, tableNames); - if (dbType == QSqlDriverPrivate::Oracle) { + if (dbType == QSqlDriver::Oracle) { q.exec("drop user "+qTableName("CREATOR", __FILE__, db)+ " cascade"); q.exec("drop user "+qTableName("APPUSER", __FILE__, db) + " cascade"); q.exec("DROP TABLE sys."+qTableName("mypassword", __FILE__, db)); @@ -485,8 +485,8 @@ void tst_QSqlDatabase::open() QVERIFY(!db.isOpenError()); } - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::SQLite && db.databaseName() == ":memory:") { + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::SQLite && db.databaseName() == ":memory:") { // tables in in-memory databases don't survive an open/close createTestTables(db); populateTestTables(db); @@ -498,7 +498,7 @@ void tst_QSqlDatabase::tables() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); const QString qtest(qTableName("qtest", __FILE__, db)), qtest_view(qTableName("qtest_view", __FILE__, db)), temp_tab(qTableName("test_tab", __FILE__, db)); @@ -553,7 +553,7 @@ void tst_QSqlDatabase::tables() QVERIFY(tables.contains(temp_tab, Qt::CaseInsensitive)); QVERIFY(tables.contains(qtest, Qt::CaseInsensitive)); - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) QVERIFY(tables.contains(qtest + " test")); } @@ -562,7 +562,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); if (testWhiteSpaceNames(db.driverName())) { const QString tableName(qTableName("qtest", __FILE__, db) + " test"); @@ -571,7 +571,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers() QSqlRecord rec = db.record(db.driver()->escapeIdentifier(tableName, QSqlDriver::TableName)); QCOMPARE(rec.count(), 1); QCOMPARE(rec.fieldName(0), QString("test test")); - if (dbType == QSqlDriverPrivate::Oracle) + if (dbType == QSqlDriver::Oracle) QCOMPARE(rec.field(0).type(), QVariant::Double); else QCOMPARE(rec.field(0).type(), QVariant::Int); @@ -579,7 +579,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers() QSqlIndex idx = db.primaryIndex(db.driver()->escapeIdentifier(tableName, QSqlDriver::TableName)); QCOMPARE(idx.count(), 1); QCOMPARE(idx.fieldName(0), QString("test test")); - if (dbType == QSqlDriverPrivate::Oracle) + if (dbType == QSqlDriver::Oracle) QCOMPARE(idx.field(0).type(), QVariant::Double); else QCOMPARE(idx.field(0).type(), QVariant::Int); @@ -830,8 +830,8 @@ void tst_QSqlDatabase::recordPSQL() QSqlQuery q(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::PostgreSQL) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); const QString tableName = qTableName("qtestfields", __FILE__, db); q.exec("drop sequence " + tableName + "_t_bigserial_seq"); @@ -1017,8 +1017,8 @@ void tst_QSqlDatabase::recordSQLServer() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType != QSqlDriverPrivate::MSSqlServer) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType != QSqlDriver::MSSqlServer) QSKIP("SQL server specific test"); // ### TODO: Add the rest of the fields @@ -1076,7 +1076,7 @@ void tst_QSqlDatabase::transaction() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); const QString qtest(qTableName("qtest", __FILE__, db)); if (!db.driver()->hasFeature(QSqlDriver::Transactions)) @@ -1107,7 +1107,7 @@ void tst_QSqlDatabase::transaction() QCOMPARE(q.value(0).toInt(), 41); q.clear(); // for SQLite which does not allow any references on rows that shall be rolled back if (!db.rollback()) { - if (dbType == QSqlDriverPrivate::MySqlServer) + if (dbType == QSqlDriver::MySqlServer) QSKIP("MySQL transaction failed: " + tst_Databases::printError(db.lastError())); else QFAIL("Could not rollback transaction: " + tst_Databases::printError(db.lastError())); @@ -1124,24 +1124,24 @@ void tst_QSqlDatabase::bigIntField() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); const QString qtest_bigint(qTableName("qtest_bigint", __FILE__, db)); QSqlQuery q(db); q.setForwardOnly(true); - if (dbType == QSqlDriverPrivate::Oracle) + if (dbType == QSqlDriver::Oracle) q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt64); - if (dbType == QSqlDriverPrivate::MySqlServer) { + if (dbType == QSqlDriver::MySqlServer) { QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit bigint, t_u64bit bigint unsigned)")); - } else if (dbType == QSqlDriverPrivate::PostgreSQL - || dbType == QSqlDriverPrivate::DB2 - || dbType == QSqlDriverPrivate::MSSqlServer) { + } else if (dbType == QSqlDriver::PostgreSQL + || dbType == QSqlDriver::DB2 + || dbType == QSqlDriver::MSSqlServer) { QVERIFY_SQL(q, exec("create table " + qtest_bigint + "(id int, t_s64bit bigint, t_u64bit bigint)")); - } else if (dbType == QSqlDriverPrivate::Oracle) { + } else if (dbType == QSqlDriver::Oracle) { QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int, t_u64bit int)")); - //} else if (dbType == QSqlDriverPrivate::Interbase) { + //} else if (dbType == QSqlDriver::Interbase) { // QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int64, t_u64bit int64)")); } else { QSKIP("no 64 bit integer support"); @@ -1150,7 +1150,7 @@ void tst_QSqlDatabase::bigIntField() qlonglong ll = Q_INT64_C(9223372036854775807); qulonglong ull = Q_UINT64_C(18446744073709551615); - if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::Oracle) { + if (dbType == QSqlDriver::MySqlServer || dbType == QSqlDriver::Oracle) { q.bindValue(0, 0); q.bindValue(1, ll); q.bindValue(2, ull); @@ -1174,12 +1174,12 @@ void tst_QSqlDatabase::bigIntField() QVERIFY(q.next()); QCOMPARE(q.value(1).toDouble(), (double)ll); QCOMPARE(q.value(1).toLongLong(), ll); - if (dbType == QSqlDriverPrivate::Oracle) + if (dbType == QSqlDriver::Oracle) QEXPECT_FAIL("", "Oracle driver lacks support for unsigned int64 types", Continue); QCOMPARE(q.value(2).toULongLong(), ull); QVERIFY(q.next()); QCOMPARE(q.value(1).toLongLong(), -ll); - if (dbType == QSqlDriverPrivate::Oracle) + if (dbType == QSqlDriver::Oracle) QEXPECT_FAIL("", "Oracle driver lacks support for unsigned int64 types", Continue); QCOMPARE(q.value(2).toULongLong(), ull); } @@ -1189,11 +1189,11 @@ void tst_QSqlDatabase::caseSensivity() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); bool cs = false; - if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::Sybase - || dbType == QSqlDriverPrivate::MSSqlServer || db.driverName().startsWith("QODBC")) + if (dbType == QSqlDriver::MySqlServer || dbType == QSqlDriver::SQLite || dbType == QSqlDriver::Sybase + || dbType == QSqlDriver::MSSqlServer || db.driverName().startsWith("QODBC")) cs = true; QSqlRecord rec = db.record(qTableName("qtest", __FILE__, db)); @@ -1222,8 +1222,8 @@ void tst_QSqlDatabase::noEscapedFieldNamesInRecord() CHECK_DATABASE(db); QString fieldname("t_varchar"); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::DB2) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::Oracle || dbType == QSqlDriver::Interbase || dbType == QSqlDriver::DB2) fieldname = fieldname.toUpper(); QSqlQuery q(db); @@ -1405,8 +1405,8 @@ void tst_QSqlDatabase::precisionPolicy() QString query = QString("SELECT num FROM %1 WHERE id = 1").arg(tableName); QVERIFY_SQL(q, exec(query)); QVERIFY_SQL(q, next()); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::SQLite) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::SQLite) QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue); QCOMPARE(q.value(0).type(), QVariant::String); @@ -1421,7 +1421,7 @@ void tst_QSqlDatabase::precisionPolicy() q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt32); QVERIFY_SQL(q, exec(query)); QVERIFY_SQL(q, next()); - if (dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::SQLite) QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue); QCOMPARE(q.value(0).type(), QVariant::Int); QCOMPARE(q.value(0).toInt(), 123); @@ -1429,7 +1429,7 @@ void tst_QSqlDatabase::precisionPolicy() q.setNumericalPrecisionPolicy(QSql::LowPrecisionDouble); QVERIFY_SQL(q, exec(query)); QVERIFY_SQL(q, next()); - if (dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::SQLite) QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue); QCOMPARE(q.value(0).type(), QVariant::Double); QCOMPARE(q.value(0).toDouble(), (double)123); @@ -1437,7 +1437,7 @@ void tst_QSqlDatabase::precisionPolicy() query = QString("SELECT num FROM %1 WHERE id = 2").arg(tableName); QVERIFY_SQL(q, exec(query)); QVERIFY_SQL(q, next()); - if (dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::SQLite) QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue); QCOMPARE(q.value(0).type(), QVariant::Double); QCOMPARE(q.value(0).toDouble(), QString("1850000000000.0001").toDouble()); @@ -1446,7 +1446,7 @@ void tst_QSqlDatabase::precisionPolicy() q.setNumericalPrecisionPolicy(QSql::HighPrecision); QVERIFY_SQL(q, exec(query)); QVERIFY_SQL(q, next()); - if (dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::SQLite) QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue); QCOMPARE(q.value(0).type(), QVariant::String); @@ -1473,7 +1473,7 @@ void tst_QSqlDatabase::mysqlOdbc_unsignedIntegers() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - if (tst_Databases::getDatabaseType(db) != QSqlDriverPrivate::MySqlServer || !db.driverName().startsWith("QODBC")) + if (tst_Databases::getDatabaseType(db) != QSqlDriver::MySqlServer || !db.driverName().startsWith("QODBC")) QSKIP("MySQL through ODBC-driver specific test"); QSqlQuery q(db); @@ -1742,8 +1742,8 @@ void tst_QSqlDatabase::odbc_bindBoolean() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::MySqlServer) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::MySqlServer) QSKIP("MySql has inconsistent behaviour of bit field type across versions."); QSqlQuery q(db); @@ -1777,8 +1777,8 @@ void tst_QSqlDatabase::odbc_testqGetString() const QString testqGetString(qTableName("testqGetString", __FILE__, db)); QSqlQuery q(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::MSSqlServer) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::MSSqlServer) QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue varchar(MAX))")); else if(tst_Databases::isMSAccess(db)) QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue memo)")); @@ -1957,8 +1957,8 @@ void tst_QSqlDatabase::odbc_uniqueidentifier() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType != QSqlDriverPrivate::MSSqlServer) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType != QSqlDriver::MSSqlServer) QSKIP("SQL Server (ODBC) specific test"); const QString tableName(qTableName("qtest_sqlguid", __FILE__, db)); diff --git a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp index b5c45cd987..fa0f7eaf34 100644 --- a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp +++ b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp @@ -71,8 +71,8 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db) QSqlQuery q(db); const QString relTEST1(qTableName("relTEST1", __FILE__, db)); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::PostgreSQL) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); tst_Databases::safeDropTable( db, relTEST1 ); @@ -122,24 +122,24 @@ void tst_QSqlDriver::record() QSqlRecord rec = db.driver()->record(tablename); QCOMPARE(rec.count(), 4); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); // QTBUG-1363: QSqlField::length() always return -1 when using QODBC3 driver and QSqlDatabase::record() - if (dbType == QSqlDriverPrivate::MSSqlServer && db.driverName().startsWith("QODBC")) + if (dbType == QSqlDriver::MSSqlServer && db.driverName().startsWith("QODBC")) QCOMPARE(rec.field(1).length(), 20); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) for(int i = 0; i < fields.count(); ++i) fields[i] = fields[i].toUpper(); for (int i = 0; i < fields.count(); ++i) QCOMPARE(rec.fieldName(i), fields[i]); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) tablename = tablename.toUpper(); - else if (dbType == QSqlDriverPrivate::PostgreSQL) + else if (dbType == QSqlDriver::PostgreSQL) tablename = tablename.toLower(); - if (dbType != QSqlDriverPrivate::PostgreSQL && !db.driverName().startsWith("QODBC")) { + if (dbType != QSqlDriver::PostgreSQL && !db.driverName().startsWith("QODBC")) { //check we can get records using a properly quoted table name rec = db.driver()->record(db.driver()->escapeIdentifier(tablename,QSqlDriver::TableName)); QCOMPARE(rec.count(), 4); @@ -148,15 +148,15 @@ void tst_QSqlDriver::record() for (int i = 0; i < fields.count(); ++i) QCOMPARE(rec.fieldName(i), fields[i]); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) tablename = tablename.toLower(); - else if (dbType == QSqlDriverPrivate::PostgreSQL) + else if (dbType == QSqlDriver::PostgreSQL) tablename = tablename.toUpper(); //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 (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::Sybase - || dbType == QSqlDriverPrivate::MSSqlServer || tst_Databases::isMSAccess(db)) + if (dbType == QSqlDriver::MySqlServer || dbType == QSqlDriver::SQLite || dbType == QSqlDriver::Sybase + || dbType == QSqlDriver::MSSqlServer || tst_Databases::isMSAccess(db)) QCOMPARE(rec.count(), 4); //mysql, sqlite and tds will match else QCOMPARE(rec.count(), 0); @@ -174,24 +174,24 @@ void tst_QSqlDriver::primaryIndex() QSqlIndex index = db.driver()->primaryIndex(tablename); QCOMPARE(index.count(), 1); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) QCOMPARE(index.fieldName(0), QString::fromLatin1("ID")); else QCOMPARE(index.fieldName(0), QString::fromLatin1("id")); //check that we can get the primary index using a quoted tablename - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) tablename = tablename.toUpper(); - else if (dbType == QSqlDriverPrivate::PostgreSQL) + else if (dbType == QSqlDriver::PostgreSQL) tablename = tablename.toLower(); - if (dbType != QSqlDriverPrivate::PostgreSQL && !db.driverName().startsWith("QODBC")) { + if (dbType != QSqlDriver::PostgreSQL && !db.driverName().startsWith("QODBC")) { index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName)); QCOMPARE(index.count(), 1); } - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) QCOMPARE(index.fieldName(0), QString::fromLatin1("ID")); else QCOMPARE(index.fieldName(0), QString::fromLatin1("id")); @@ -199,14 +199,14 @@ void tst_QSqlDriver::primaryIndex() //check that we can not get the primary index using a quoted but incorrect table name casing - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) tablename = tablename.toLower(); - else if (dbType == QSqlDriverPrivate::PostgreSQL) + else if (dbType == QSqlDriver::PostgreSQL) tablename = tablename.toUpper(); index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName)); - if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::Sybase - || dbType == QSqlDriverPrivate::MSSqlServer || tst_Databases::isMSAccess(db)) + if (dbType == QSqlDriver::MySqlServer || dbType == QSqlDriver::SQLite || dbType == QSqlDriver::Sybase + || dbType == QSqlDriver::MSSqlServer || 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/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index e95980d52a..b4863d4a82 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -283,7 +283,7 @@ void tst_QSqlQuery::cleanup() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); if ( QTest::currentTestFunction() == QLatin1String( "numRowsAffected" ) || QTest::currentTestFunction() == QLatin1String( "transactions" ) || QTest::currentTestFunction() == QLatin1String( "size" ) @@ -292,7 +292,7 @@ void tst_QSqlQuery::cleanup() populateTestTables( db ); } - if (QTest::currentTestFailed() && (dbType == QSqlDriverPrivate::Oracle || db.driverName().startsWith("QODBC"))) { + if (QTest::currentTestFailed() && (dbType == QSqlDriver::Oracle || db.driverName().startsWith("QODBC"))) { //since Oracle ODBC totally craps out on error, we init again db.close(); db.open(); @@ -311,7 +311,7 @@ void tst_QSqlQuery::generic_data(const QString& engine) void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) { - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QStringList tablenames; // drop all the table in case a testcase failed tablenames << qtest @@ -348,24 +348,24 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) << qTableName("qtest_oraOCINumber", __FILE__, db) << qTableName("bug2192", __FILE__, db); - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) tablenames << qTableName("task_233829", __FILE__, db); - if (dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::SQLite) tablenames << qTableName("record_sqlite", __FILE__, db); - if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Oracle) + if (dbType == QSqlDriver::MSSqlServer || dbType == QSqlDriver::Oracle) tablenames << qTableName("qtest_longstr", __FILE__, db); - if (dbType == QSqlDriverPrivate::MSSqlServer) + if (dbType == QSqlDriver::MSSqlServer) db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__, db)); - if (dbType == QSqlDriverPrivate::MySqlServer) + if (dbType == QSqlDriver::MySqlServer) db.exec("DROP PROCEDURE IF EXISTS "+ qTableName("bug6852_proc", __FILE__, db)); tst_Databases::safeDropTables( db, tablenames ); - if (dbType == QSqlDriverPrivate::Oracle) { + if (dbType == QSqlDriver::Oracle) { QSqlQuery q( db ); q.exec("DROP PACKAGE " + qTableName("pkg", __FILE__, db)); } @@ -374,20 +374,20 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) void tst_QSqlQuery::createTestTables( QSqlDatabase db ) { QSqlQuery q( db ); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::MySqlServer) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::MySqlServer) // ### stupid workaround until we find a way to hardcode this // in the MySQL server startup script q.exec( "set table_type=innodb" ); - else if (dbType == QSqlDriverPrivate::PostgreSQL) + else if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec( "create table " + 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 " + qtest + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) ); - if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Sybase) + if (dbType == QSqlDriver::MSSqlServer || dbType == QSqlDriver::Sybase) QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int null, t_varchar varchar(20) null)")); else QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int, t_varchar varchar(20))")); @@ -426,8 +426,8 @@ void tst_QSqlQuery::char1Select() QVERIFY_SQL(q, exec("insert into " + tbl + " values ('a')")); QVERIFY_SQL(q, exec("select * from " + tbl)); QVERIFY( q.next() ); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::Interbase) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::Interbase) QCOMPARE( q.value( 0 ).toString().left( 1 ), QString( "a" ) ); else QCOMPARE( q.value( 0 ).toString(), QString( "a" ) ); @@ -441,8 +441,8 @@ void tst_QSqlQuery::char1SelectUnicode() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::DB2) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::DB2) QSKIP("Needs someone with more Unicode knowledge than I have to fix"); if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) { @@ -455,14 +455,14 @@ void tst_QSqlQuery::char1SelectUnicode() QString createQuery; const QString char1SelectUnicode(qTableName("char1SU", __FILE__, db)); - if (dbType == QSqlDriverPrivate::MSSqlServer) + if (dbType == QSqlDriver::MSSqlServer) createQuery = "create table " + char1SelectUnicode + "(id nchar(1))"; - else if (dbType == QSqlDriverPrivate::DB2 || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::PostgreSQL) + else if (dbType == QSqlDriver::DB2 || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::PostgreSQL) createQuery = "create table " + char1SelectUnicode + " (id char(3))"; - else if (dbType == QSqlDriverPrivate::Interbase) + else if (dbType == QSqlDriver::Interbase) createQuery = "create table " + char1SelectUnicode + " (id char(1) character set unicode_fss)"; - else if (dbType == QSqlDriverPrivate::MySqlServer) + else if (dbType == QSqlDriver::MySqlServer) createQuery = "create table " + char1SelectUnicode + " (id char(1)) " "default character set 'utf8'"; else @@ -588,11 +588,11 @@ void tst_QSqlQuery::bindBool() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); QSqlQuery q(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); const QString tableName(qTableName("bindBool", __FILE__, db)); q.exec("DROP TABLE " + tableName); - QString colType = dbType == QSqlDriverPrivate::PostgreSQL ? QLatin1String("BOOLEAN") : QLatin1String("INT"); + QString colType = dbType == QSqlDriver::PostgreSQL ? 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) { @@ -845,14 +845,14 @@ void tst_QSqlQuery::outValues() QSqlQuery q( db ); q.setForwardOnly( true ); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::Oracle) { + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::Oracle) { QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x out int) is\n" "begin\n" " x := 42;\n" "end;\n" ) ); QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); - } else if (dbType == QSqlDriverPrivate::DB2) { + } else if (dbType == QSqlDriver::DB2) { q.exec( "drop procedure " + tst_outValues ); //non-fatal QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + tst_outValues + " (OUT x int)\n" "LANGUAGE SQL\n" @@ -860,7 +860,7 @@ void tst_QSqlQuery::outValues() " SET x = 42;\n" "END P1" ) ); QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); - } else if (dbType == QSqlDriverPrivate::MSSqlServer) { + } else if (dbType == QSqlDriver::MSSqlServer) { q.exec( "drop procedure " + tst_outValues ); //non-fatal QVERIFY_SQL( q, exec( "create procedure " + tst_outValues + " (@x int out) as\n" "begin\n" @@ -934,7 +934,7 @@ void tst_QSqlQuery::value() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q( db ); QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qtest + " order by id" ) ); int i = 1; @@ -943,14 +943,14 @@ void tst_QSqlQuery::value() QCOMPARE( q.value( 0 ).toInt(), i ); QCOMPARE( q.value( "id" ).toInt(), i ); - if (dbType == QSqlDriverPrivate::Interbase) + if (dbType == QSqlDriver::Interbase) QVERIFY( q.value( 1 ).toString().startsWith( "VarChar" + QString::number( i ) ) ); else if ( q.value( 1 ).toString().right( 1 ) == " " ) QCOMPARE( q.value( 1 ).toString(), ( "VarChar" + QString::number( i ) + " " ) ); else QCOMPARE( q.value( 1 ).toString(), ( "VarChar" + QString::number( i ) ) ); - if (dbType == QSqlDriverPrivate::Interbase) + if (dbType == QSqlDriver::Interbase) QVERIFY( q.value( 2 ).toString().startsWith( "Char" + QString::number( i ) ) ); else if ( q.value( 2 ).toString().right( 1 ) != " " ) QCOMPARE( q.value( 2 ).toString(), ( "Char" + QString::number( i ) ) ); @@ -1520,8 +1520,8 @@ void tst_QSqlQuery::precision() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::Interbase) + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::Interbase) QSKIP("DB unable to store high precision"); const QString qtest_precision(qTableName("qtest_precision", __FILE__, db)); @@ -1551,10 +1551,10 @@ void tst_QSqlQuery::precision() i++; // MySQL and TDS have crappy precisions by default - if (dbType == QSqlDriverPrivate::MySqlServer) { + if (dbType == QSqlDriver::MySqlServer) { if ( i < 17 ) QWARN( "MySQL didn't return the right precision" ); - } else if (dbType == QSqlDriverPrivate::Sybase) { + } else if (dbType == QSqlDriver::Sybase) { if ( i < 18 ) QWARN( "TDS didn't return the right precision" ); } else { @@ -1596,14 +1596,14 @@ void tst_QSqlQuery::transaction() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); if ( !db.driver()->hasFeature( QSqlDriver::Transactions ) ) QSKIP( "DBMS not transaction capable"); // this is the standard SQL QString startTransactionStr( "start transaction" ); - if (dbType == QSqlDriverPrivate::MySqlServer) + if (dbType == QSqlDriver::MySqlServer) startTransactionStr = "begin work"; QSqlQuery q( db ); @@ -1641,7 +1641,7 @@ void tst_QSqlQuery::transaction() QCOMPARE( q.value( 0 ).toInt(), 41 ); if ( !q.exec( "rollback" ) ) { - if (dbType == QSqlDriverPrivate::MySqlServer) { + if (dbType == QSqlDriver::MySqlServer) { qDebug( "MySQL: %s", qPrintable(tst_Databases::printError( q.lastError() ) )); QSKIP( "MySQL transaction failed "); //non-fatal } else @@ -1679,11 +1679,11 @@ void tst_QSqlQuery::joins() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); const QString qtestj1(qTableName("qtestj1", __FILE__, db)), qtestj2(qTableName("qtestj2", __FILE__, db)); - if (dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::Sybase - || dbType == QSqlDriverPrivate::Interbase || db.driverName().startsWith("QODBC")) + if (dbType == QSqlDriver::Oracle || dbType == QSqlDriver::Sybase + || dbType == QSqlDriver::Interbase || db.driverName().startsWith("QODBC")) // Oracle broken beyond recognition - cannot outer join on more than // one table. QSKIP( "DBMS cannot understand standard SQL"); @@ -1763,12 +1763,12 @@ void tst_QSqlQuery::prepare_bind_exec() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); const QString qtest_prepare(qTableName("qtest_prepare", __FILE__, db)); - if (dbType == QSqlDriverPrivate::Interbase && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb")) + if (dbType == QSqlDriver::Interbase && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb")) QSKIP("Can't transliterate extended unicode to ascii"); - if (dbType == QSqlDriverPrivate::DB2) + if (dbType == QSqlDriver::DB2) QSKIP("Needs someone with more Unicode knowledge than I have to fix"); { @@ -1785,13 +1785,13 @@ void tst_QSqlQuery::prepare_bind_exec() useUnicode = false; QString createQuery; - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::PostgreSQL) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Sybase) + if (dbType == QSqlDriver::MSSqlServer || dbType == QSqlDriver::Sybase) createQuery = "create table " + qtest_prepare + " (id int primary key, name nvarchar(200) null, name2 nvarchar(200) null)"; - else if (dbType == QSqlDriverPrivate::MySqlServer && useUnicode) + else if (dbType == QSqlDriver::MySqlServer && useUnicode) createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200) character set utf8, name2 varchar(200) character set utf8)"; else createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200), name2 varchar(200))"; @@ -2059,8 +2059,8 @@ void tst_QSqlQuery::sqlServerLongStrings() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType != QSqlDriverPrivate::MSSqlServer) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType != QSqlDriver::MSSqlServer) QSKIP( "SQL Server specific test"); QSqlQuery q( db ); @@ -2105,7 +2105,7 @@ void tst_QSqlQuery::invalidQuery() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q( db ); QVERIFY( !q.exec() ); @@ -2115,7 +2115,7 @@ void tst_QSqlQuery::invalidQuery() QVERIFY( !q.next() ); QVERIFY( !q.isActive() ); - if (dbType != QSqlDriverPrivate::Oracle && dbType != QSqlDriverPrivate::DB2 && !db.driverName().startsWith("QODBC")) { + if (dbType != QSqlDriver::Oracle && dbType != QSqlDriver::DB2 && !db.driverName().startsWith("QODBC")) { // oracle and db2 just prepares everything without complaining if ( db.driver()->hasFeature( QSqlDriver::PreparedQueries ) ) QVERIFY( !q.prepare( "blahfasel" ) ); @@ -2442,11 +2442,11 @@ void tst_QSqlQuery::createQueryOnClosedDatabase() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); // Only supported by these drivers - if (dbType != QSqlDriverPrivate::PostgreSQL && dbType != QSqlDriverPrivate::Oracle - && dbType != QSqlDriverPrivate::MySqlServer && dbType != QSqlDriverPrivate::DB2) + if (dbType != QSqlDriver::PostgreSQL && dbType != QSqlDriver::Oracle + && dbType != QSqlDriver::MySqlServer && dbType != QSqlDriver::DB2) QSKIP( "Test is specific for PostgreSQL, Oracle, MySql and DB2"); db.close(); @@ -2574,7 +2574,7 @@ void tst_QSqlQuery::nextResult() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); if ( !db.driver()->hasFeature( QSqlDriver::MultipleResultSets ) || !db.driver()->hasFeature( QSqlDriver::BatchOperations ) ) QSKIP( "DBMS does not support multiple result sets or batch operations"); @@ -2635,7 +2635,7 @@ void tst_QSqlQuery::nextResult() QCOMPARE( q.record().field( 1 ).name().toUpper(), QString( "NUM" ) ); - if (dbType == QSqlDriverPrivate::MySqlServer) + if (dbType == QSqlDriver::MySqlServer) QCOMPARE( q.record().field( 1 ).type(), QVariant::String ); else QCOMPARE( q.record().field( 1 ).type(), QVariant::Double ); @@ -2691,13 +2691,13 @@ void tst_QSqlQuery::nextResult() q.exec( QString( "DROP PROCEDURE %1;" ).arg( procName ) ); - if (dbType == QSqlDriverPrivate::MySqlServer) + if (dbType == QSqlDriver::MySqlServer) QVERIFY_SQL( q, exec( QString( "CREATE PROCEDURE %1()" "\nBEGIN" "\nSELECT id, text FROM %2;" "\nSELECT empty, num, text, id FROM %3;" "\nEND" ).arg( procName ).arg( tableName ).arg( tableName ) ) ); - else if (dbType == QSqlDriverPrivate::DB2) + else if (dbType == QSqlDriver::DB2) QVERIFY_SQL( q, exec( QString( "CREATE PROCEDURE %1()" "\nRESULT SETS 2" "\nLANGUAGE SQL" @@ -2713,7 +2713,7 @@ void tst_QSqlQuery::nextResult() "\nSELECT id, text FROM %2" "\nSELECT empty, num, text, id FROM %3" ).arg( procName ).arg( tableName ).arg( tableName ) ) ); - if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::DB2) { + if (dbType == QSqlDriver::MySqlServer || dbType == QSqlDriver::DB2) { q.setForwardOnly( true ); QVERIFY_SQL( q, exec( QString( "CALL %1()" ).arg( procName ) ) ); } else { @@ -2739,7 +2739,7 @@ void tst_QSqlQuery::nextResult() } // MySQL also counts the CALL itself as a result - if (dbType == QSqlDriverPrivate::MySqlServer) { + if (dbType == QSqlDriver::MySqlServer) { QVERIFY( q.nextResult() ); QVERIFY( !q.isSelect() ); // ... but it's not a select QCOMPARE( q.numRowsAffected(), 0 ); // ... and no rows are affected (at least not with this procedure) @@ -2774,11 +2774,11 @@ void tst_QSqlQuery::blobsPreparedQuery() // In PostgreSQL a BLOB is not called a BLOB, but a BYTEA! :-) // ... and in SQL Server it can be called a lot, but IMAGE will do. - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QString typeName( "BLOB" ); - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) typeName = "BYTEA"; - else if (dbType == QSqlDriverPrivate::MSSqlServer) + else if (dbType == QSqlDriver::MSSqlServer) typeName = "IMAGE"; QVERIFY_SQL( q, exec( QString( "CREATE TABLE %1(id INTEGER, data %2)" ).arg( tableName ).arg( typeName ) ) ); @@ -3053,8 +3053,8 @@ void tst_QSqlQuery::sqlServerReturn0() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType != QSqlDriverPrivate::MSSqlServer) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType != QSqlDriver::MSSqlServer) QSKIP("SQL Server specific test"); const QString tableName(qTableName("test141895", __FILE__, db)), procName(qTableName("test141895_proc", __FILE__, db)); @@ -3169,8 +3169,8 @@ void tst_QSqlQuery::QTBUG_18435() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType != QSqlDriverPrivate::MSSqlServer || !db.driverName().startsWith("QODBC")) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType != QSqlDriver::MSSqlServer || !db.driverName().startsWith("QODBC")) QSKIP("SQL Server specific test"); QSqlQuery q(db); @@ -3251,8 +3251,8 @@ void tst_QSqlQuery::QTBUG_6618() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType != QSqlDriverPrivate::MSSqlServer) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType != QSqlDriver::MSSqlServer) QSKIP("SQL Server specific test"); QSqlQuery q(db); @@ -3668,8 +3668,8 @@ void tst_QSqlQuery::sqlite_constraint() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType != QSqlDriverPrivate::SQLite) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType != QSqlDriver::SQLite) QSKIP("Sqlite3 specific test"); QSqlQuery q(db); @@ -3720,10 +3720,10 @@ void tst_QSqlQuery::aggregateFunctionTypes() CHECK_DATABASE(db); QVariant::Type intType = QVariant::Int; // QPSQL uses LongLong for manipulation of integers - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::PostgreSQL) + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::MySqlServer || dbType == QSqlDriver::PostgreSQL) intType = QVariant::LongLong; - else if (dbType == QSqlDriverPrivate::Oracle) + else if (dbType == QSqlDriver::Oracle) intType = QVariant::Double; { const QString tableName(qTableName("numericFunctionsWithIntValues", __FILE__, db)); @@ -3735,9 +3735,9 @@ void tst_QSqlQuery::aggregateFunctionTypes() // First test without any entries QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); QVERIFY(q.next()); - if (dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::SQLite) QCOMPARE(q.record().field(0).type(), QVariant::Invalid); - else if (dbType == QSqlDriverPrivate::MySqlServer) + else if (dbType == QSqlDriver::MySqlServer) QCOMPARE(q.record().field(0).type(), QVariant::Double); else QCOMPARE(q.record().field(0).type(), intType); @@ -3748,15 +3748,15 @@ void tst_QSqlQuery::aggregateFunctionTypes() QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); QVERIFY(q.next()); QCOMPARE(q.value(0).toInt(), 3); - if (dbType == QSqlDriverPrivate::MySqlServer) + if (dbType == QSqlDriver::MySqlServer) 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 (dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::PostgreSQL || dbType == QSqlDriverPrivate::MySqlServer - || dbType == QSqlDriverPrivate::Oracle) { + if (dbType == QSqlDriver::SQLite || dbType == QSqlDriver::PostgreSQL || dbType == QSqlDriver::MySqlServer + || dbType == QSqlDriver::Oracle) { QCOMPARE(q.value(0).toDouble(), 1.5); QCOMPARE(q.record().field(0).type(), QVariant::Double); } else { @@ -3789,7 +3789,7 @@ void tst_QSqlQuery::aggregateFunctionTypes() // First test without any entries QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); QVERIFY(q.next()); - if (dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::SQLite) QCOMPARE(q.record().field(0).type(), QVariant::Invalid); else QCOMPARE(q.record().field(0).type(), QVariant::Double); @@ -3823,7 +3823,7 @@ void tst_QSqlQuery::aggregateFunctionTypes() QCOMPARE(q.record().field(0).type(), QVariant::Double); // PSQL does not have support for the round() function - if (dbType != QSqlDriverPrivate::PostgreSQL) { + if (dbType != QSqlDriver::PostgreSQL) { QVERIFY_SQL(q, exec("SELECT ROUND(id, 1) FROM " + tableName + " WHERE id=1.5")); QVERIFY(q.next()); QCOMPARE(q.value(0).toDouble(), 1.5); @@ -3831,7 +3831,7 @@ void tst_QSqlQuery::aggregateFunctionTypes() QVERIFY_SQL(q, exec("SELECT ROUND(id, 0) FROM " + tableName + " WHERE id=2.5")); QVERIFY(q.next()); - if (dbType == QSqlDriverPrivate::MySqlServer) + if (dbType == QSqlDriver::MySqlServer) QCOMPARE(q.value(0).toDouble(), 2.0); else QCOMPARE(q.value(0).toDouble(), 3.0); @@ -3847,7 +3847,7 @@ void tst_QSqlQuery::aggregateFunctionTypes() QVERIFY_SQL(q, exec("SELECT MAX(txt) FROM " + tableName)); QVERIFY(q.next()); - if (dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::SQLite) QCOMPARE(q.record().field(0).type(), QVariant::Invalid); else QCOMPARE(q.record().field(0).type(), QVariant::String); diff --git a/tests/auto/sql/kernel/qsqlresult/testsqldriver.h b/tests/auto/sql/kernel/qsqlresult/testsqldriver.h index 6dca92de94..c7889a979c 100644 --- a/tests/auto/sql/kernel/qsqlresult/testsqldriver.h +++ b/tests/auto/sql/kernel/qsqlresult/testsqldriver.h @@ -91,11 +91,6 @@ public: int /* port */, const QString & /* options */) { return false; } void close() {} - QSqlDriverPrivate::DBMSType dbmsType() const - { - Q_D(const QSqlDriver); - return d->dbmsType; - } QSqlResult *createResult() const { return new TestSqlDriverResult(this); } }; diff --git a/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp b/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp index ba9b1bb593..bb293c1f55 100644 --- a/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp +++ b/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp @@ -71,17 +71,17 @@ void tst_QSqlResult::parseOfBoundValues() QVERIFY(result.savePrepare("SELECT :1 AS ':2'")); QCOMPARE(result.boundValues().count(), 1); QVERIFY(result.savePrepare("SELECT :1 AS [:2]")); - if (testDriver.dbmsType() == QSqlDriverPrivate::PostgreSQL) + if (testDriver.dbmsType() == QSqlDriver::PostgreSQL) QCOMPARE(result.boundValues().count(), 2); else QCOMPARE(result.boundValues().count(), 1); QVERIFY(result.savePrepare("SELECT :1 AS [:2]]]")); - if (testDriver.dbmsType() == QSqlDriverPrivate::PostgreSQL) + if (testDriver.dbmsType() == QSqlDriver::PostgreSQL) QCOMPARE(result.boundValues().count(), 2); else QCOMPARE(result.boundValues().count(), 1); QVERIFY(result.savePrepare("SELECT :1 AS [:2]]]]]")); - if (testDriver.dbmsType() == QSqlDriverPrivate::PostgreSQL) + if (testDriver.dbmsType() == QSqlDriver::PostgreSQL) QCOMPARE(result.boundValues().count(), 2); else QCOMPARE(result.boundValues().count(), 1); @@ -91,7 +91,7 @@ void tst_QSqlResult::parseOfBoundValues() QVERIFY(result.savePrepare("SELECT ? AS '?'")); QCOMPARE(result.boundValues().count(), 1); QVERIFY(result.savePrepare("SELECT ? AS [?]")); - if (testDriver.dbmsType() == QSqlDriverPrivate::PostgreSQL) + if (testDriver.dbmsType() == QSqlDriver::PostgreSQL) QCOMPARE(result.boundValues().count(), 2); else QCOMPARE(result.boundValues().count(), 1); diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp index 881405ce38..84e2fd57de 100644 --- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -150,8 +150,8 @@ void tst_QSqlQueryModel::createTestTables(QSqlDatabase db) { dropTestTables(db); QSqlQuery q(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::PostgreSQL) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); QVERIFY_SQL( q, exec("create table " + qTableName("test", __FILE__, db) + "(id integer not null, name varchar(20), title integer, primary key (id))")); QVERIFY_SQL( q, exec("create table " + qTableName("test2", __FILE__, db) + "(id integer not null, title varchar(20), primary key (id))")); @@ -305,13 +305,13 @@ void tst_QSqlQueryModel::insertColumn() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); DBTestModel model; model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db)); model.fetchMore(); // necessary??? - bool isToUpper = (dbType == QSqlDriverPrivate::Interbase) || (dbType == QSqlDriverPrivate::Oracle) || (dbType == QSqlDriverPrivate::DB2); + bool isToUpper = (dbType == QSqlDriver::Interbase) || (dbType == QSqlDriver::Oracle) || (dbType == QSqlDriver::DB2); const QString idColumn(isToUpper ? "ID" : "id"); const QString nameColumn(isToUpper ? "NAME" : "name"); const QString titleColumn(isToUpper ? "TITLE" : "title"); @@ -409,14 +409,14 @@ void tst_QSqlQueryModel::record() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlQueryModel model; model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db)); QSqlRecord rec = model.record(); - bool isToUpper = (dbType == QSqlDriverPrivate::Interbase) || (dbType == QSqlDriverPrivate::Oracle) || (dbType == QSqlDriverPrivate::DB2); + bool isToUpper = (dbType == QSqlDriver::Interbase) || (dbType == QSqlDriver::Oracle) || (dbType == QSqlDriver::DB2); QCOMPARE(rec.count(), 3); QCOMPARE(rec.fieldName(0), isToUpper ? QString("ID") : QString("id")); @@ -440,7 +440,7 @@ void tst_QSqlQueryModel::setHeaderData() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlQueryModel model; @@ -461,7 +461,7 @@ void tst_QSqlQueryModel::setHeaderData() QVERIFY(!model.setHeaderData(7, Qt::Horizontal, "foo", Qt::ToolTipRole)); QVERIFY(!model.headerData(7, Qt::Horizontal, Qt::ToolTipRole).isValid()); - bool isToUpper = (dbType == QSqlDriverPrivate::Interbase) || (dbType == QSqlDriverPrivate::Oracle) || (dbType == QSqlDriverPrivate::DB2); + bool isToUpper = (dbType == QSqlDriver::Interbase) || (dbType == QSqlDriver::Oracle) || (dbType == QSqlDriver::DB2); QCOMPARE(model.headerData(0, Qt::Horizontal).toString(), isToUpper ? QString("ID") : QString("id")); QCOMPARE(model.headerData(1, Qt::Horizontal).toString(), isToUpper ? QString("NAME") : QString("name")); QCOMPARE(model.headerData(2, Qt::Horizontal).toString(), QString("bar")); diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index c75a2cf1ab..e97c391a52 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -143,13 +143,13 @@ void tst_QSqlRelationalTableModel::initTestCase() { foreach (const QString &dbname, dbs.dbNames) { QSqlDatabase db=QSqlDatabase::database(dbname); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::Interbase) { + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::Interbase) { db.exec("SET DIALECT 3"); - } else if (dbType == QSqlDriverPrivate::MSSqlServer) { + } else if (dbType == QSqlDriver::MSSqlServer) { db.exec("SET ANSI_DEFAULTS ON"); db.exec("SET IMPLICIT_TRANSACTIONS OFF"); - } else if (dbType == QSqlDriverPrivate::PostgreSQL) { + } else if (dbType == QSqlDriver::PostgreSQL) { db.exec("set client_min_messages='warning'"); } recreateTestTables(db); @@ -238,7 +238,7 @@ void tst_QSqlRelationalTableModel::setData() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); // set the values using OnRowChange Strategy { @@ -321,7 +321,7 @@ void tst_QSqlRelationalTableModel::setData() //sybase doesn't allow tables with the same alias used twice as col names //so don't set up an identical relation when using the tds driver - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); model.setEditStrategy(QSqlTableModel::OnManualSubmit); @@ -334,7 +334,7 @@ void tst_QSqlRelationalTableModel::setData() QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi2")); QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr")); else QCOMPARE(model.data(model.index(0, 3)).toInt(), 1); @@ -352,12 +352,12 @@ void tst_QSqlRelationalTableModel::setData() QCOMPARE(model.data(model.index(0, 3)).toInt(), 1); model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr")); else QCOMPARE(model.data(model.index(0, 3)).toInt(), 1); @@ -554,7 +554,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlRelationalTableModel model(0, db); @@ -562,14 +562,14 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); model.setSort(0, Qt::AscendingOrder); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0,0)).toInt(), 1); QCOMPARE(model.data(model.index(0,1)).toString(), QString("harry")); QCOMPARE(model.data(model.index(0,2)).toString(), QString("herr")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister")); else QCOMPARE(model.data(model.index(0,3)).toInt(), 2); @@ -583,7 +583,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QCOMPARE(model.data(model.index(0,0)).toInt(), 1011); QCOMPARE(model.data(model.index(0,1)).toString(), QString("test")); QCOMPARE(model.data(model.index(0,2)).toString(), QString("mister")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr")); else QCOMPARE(model.data(model.index(0,3)).toInt(), 1); @@ -591,7 +591,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QCOMPARE(model.data(model.index(1,0)).toInt(), 1); QCOMPARE(model.data(model.index(1,1)).toString(), QString("harry")); QCOMPARE(model.data(model.index(1,2)).toString(), QString("herr")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(1,3)).toString(), QString("mister")); else QCOMPARE(model.data(model.index(1,3)).toInt(), 2); @@ -608,7 +608,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QCOMPARE(model.data(model.index(0,1)).toString(), QString("harry")); QCOMPARE(model.data(model.index(0,2)).toString(), QString("herr")); - if (dbType != QSqlDriverPrivate::Sybase) { + if (dbType != QSqlDriver::Sybase) { QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister")); model.setData(model.index(0,3),1); QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr")); @@ -632,7 +632,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QCOMPARE(model.data(model.index(0,0)).toInt(),1012); QCOMPARE(model.data(model.index(0,1)).toString(), QString("george")); QCOMPARE(model.data(model.index(0,2)).toString(), QString("mister")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister")); else QCOMPARE(model.data(model.index(0,3)).toInt(), 2); @@ -641,7 +641,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QCOMPARE(model.data(model.index(1,0)).toInt(),1013); QCOMPARE(model.data(model.index(1,1)).toString(), QString("kramer")); QCOMPARE(model.data(model.index(1,2)).toString(), QString("mister")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(1,3)).toString(), QString("herr")); else QCOMPARE(model.data(model.index(1,3)).toInt(), 1); @@ -649,7 +649,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QCOMPARE(model.data(model.index(2,0)).toInt(), 1); QCOMPARE(model.data(model.index(2,1)).toString(), QString("harry")); QCOMPARE(model.data(model.index(2,2)).toString(), QString("herr")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(2,3)).toString(), QString("herr")); else QCOMPARE(model.data(model.index(2,3)).toInt(), 1); @@ -746,13 +746,13 @@ void tst_QSqlRelationalTableModel::sort() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlRelationalTableModel model(0, db); model.setTable(reltest1); model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); model.setSort(2, Qt::DescendingOrder); @@ -768,7 +768,7 @@ void tst_QSqlRelationalTableModel::sort() model.setSort(3, Qt::AscendingOrder); QVERIFY_SQL(model, select()); - if (dbType != QSqlDriverPrivate::Sybase) { + if (dbType != QSqlDriver::Sybase) { QCOMPARE(model.rowCount(), 4); QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr")); QCOMPARE(model.data(model.index(1, 3)).toString(), QString("mister")); @@ -797,7 +797,7 @@ void tst_QSqlRelationalTableModel::sort() model.setSort(3, Qt::AscendingOrder); QVERIFY_SQL(model, select()); - if (dbType != QSqlDriverPrivate::Sybase) { + if (dbType != QSqlDriver::Sybase) { QCOMPARE(model.rowCount(), 6); QCOMPARE(model.data(model.index(0, 3)).toString(), QString("")); QCOMPARE(model.data(model.index(1, 3)).toString(), QString("herr")); @@ -912,14 +912,14 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlRelationalTableModel model(0, db); model.setTable(reltest1); model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); model.setSort(1, Qt::AscendingOrder); model.setEditStrategy(QSqlTableModel::OnManualSubmit); @@ -929,7 +929,7 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache() QCOMPARE(model.data(model.index(3, 0)).toInt(), 3); QCOMPARE(model.data(model.index(3, 1)).toString(), QString("vohi")); QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(3, 3)).toString(), QString("mister")); else QCOMPARE(model.data(model.index(3, 3)).toInt(), 2 ); @@ -944,7 +944,7 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache() QCOMPARE(model.data(model.index(0, 0)).toInt(), 7); QCOMPARE(model.data(model.index(0, 1)).toString(), QString("anders")); QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr")); else QCOMPARE(model.data(model.index(0, 3)).toInt(), 1); @@ -952,7 +952,7 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache() QCOMPARE(model.data(model.index(4, 0)).toInt(), 3); QCOMPARE(model.data(model.index(4, 1)).toString(), QString("vohi")); QCOMPARE(model.data(model.index(4, 2)).toString(), QString("herr")); - if (dbType != QSqlDriverPrivate::Sybase) + if (dbType != QSqlDriver::Sybase) QCOMPARE(model.data(model.index(4, 3)).toString(), QString("mister")); else QCOMPARE(model.data(model.index(4, 3)).toInt(), 2); @@ -966,7 +966,7 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlRelationalTableModel model(0, db); model.setTable(reltest3); @@ -977,7 +977,7 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames() model.setRelation(2, QSqlRelation(reltest4, "id", "name")); QVERIFY_SQL(model, select()); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) { + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) { QCOMPARE(model.record(1).value((reltest4+QLatin1String("_name_2")).toUpper()).toString(), QString("Trondheim")); } else { @@ -990,7 +990,7 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames() rec.setValue(1, "Berge"); rec.setValue(2, 1); // Must insert the key value - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) { + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) { QCOMPARE(rec.fieldName(0), QLatin1String("ID")); QCOMPARE(rec.fieldName(1), QLatin1String("NAME")); // This comes from main table } else { @@ -999,7 +999,7 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames() } // The duplicate field names is aliased because it's comes from the relation's display column. - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) QCOMPARE(rec.fieldName(2), (reltest4+QLatin1String("_name_2")).toUpper()); else QCOMPARE(rec.fieldName(2), reltest4+QLatin1String("_name_2")); @@ -1088,9 +1088,9 @@ void tst_QSqlRelationalTableModel::casing() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::MSSqlServer) + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::SQLite || dbType == QSqlDriver::MSSqlServer) QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities"); QSqlQuery q(db); @@ -1109,7 +1109,7 @@ void tst_QSqlRelationalTableModel::casing() QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db) + " values(2, 'george', 2)")); QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db) + " values(4, 'kramer', 2)")); - if (dbType == QSqlDriverPrivate::Oracle) { + if (dbType == QSqlDriver::Oracle) { //try an owner that doesn't exist QSqlRecord rec = db.driver()->record("doug." + qTableName("CASETEST1", db).toUpper()); QCOMPARE( rec.count(), 0); @@ -1155,7 +1155,7 @@ void tst_QSqlRelationalTableModel::escapedRelations() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); recreateTestTables(db); @@ -1163,7 +1163,7 @@ void tst_QSqlRelationalTableModel::escapedRelations() model.setTable(reltest1); //try with relation table name quoted - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) { + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) { model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(reltest2.toUpper(),QSqlDriver::TableName), "tid", "title")); @@ -1188,7 +1188,7 @@ void tst_QSqlRelationalTableModel::escapedRelations() //try with index column quoted model.setJoinMode(QSqlRelationalTableModel::InnerJoin); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) { + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) { model.setRelation(2, QSqlRelation(reltest2, db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName).toUpper(), "title")); @@ -1212,7 +1212,7 @@ void tst_QSqlRelationalTableModel::escapedRelations() //try with display column quoted model.setJoinMode(QSqlRelationalTableModel::InnerJoin); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) { + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) { model.setRelation(2, QSqlRelation(reltest2, "tid", @@ -1238,7 +1238,7 @@ void tst_QSqlRelationalTableModel::escapedRelations() //try with tablename and index and display columns quoted in the relation model.setJoinMode(QSqlRelationalTableModel::InnerJoin); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) { + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) { model.setRelation(2, QSqlRelation(reltest2, "tid", db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper())); @@ -1266,13 +1266,13 @@ void tst_QSqlRelationalTableModel::escapedTableName() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); // set the values using OnRowChange Strategy with an escaped tablename { QSqlRelationalTableModel model(0, db); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) { + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) { model.setTable(db.driver()->escapeIdentifier(reltest1.toUpper(), QSqlDriver::TableName)); } else { model.setTable(db.driver()->escapeIdentifier(reltest1, QSqlDriver::TableName)); @@ -1319,7 +1319,7 @@ void tst_QSqlRelationalTableModel::escapedTableName() { QSqlRelationalTableModel model(0, db); - if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) { + if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) { model.setTable(db.driver()->escapeIdentifier(reltest1.toUpper(), QSqlDriver::TableName)); } else { model.setTable(db.driver()->escapeIdentifier(reltest1, QSqlDriver::TableName)); @@ -1455,9 +1455,9 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType != QSqlDriverPrivate::PostgreSQL) + if (dbType != QSqlDriver::PostgreSQL) QSKIP("Postgresql specific test"); QSqlRelationalTableModel model(0, db); diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index b560470fcf..b77b883b03 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -160,9 +160,9 @@ void tst_QSqlTableModel::dropTestTables() { for (int i = 0; i < dbs.dbNames.count(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q(db); - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); QStringList tableNames; @@ -189,7 +189,7 @@ void tst_QSqlTableModel::createTestTables() { for (int i = 0; i < dbs.dbNames.count(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q(db); QVERIFY_SQL( q, exec("create table " + test + "(id int, name varchar(20), title int)")); @@ -198,7 +198,7 @@ void tst_QSqlTableModel::createTestTables() QVERIFY_SQL( q, exec("create table " + test3 + "(id int, random varchar(20), randomtwo varchar(20))")); - if (dbType != QSqlDriverPrivate::MSSqlServer) + if (dbType != QSqlDriver::MSSqlServer) QVERIFY_SQL(q, exec("create table " + qTableName("test4", __FILE__, db) + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))")); else QVERIFY_SQL(q, exec("create table " + qTableName("test4", __FILE__, db) + "(column1 varchar(50), column2 varchar(50) NULL, column3 varchar(50))")); @@ -1699,11 +1699,11 @@ void tst_QSqlTableModel::primaryKeyOrder() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q(db); - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); QVERIFY_SQL(q, exec("create table " + qTableName("foo", __FILE__, db) + "(a varchar(20), id int not null primary key, b varchar(20))")); diff --git a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp index 25e972a4d5..769dbe6d47 100644 --- a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp +++ b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp @@ -109,7 +109,7 @@ void tst_QSqlQuery::cleanup() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); if ( QTest::currentTestFunction() == QLatin1String( "numRowsAffected" ) || QTest::currentTestFunction() == QLatin1String( "transactions" ) @@ -119,7 +119,7 @@ void tst_QSqlQuery::cleanup() populateTestTables( db ); } - if (QTest::currentTestFailed() && (dbType == QSqlDriverPrivate::Oracle || db.driverName().startsWith("QODBC"))) { + if (QTest::currentTestFailed() && (dbType == QSqlDriver::Oracle || db.driverName().startsWith("QODBC"))) { //since Oracle ODBC totally craps out on error, we init again db.close(); db.open(); @@ -138,7 +138,7 @@ void tst_QSqlQuery::generic_data(const QString& engine) void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) { - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); QStringList tablenames; // drop all the table in case a testcase failed tablenames << qtest @@ -172,24 +172,24 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) << qTableName("test141895", __FILE__, db) << qTableName("qtest_oraOCINumber", __FILE__, db); - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) tablenames << qTableName("task_233829", __FILE__, db); - if (dbType == QSqlDriverPrivate::SQLite) + if (dbType == QSqlDriver::SQLite) tablenames << qTableName("record_sqlite", __FILE__, db); - if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Oracle) + if (dbType == QSqlDriver::MSSqlServer || dbType == QSqlDriver::Oracle) tablenames << qTableName("qtest_longstr", __FILE__, db); - if (dbType == QSqlDriverPrivate::MSSqlServer) + if (dbType == QSqlDriver::MSSqlServer) db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__, db)); - if (dbType == QSqlDriverPrivate::MySqlServer) + if (dbType == QSqlDriver::MySqlServer) db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__, db)); tst_Databases::safeDropTables( db, tablenames ); - if (dbType == QSqlDriverPrivate::Oracle) { + if (dbType == QSqlDriver::Oracle) { QSqlQuery q( db ); q.exec("DROP PACKAGE " + qTableName("pkg", __FILE__, db)); } @@ -199,20 +199,20 @@ void tst_QSqlQuery::createTestTables( QSqlDatabase db ) { const QString qtestNull = qTableName("qtest_null", __FILE__, db); QSqlQuery q( db ); - QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); - if (dbType == QSqlDriverPrivate::MySqlServer) + QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriver::MySqlServer) // ### stupid workaround until we find a way to hardcode this // in the MySQL server startup script q.exec( "set table_type=innodb" ); - else if (dbType == QSqlDriverPrivate::PostgreSQL) + else if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - if (dbType == QSqlDriverPrivate::PostgreSQL) + if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec( "create table " + 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 " + qtest + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) ); - if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Sybase) + if (dbType == QSqlDriver::MSSqlServer || dbType == QSqlDriver::Sybase) QVERIFY_SQL(q, exec("create table " + qtestNull + " (id int null, t_varchar varchar(20) null)")); else QVERIFY_SQL(q, exec("create table " + qtestNull + " (id int, t_varchar varchar(20))"));