Details
-
Suggestion
-
Resolution: Incomplete
-
P3: Somewhat important
-
None
-
4.8.4, 5.0.1
-
None
Description
We're using this patch to support UTF-16 CaseInsensitive comparisons. Would be nice, if you'd add this to Qt 5
Index: qsql_sqlite.cpp
===================================================================
— qsql_sqlite.cpp (Revision 166)
+++ qsql_sqlite.cpp (Revision 167)
@@ -31,6 +31,7 @@
#include <qstringlist.h>
#include <qvector.h>
#include <qdebug.h>
+#include <qchar.h>
#if defined Q_OS_WIN
- include <qt_windows.h>
@@ -520,6 +521,22 @@
return false;
}
+static int sqlite_compare_utf16( void* /arg/,int size1, const void str1, int size2, const void str2)
+
+
+static int sqlite_compare_utf16ci( void* /arg/,int size1, const void str1, int size2, const void str2)
+
+
/*
SQLite dbs have no user name, passwords, hosts or ports.
just file names.
@@ -551,7 +568,28 @@
if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL) == SQLITE_OK) {
sqlite3_busy_timeout(d->access, timeOut);
- setOpen(true);
+
+ int res = SQLITE_OK;
+
+ // add UTF16 collation (comparison is performed by QString functions)
+ res = sqlite3_create_collation(d->access, "UTF16", SQLITE_UTF16, 0, sqlite_compare_utf16);
+ if (res != SQLITE_OK) { + setLastError(qMakeError(d->access, tr("Error opening database"), + QSqlError::ConnectionError, res)); + setOpenError(true); + return false; + }+
{ + setLastError(qMakeError(d->access, tr("Error opening database"), + QSqlError::ConnectionError, res)); + setOpenError(true); + return false; + }
+ // add UTF16CI (case insensitive) collation (comparison is performed by QString functions)
+ res = sqlite3_create_collation(d->access, "UTF16CI", SQLITE_UTF16, 0, sqlite_compare_utf16ci);
+ if (res != SQLITE_OK)+
+ setOpen(true);
setOpenError(false);
return true;
} else {