summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2021-01-07 15:46:01 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-07 23:23:52 +0000
commit517450d03a7a1c638aa32fec5a6101b79779d827 (patch)
tree090f2693de4f9a8cbdcab08b1b7f074fc3638d3e /tests
parent4460711a802b4dfb6a9e71666185b15c59fb2e3a (diff)
PSQL: Fix the QSqlDatabase test
Change-Id: Ic7956b556f1f0f10574fd79f5cbd283208240353 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> (cherry picked from commit dce43106e2944e14ac86cf3bc7e624795d2c51cb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index 4e6664faa0..84e4ab373c 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -374,8 +374,10 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
q.exec("drop schema " + qTableName("qtestScHeMa", __FILE__, db) + " cascade");
}
- if (testWhiteSpaceNames(db.driverName()))
- tableNames << db.driver()->escapeIdentifier(qtestTable + " test", QSqlDriver::TableName);
+ if (testWhiteSpaceNames(db.driverName())) {
+ tableNames << db.driver()->escapeIdentifier(qTableName("qtest test", __FILE__, db),
+ QSqlDriver::TableName);
+ }
tst_Databases::safeDropTables(db, tableNames);
@@ -521,7 +523,8 @@ void tst_QSqlDatabase::tables()
const auto qtest(qTableName("qtest", __FILE__, db, false)),
qtest_view(qTableName("qtest_view", __FILE__, db, false)),
- temp_tab(qTableName("test_tab", __FILE__, db, false));
+ temp_tab(qTableName("test_tab", __FILE__, db, false)),
+ qtestspace(qTableName("qtest test", __FILE__, db, false));
bool views = true;
bool tempTables = false;
@@ -571,7 +574,7 @@ void tst_QSqlDatabase::tables()
QVERIFY(tables.contains(qtest, Qt::CaseInsensitive));
if (dbType == QSqlDriver::PostgreSQL)
- QVERIFY(tables.contains(qtest + " test"));
+ QVERIFY(tables.contains(qtestspace));
}
void tst_QSqlDatabase::whitespaceInIdentifiers()
@@ -2120,7 +2123,14 @@ void tst_QSqlDatabase::eventNotification()
QVERIFY(driver->subscribedToNotifications().contains("event_foo"));
// Can't subscribe to the same event multiple times
- QVERIFY2(!driver->subscribeToNotification(QLatin1String("event_foo")), "Shouldn't be able to subscribe to event_foo twice");
+ const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType != QSqlDriver::PostgreSQL) {
+ // We will resubscribe on PostgreSQL in case it is due to a disconnect, the call will
+ // do nothing on the PostgreSQL side but it will indicate it succeeded anyway and there
+ // will still only be one entry for it
+ QVERIFY2(!driver->subscribeToNotification(QLatin1String("event_foo")),
+ "Shouldn't be able to subscribe to event_foo twice");
+ }
QCOMPARE(driver->subscribedToNotifications().size(), 1);
// Unsubscribe from "event_foo"