SQL/IBASE: Always escape the table names when creating the SQL statement
Sync the IBASE driver behavior for primaryIndex() and record() with the rest by assuming that the given table name has the correct casing. Change the tests for these two function to pass an unescaped table name. Change-Id: I6d96359f97e1acc6970b9a22fdf0e968a616b7bc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
f5aa8317d0
commit
ca7e3bcf91
@ -1700,13 +1700,9 @@ QSqlRecord QIBaseDriver::record(const QString& tablename) const
|
||||
if (!isOpen())
|
||||
return rec;
|
||||
|
||||
const QString table = stripDelimiters(tablename, QSqlDriver::TableName);
|
||||
QSqlQuery q(createResult());
|
||||
q.setForwardOnly(true);
|
||||
QString table = tablename;
|
||||
if (isIdentifierEscaped(table, QSqlDriver::TableName))
|
||||
table = stripDelimiters(table, QSqlDriver::TableName);
|
||||
else
|
||||
table = table.toUpper();
|
||||
q.exec("SELECT a.RDB$FIELD_NAME, b.RDB$FIELD_TYPE, b.RDB$FIELD_LENGTH, "
|
||||
"b.RDB$FIELD_SCALE, b.RDB$FIELD_PRECISION, a.RDB$NULL_FLAG "
|
||||
"FROM RDB$RELATION_FIELDS a, RDB$FIELDS b "
|
||||
@ -1739,12 +1735,7 @@ QSqlIndex QIBaseDriver::primaryIndex(const QString &table) const
|
||||
if (!isOpen())
|
||||
return index;
|
||||
|
||||
QString tablename = table;
|
||||
if (isIdentifierEscaped(tablename, QSqlDriver::TableName))
|
||||
tablename = stripDelimiters(tablename, QSqlDriver::TableName);
|
||||
else
|
||||
tablename = tablename.toUpper();
|
||||
|
||||
const QString tablename = stripDelimiters(table, QSqlDriver::TableName);
|
||||
QSqlQuery q(createResult());
|
||||
q.setForwardOnly(true);
|
||||
q.exec("SELECT a.RDB$INDEX_NAME, b.RDB$FIELD_NAME, d.RDB$FIELD_TYPE, d.RDB$FIELD_SCALE "
|
||||
|
@ -112,7 +112,7 @@ void tst_QSqlDriver::record()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QString tablename(qTableName("relTEST1", __FILE__, db));
|
||||
QString tablename(qTableName("relTEST1", __FILE__, db, false));
|
||||
QStringList fields;
|
||||
fields << "id" << "name" << "title_key" << "another_title_key" << "more_data";
|
||||
|
||||
@ -171,7 +171,7 @@ void tst_QSqlDriver::primaryIndex()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QString tablename(qTableName("relTEST1", __FILE__, db));
|
||||
QString tablename(qTableName("relTEST1", __FILE__, db, false));
|
||||
//check that we can get primary index using unquoted mixed case table name
|
||||
QSqlIndex index = db.driver()->primaryIndex(tablename);
|
||||
QCOMPARE(index.count(), 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user