summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-10-14 17:46:16 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-10-14 17:46:34 +0200
commit440286655e0ca271506cf7cc02ad0dbf4baef9ca (patch)
tree896fa81adb8b14a69355a3a6cf64d06ec8173c9a /tests/auto/sql
parent1e27ad1697187549151657ba187928e439300db7 (diff)
parente164d61ca8263fc4b46fdd916e1ea77c7dd2b735 (diff)
Merge remote-tracking branch 'origin/dev' into wip/cmake
Diffstat (limited to 'tests/auto/sql')
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp62
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp21
2 files changed, 24 insertions, 59 deletions
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index c59250e36e..f726139e08 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -520,10 +520,6 @@ void tst_QSqlDatabase::tables()
bool tempTables = false;
QSqlQuery q(db);
- if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
- QSKIP( "Test requires MySQL >= 5.0");
-
-
if (!q.exec("CREATE VIEW " + qtest_view + " as select * from " + qtest)) {
qDebug("DBMS '%s' cannot handle VIEWs: %s",
qPrintable(tst_Databases::dbToString(db)),
@@ -1891,11 +1887,6 @@ void tst_QSqlDatabase::mysql_multiselect()
const QString qtest(qTableName("qtest", __FILE__, db));
QSqlQuery q(db);
- QString version=tst_Databases::getMySqlVersion( db );
- double ver=version.section(QChar::fromLatin1('.'),0,1).toDouble();
- if (ver < 4.1)
- QSKIP("Test requires MySQL >= 4.1");
-
QVERIFY_SQL(q, exec("SELECT * FROM " + qtest + "; SELECT * FROM " + qtest));
QVERIFY_SQL(q, next());
QVERIFY_SQL(q, exec("SELECT * FROM " + qtest + "; SELECT * FROM " + qtest));
@@ -2135,6 +2126,8 @@ void tst_QSqlDatabase::eventNotificationIBase()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
+ if (db.driverName().compare(QLatin1String("QIBASE"), Qt::CaseInsensitive))
+ QSKIP("QIBASE specific test");
CHECK_DATABASE(db);
const QString procedureName(qTableName("posteventProc", __FILE__, db));
@@ -2147,13 +2140,12 @@ void tst_QSqlDatabase::eventNotificationIBase()
q.exec(QString("DROP PROCEDURE %1").arg(procedureName));
q.exec(QString("CREATE PROCEDURE %1\nAS BEGIN\nPOST_EVENT '%1';\nEND;").arg(procedureName));
q.exec(QString("EXECUTE PROCEDURE %1").arg(procedureName));
- QSignalSpy spy(driver, SIGNAL(notification(QString)));
+ QSignalSpy spy(driver, QOverload<const QString &, QSqlDriver::NotificationSource, const QVariant &>::of(&QSqlDriver::notification));
db.commit(); // No notifications are posted until the transaction is committed.
- QTest::qWait(300); // Interbase needs some time to post the notification and call the driver callback.
- // This happends from another thread, and we have to process events in order for the
- // event handler in the driver to be executed and emit the notification signal.
-
- QCOMPARE(spy.count(), 1);
+ // Interbase needs some time to post the notification and call the driver callback.
+ // This happends from another thread, and we have to process events in order for the
+ // event handler in the driver to be executed and emit the notification signal.
+ QTRY_COMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), procedureName);
QVERIFY_SQL(*driver, unsubscribeFromNotification(procedureName));
@@ -2164,52 +2156,49 @@ void tst_QSqlDatabase::eventNotificationPSQL()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
+ if (db.driverName().compare(QLatin1String("QPSQL"), Qt::CaseInsensitive))
+ QSKIP("QPSQL specific test");
CHECK_DATABASE(db);
QSqlQuery query(db);
const auto procedureName = qTableName("posteventProc", __FILE__, db, false);
QString payload = "payload";
- QSqlDriver &driver=*(db.driver());
- QVERIFY_SQL(driver, subscribeToNotification(procedureName));
- QSignalSpy spy(db.driver(), SIGNAL(notification(QString,QSqlDriver::NotificationSource,QVariant)));
+ QSqlDriver *driver = db.driver();
+ QVERIFY_SQL(*driver, subscribeToNotification(procedureName));
+ QSignalSpy spy(driver, QOverload<const QString &, QSqlDriver::NotificationSource, const QVariant &>::of(&QSqlDriver::notification));
query.exec(QString("NOTIFY \"%1\", '%2'").arg(procedureName).arg(payload));
- QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), procedureName);
QCOMPARE(qvariant_cast<QSqlDriver::NotificationSource>(arguments.at(1)), QSqlDriver::SelfSource);
QCOMPARE(qvariant_cast<QVariant>(arguments.at(2)).toString(), payload);
- QVERIFY_SQL(driver, unsubscribeFromNotification(procedureName));
+ QVERIFY_SQL(*driver, unsubscribeFromNotification(procedureName));
}
void tst_QSqlDatabase::eventNotificationSQLite()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
- CHECK_DATABASE(db);
- if (db.driverName().compare(QLatin1String("QSQLITE"), Qt::CaseInsensitive)) {
+ if (db.driverName().compare(QLatin1String("QSQLITE"), Qt::CaseInsensitive))
QSKIP("QSQLITE specific test");
- }
+ CHECK_DATABASE(db);
+
const QString tableName(qTableName("sqlitnotifytest", __FILE__, db));
const auto noEscapeTableName(qTableName("sqlitnotifytest", __FILE__, db, false));
tst_Databases::safeDropTable(db, tableName);
- QSignalSpy notificationSpy(db.driver(), SIGNAL(notification(QString)));
- QSignalSpy notificationSpyExt(db.driver(), SIGNAL(notification(QString,QSqlDriver::NotificationSource,QVariant)));
+ QSqlDriver *driver = db.driver();
+ QSignalSpy spy(driver, QOverload<const QString &, QSqlDriver::NotificationSource, const QVariant &>::of(&QSqlDriver::notification));
QSqlQuery q(db);
QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INTEGER, realVal REAL)"));
- db.driver()->subscribeToNotification(noEscapeTableName);
+ driver->subscribeToNotification(noEscapeTableName);
QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, realVal) VALUES (1, 2.3)"));
- QTRY_COMPARE(notificationSpy.count(), 1);
- QTRY_COMPARE(notificationSpyExt.count(), 1);
- QList<QVariant> arguments = notificationSpy.takeFirst();
- QCOMPARE(arguments.at(0).toString(), noEscapeTableName);
- arguments = notificationSpyExt.takeFirst();
+ QTRY_COMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), noEscapeTableName);
- db.driver()->unsubscribeFromNotification(noEscapeTableName);
+ driver->unsubscribeFromNotification(noEscapeTableName);
QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, realVal) VALUES (1, 2.3)"));
- QTRY_COMPARE(notificationSpy.count(), 0);
- QTRY_COMPARE(notificationSpyExt.count(), 0);
+ QTRY_COMPARE(spy.count(), 0);
}
void tst_QSqlDatabase::sqlite_bindAndFetchUInt()
@@ -2282,9 +2271,6 @@ void tst_QSqlDatabase::mysql_savepointtest()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if (tst_Databases::getMySqlVersion(db).section(QChar('.'), 0, 1).toDouble() < 4.1)
- QSKIP( "Test requires MySQL >= 4.1");
-
QSqlQuery q(db);
QVERIFY_SQL(q, exec("begin"));
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest", __FILE__, db) + " VALUES (54, 'foo', 'foo', 54.54)"));
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 784d0a70d7..ef58d612c9 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -480,10 +480,6 @@ void tst_QSqlQuery::char1SelectUnicode()
if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) {
QString uniStr( QChar(0x0915) ); // DEVANAGARI LETTER KA
QSqlQuery q( db );
-
- if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
- QSKIP( "Test requires MySQL >= 5.0");
-
QString createQuery;
const QString char1SelectUnicode(qTableName("char1SU", __FILE__, db));
@@ -563,9 +559,6 @@ void tst_QSqlQuery::mysql_outValues()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if (tst_Databases::getMySqlVersion(db).section(QChar('.'), 0, 0 ).toInt() < 5)
- QSKIP( "Test requires MySQL >= 5.0");
-
const QString hello(qTableName("hello", __FILE__, db)), qtestproc(qTableName("qtestproc", __FILE__, db));
QSqlQuery q( db );
@@ -2093,10 +2086,6 @@ void tst_QSqlQuery::prepare_bind_exec()
bool useUnicode = db.driver()->hasFeature( QSqlDriver::Unicode );
QSqlQuery q( db );
-
- if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
- useUnicode = false;
-
QString createQuery;
QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
if (dbType == QSqlDriver::PostgreSQL)
@@ -3068,10 +3057,6 @@ void tst_QSqlQuery::nextResult()
QSKIP("DBMS does not support multiple result sets");
QSqlQuery q( db );
-
- if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
- QSKIP( "Test requires MySQL >= 5.0");
-
const QString tableName(qTableName("more_results", __FILE__, db));
QVERIFY_SQL( q, exec( "CREATE TABLE " + tableName + " (id integer, text varchar(20), num numeric(6, 3), empty varchar(10));" ) );
@@ -3836,9 +3821,6 @@ void tst_QSqlQuery::QTBUG_6852()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if ( tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
- QSKIP( "Test requires MySQL >= 5.0");
-
QSqlQuery q(db);
const QString tableName(qTableName("bug6852", __FILE__, db)), procName(qTableName("bug6852_proc", __FILE__, db));
@@ -3870,9 +3852,6 @@ void tst_QSqlQuery::QTBUG_5765()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if ( tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 1 ).toFloat()<4.1 )
- QSKIP( "Test requires MySQL >= 4.1");
-
QSqlQuery q(db);
const QString tableName(qTableName("bug5765", __FILE__, db));