Skip to content

Commit

Permalink
PSQL: Fix the QSqlDatabase test
Browse files Browse the repository at this point in the history
Pick-to: 6.0 5.15
Change-Id: Ic7956b556f1f0f10574fd79f5cbd283208240353
Reviewed-by: Christian Ehrlicher <[email protected]>
  • Loading branch information
AndyShawQt committed Jan 7, 2021
1 parent 1b636b7 commit dce4310
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,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);

Expand Down Expand Up @@ -523,7 +525,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;
Expand Down Expand Up @@ -573,7 +576,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()
Expand Down Expand Up @@ -2122,7 +2125,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"
Expand Down

0 comments on commit dce4310

Please sign in to comment.