From 461ef575bcf778ba24b0be6b775098d4b80ae5e1 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 16 Jan 2018 09:54:01 +0100 Subject: Always escape the table names when creating the SQL statement Since some databases are case sensitive if part of the query is quoted, then we should ensure that all instances of the table name are escaped unless the test is delibrately testing the non-escaped case. As a result, this commit also removes some expected failures pertaining to PostgreSQL and also adds an entry to the list of tables being dropped when a test is finished. [ChangeLog][Sql][PostgreSQL] QSqlDatabase is now stricter about table names when used with record() and primaryIndex(). If the tablename was not quoted when it was created, then the table name passed to record() and primaryIndex() needs to be in lower case so that PostgreSQL is able to find it. Fixes: QTBUG-65788 Change-Id: Id1f54cb66b761c39edf858501b730ede7eec1fd3 Reviewed-by: Paul Wicking Reviewed-by: Edward Welbourne --- src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/sqldrivers/mysql') diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 80c0c9c522..febbe58506 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -1551,7 +1551,7 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const QSqlQuery i(createResult()); QString stmt(QLatin1String("show index from %1;")); QSqlRecord fil = record(tablename); - i.exec(stmt.arg(tablename)); + i.exec(stmt.arg(escapeIdentifier(tablename, QSqlDriver::TableName))); while (i.isActive() && i.next()) { if (i.value(2).toString() == QLatin1String("PRIMARY")) { idx.append(fil.field(i.value(4).toString())); -- cgit v1.2.3