QSqlDatabase: make evident the name of the driver that failed to load
Tell me this isn't confusing: Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB") QSqlDatabase: driver not loaded QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 This also merges the two messages into a single line, which is nicer for rich logging environments. Change-Id: Ieb80c6571213dddc518bfffdb6c86632df8f932c Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> (cherry picked from commit 4216ba7c37dbdf67bfb5dc793d01a232ce4ea762) (cherry picked from commit 22dd10e261c1c9ab46a8bfe99f574bae1c6c01e9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9a6b7641e8
commit
d0787745aa
@ -655,9 +655,9 @@ void QSqlDatabasePrivate::init(const QString &type)
|
||||
driver = qLoadPlugin<QSqlDriver, QSqlDriverPlugin>(loader(), type);
|
||||
|
||||
if (!driver) {
|
||||
qCWarning(lcSqlDb, "QSqlDatabase: %ls driver not loaded", qUtf16Printable(type));
|
||||
qCWarning(lcSqlDb, "QSqlDatabase: available drivers: %ls",
|
||||
qUtf16Printable(QSqlDatabase::drivers().join(u' ')));
|
||||
qCWarning(lcSqlDb,
|
||||
"QSqlDatabase: can not load requested driver '%ls', available drivers: %ls",
|
||||
qUtf16Printable(type), qUtf16Printable(QSqlDatabase::drivers().join(u' ')));
|
||||
if (QCoreApplication::instance() == nullptr)
|
||||
qCWarning(lcSqlDb, "QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins");
|
||||
driver = shared_null()->driver;
|
||||
|
@ -383,8 +383,9 @@ void tst_QSqlDatabase::generic_data(const QString& engine)
|
||||
|
||||
void tst_QSqlDatabase::addDatabase()
|
||||
{
|
||||
QTest::ignoreMessage(QtWarningMsg, "QSqlDatabase: BLAH_FOO_NONEXISTENT_DRIVER driver not loaded");
|
||||
QTest::ignoreMessage(QtWarningMsg, qPrintable("QSqlDatabase: available drivers: " + QSqlDatabase::drivers().join(QLatin1Char(' '))));
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
"QSqlDatabase: can not load requested driver 'BLAH_FOO_NONEXISTENT_DRIVER', available drivers: "
|
||||
+ QSqlDatabase::drivers().join(QLatin1Char(' ')).toLatin1());
|
||||
{
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("BLAH_FOO_NONEXISTENT_DRIVER",
|
||||
"INVALID_CONNECTION");
|
||||
|
@ -2908,10 +2908,10 @@ void tst_QSqlQuery::queryOnInvalidDatabase()
|
||||
QSqlDatabase::removeDatabase("invalidConnection");
|
||||
});
|
||||
// Note: destruction of db needs to happen before we call removeDatabase.
|
||||
QTest::ignoreMessage(QtWarningMsg, "QSqlDatabase: INVALID driver not loaded");
|
||||
#if QT_CONFIG(regularexpression)
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
QRegularExpression("QSqlDatabase: available drivers: "));
|
||||
QRegularExpression("QSqlDatabase: can not load requested driver "
|
||||
"'INVALID', available drivers: "));
|
||||
#endif
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("INVALID", "invalidConnection");
|
||||
QVERIFY(db.lastError().isValid());
|
||||
|
Loading…
x
Reference in New Issue
Block a user