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 <volker.hilsheimer@qt.io>
This commit is contained in:
Christian Ehrlicher 2023-02-21 17:50:21 +01:00
parent e69d80e14d
commit 78f7a8c418

View File

@ -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;
}