SQL/Tests: fix tst_qsqldatabase::caseSensivity() for MySQL on linux

MySQL has a different default setting for case sensitive table names on
linux and windows which makes the test fail on linux but work on
windows when using the database with the default settings. Read out the
respecitive setting so the test will pass every time.

Change-Id: I8651858d47652022ddc4b6386a6153cf70c6fed6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Christian Ehrlicher 2022-10-15 20:49:25 +02:00 committed by Volker Hilsheimer
parent 16e0e7c779
commit 05ec29f76c

View File

@ -1243,21 +1243,21 @@ void tst_QSqlDatabase::caseSensivity()
}
QSqlRecord rec = db.record(qTableName("qtest", __FILE__, db, driverQuotedCaseSensitive(db)));
QVERIFY((int)rec.count() > 0);
QVERIFY(rec.count() > 0);
if (!cs) {
rec = db.record(qTableName("QTEST", __FILE__, db, false).toUpper());
QVERIFY((int)rec.count() > 0);
rec = db.record(qTableName("qTesT", __FILE__, db, false));
QVERIFY((int)rec.count() > 0);
rec = db.record(qTableName("QTEST", __FILE__, db, false).toUpper());
QVERIFY(rec.count() > 0);
rec = db.record(qTableName("qTesT", __FILE__, db, false));
QVERIFY(rec.count() > 0);
}
rec = db.primaryIndex(qTableName("qtest", __FILE__, db, driverQuotedCaseSensitive(db)));
QVERIFY((int)rec.count() > 0);
QVERIFY(rec.count() > 0);
if (!cs) {
rec = db.primaryIndex(qTableName("QTEST", __FILE__, db, false).toUpper());
QVERIFY((int)rec.count() > 0);
rec = db.primaryIndex(qTableName("qTesT", __FILE__, db, false));
QVERIFY((int)rec.count() > 0);
rec = db.primaryIndex(qTableName("QTEST", __FILE__, db, false).toUpper());
QVERIFY(rec.count() > 0);
rec = db.primaryIndex(qTableName("qTesT", __FILE__, db, false));
QVERIFY(rec.count() > 0);
}
// Explicit test for case sensitive table creation without quoting
@ -1269,6 +1269,13 @@ void tst_QSqlDatabase::caseSensivity()
QVERIFY_SQL(qry, exec("SELECT * FROM " + noQuotesTable));
QVERIFY_SQL(qry, next());
QCOMPARE(qry.value(0).toInt(), 1);
// QMYSQLDriver::record() is using a mysql function instead of a query, so quoting
// will not help when the table names are not stored lowercase.
if (dbType == QSqlDriver::MySqlServer) {
QVERIFY_SQL(qry, exec("SHOW GLOBAL VARIABLES LIKE 'lower_case_table_names'"));
QVERIFY_SQL(qry, next());
cs = qry.value(1).toInt() != 0;
}
rec = db.record(cs ? noQuotesTable.toLower() : noQuotesTable);
QVERIFY(rec.count() > 0);
}