From 1070d82e13c43accf10ef24d5bbb82d681c1cf4f Mon Sep 17 00:00:00 2001
From: Bill King <bill.king@nokia.com>
Date: Thu, 13 Aug 2009 15:06:41 +1000
Subject: Fixes proper quoting under odbc.

Query the database for the quoting charachter, don't assume you know
what it is.

Reviewed-by: Justin McPherson
---
 src/sql/drivers/odbc/qsql_odbc.cpp | 16 +++++-----------
 1 file 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;
 }
-- 
cgit v0.12