From 78f7a8c418bc887ebb5bd75f63e35a2b8108f107 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 21 Feb 2023 17:50:21 +0100 Subject: [PATCH] SQL/OCI: Fix QSQLDriver::record() when tablename is a synonym Fix the statement when the tablename is a synonym by not appending the where clause for the table name to the initial statement used for tables and synonyms later on. Pick-to: 6.5 6.4 6.2 5.15 Fixes: QTBUG-111339 Change-Id: Ie18a858427d124e80462048b1a9c5e2afa327546 Reviewed-by: Volker Hilsheimer --- src/plugins/sqldrivers/oci/qsql_oci.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/sqldrivers/oci/qsql_oci.cpp b/src/plugins/sqldrivers/oci/qsql_oci.cpp index b8202a64cca..6d72f7afcc1 100644 --- a/src/plugins/sqldrivers/oci/qsql_oci.cpp +++ b/src/plugins/sqldrivers/oci/qsql_oci.cpp @@ -2563,8 +2563,7 @@ QSqlRecord QOCIDriver::record(const QString& tablename) const // eg. a sub-query on the sys.synonyms table QString stmt("select column_name, data_type, data_length, " "data_precision, data_scale, nullable, data_default%1" - "from all_tab_columns a " - "where a.table_name=%2"_L1); + "from all_tab_columns a "_L1); if (d->serverVersion >= 9) stmt = stmt.arg(", char_length "_L1); else @@ -2578,7 +2577,7 @@ QSqlRecord QOCIDriver::record(const QString& tablename) const else table = table.toUpper(); - tmpStmt = stmt.arg(u'\'' + table + u'\''); + tmpStmt = stmt + "where a.table_name='"_L1 + table + u'\''; if (owner.isEmpty()) { owner = d->user; }