diff options
author | Bill King <bill.king@nokia.com> | 2009-09-30 05:26:42 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-09-30 05:26:42 (GMT) |
commit | 9a7624ce5c4f78f89408eb0d9a33b1cd1569eb3c (patch) | |
tree | 771281c7f24cec04104a0483f237f8f22c46bf3a /src/sql/drivers | |
parent | 7e979a9a0330a533bbe1693ba68d3737af664a77 (diff) | |
download | Qt-9a7624ce5c4f78f89408eb0d9a33b1cd1569eb3c.zip Qt-9a7624ce5c4f78f89408eb0d9a33b1cd1569eb3c.tar.gz Qt-9a7624ce5c4f78f89408eb0d9a33b1cd1569eb3c.tar.bz2 |
(TDS) Fixes missing field/table name escaping.
Diffstat (limited to 'src/sql/drivers')
-rw-r--r-- | src/sql/drivers/tds/qsql_tds.cpp | 11 | ||||
-rw-r--r-- | src/sql/drivers/tds/qsql_tds.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/sql/drivers/tds/qsql_tds.cpp b/src/sql/drivers/tds/qsql_tds.cpp index 005905b..dddc1b4 100644 --- a/src/sql/drivers/tds/qsql_tds.cpp +++ b/src/sql/drivers/tds/qsql_tds.cpp @@ -794,4 +794,15 @@ QSqlIndex QTDSDriver::primaryIndex(const QString& tablename) const return idx; } +QString QTDSDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const +{ + QString res = identifier; + if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) { + res.replace(QLatin1Char('"'), QLatin1String("\"\"")); + res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); + res.replace(QLatin1Char('.'), QLatin1String("\".\"")); + } + return res; +} + QT_END_NAMESPACE diff --git a/src/sql/drivers/tds/qsql_tds.h b/src/sql/drivers/tds/qsql_tds.h index 6001106..0ceae6d 100644 --- a/src/sql/drivers/tds/qsql_tds.h +++ b/src/sql/drivers/tds/qsql_tds.h @@ -116,6 +116,8 @@ public: bool trimStrings) const; QVariant handle() const; + QString escapeIdentifier(const QString &identifier, IdentifierType type) const; + protected: bool beginTransaction(); bool commitTransaction(); |