summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill King <bill.king@nokia.com>2009-08-13 05:06:41 (GMT)
committerBill King <bill.king@nokia.com>2009-08-13 05:14:02 (GMT)
commit1070d82e13c43accf10ef24d5bbb82d681c1cf4f (patch)
tree9810f8292a465d723cce2a106aec3bb00669c014
parentf4a2451421994cacf5ae79f242f5cdb37ebdd87c (diff)
downloadQt-1070d82e13c43accf10ef24d5bbb82d681c1cf4f.zip
Qt-1070d82e13c43accf10ef24d5bbb82d681c1cf4f.tar.gz
Qt-1070d82e13c43accf10ef24d5bbb82d681c1cf4f.tar.bz2
Fixes proper quoting under odbc.
Query the database for the quoting charachter, don't assume you know what it is. Reviewed-by: Justin McPherson
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 8eb2e15..6a8609e 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -2400,18 +2400,12 @@ QVariant QODBCDriver::handle() const
QString QODBCDriver::escapeIdentifier(const QString &identifier, IdentifierType) const
{
+ QChar quote = d->quoteChar();
QString res = identifier;
- if (d->isMySqlServer) {
- if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('`')) && !identifier.endsWith(QLatin1Char('`')) ) {
- res.prepend(QLatin1Char('`')).append(QLatin1Char('`'));
- res.replace(QLatin1Char('.'), QLatin1String("`.`"));
- }
- } else {
- if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) {
- res.replace(QLatin1Char('"'), QLatin1String("\"\""));
- res.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
- res.replace(QLatin1Char('.'), QLatin1String("\".\""));
- }
+ if(!identifier.isEmpty() && !identifier.startsWith(quote) && !identifier.endsWith(quote) ) {
+ res.replace(quote, QString(quote)+QString(quote));
+ res.prepend(quote).append(quote);
+ res.replace(QLatin1Char('.'), QString(quote)+QLatin1Char('.')+QString(quote));
}
return res;
}