diff options
author | Bill King <bill.king@nokia.com> | 2009-06-22 01:26:29 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-06-22 02:00:48 (GMT) |
commit | 24d0bee8de27fb148a12efa21d973f4c45e216d0 (patch) | |
tree | 701dc82487ca45fabea07c3f3c4a7329093491b5 /src/sql/drivers/ibase | |
parent | fbe1e69584746e6255b6ea6fede9080c96f5d4e2 (diff) | |
download | Qt-24d0bee8de27fb148a12efa21d973f4c45e216d0.zip Qt-24d0bee8de27fb148a12efa21d973f4c45e216d0.tar.gz Qt-24d0bee8de27fb148a12efa21d973f4c45e216d0.tar.bz2 |
Fix the behaviour of sql classes regarding quoted identifiers
If no quotes around identifiers are provided by the programmer,
identifiers are treated identically to how the underlying engine
would behave. i.e. some engines uppercase the identifiers
others lowercase them. If the programmer wants case sensitivty
and/or use whitespaces they will need to quote their identifiers.
The previous (incorrect) behaviour always quoted the identifiers.
Originally committed to 4.5, but removed due to BC concerns, this
is a reintegration into mainline for inclusion in 4.6
Reviewed-by: Bill King
Diffstat (limited to 'src/sql/drivers/ibase')
-rw-r--r-- | src/sql/drivers/ibase/qsql_ibase.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index 259a247..d714327 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -1592,12 +1592,16 @@ QSqlRecord QIBaseDriver::record(const QString& tablename) const 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(QLatin1String("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 " "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE " - "AND a.RDB$RELATION_NAME = '") + tablename.toUpper() + QLatin1String("' " + "AND a.RDB$RELATION_NAME = '") + table + QLatin1String("' " "ORDER BY a.RDB$FIELD_POSITION")); while (q.next()) { @@ -1625,12 +1629,18 @@ 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(); + QSqlQuery q(createResult()); q.setForwardOnly(true); q.exec(QLatin1String("SELECT a.RDB$INDEX_NAME, b.RDB$FIELD_NAME, d.RDB$FIELD_TYPE, d.RDB$FIELD_SCALE " "FROM RDB$RELATION_CONSTRAINTS a, RDB$INDEX_SEGMENTS b, RDB$RELATION_FIELDS c, RDB$FIELDS d " "WHERE a.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' " - "AND a.RDB$RELATION_NAME = '") + table.toUpper() + + "AND a.RDB$RELATION_NAME = '") + tablename + QLatin1String(" 'AND a.RDB$INDEX_NAME = b.RDB$INDEX_NAME " "AND c.RDB$RELATION_NAME = a.RDB$RELATION_NAME " "AND c.RDB$FIELD_NAME = b.RDB$FIELD_NAME " |