summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql/kernel
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-03-27 21:20:43 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-07-08 00:08:44 +0200
commit4b7b5edf26b895932d0bee2d3315989c41c2d283 (patch)
treeda4b7ff71c73684e809ae518d4c00262a44ec430 /tests/auto/sql/kernel
parent98e4e992fee5152912852fb686fa3a9e546853f2 (diff)
SQL/SQLite: add case folding for non-ascii characters
SQLite does not provide a proper case folding for non-ascii characters due to a lack of a proper ICU library. Therefore add an option so Qt can do it for SQLite. [ChangeLog][SQL][SQLite] Add new option QSQLITE_ENABLE_NON_ASCII_CASE_FOLDING for correct case folding of non-ascii characters. Fixes: QTBUG-18871 Change-Id: Ib62fedf750f05e50a581604253cf30d81e367b42 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/sql/kernel')
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_databases.h4
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp15
2 files changed, 17 insertions, 2 deletions
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
index 0debe5d549..87efdb4441 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
@@ -118,12 +118,14 @@ public:
if (port > 0)
cName += QLatin1Char(':') + QString::number(port);
+ QString opts = params;
if (driver == "QSQLITE") {
// Since the database for sqlite is generated at runtime it's always
// available, but we use QTempDir so it's always in a different
// location. Thus, let's ignore the path completely.
cName = "SQLite";
qInfo("SQLite will use the database located at %ls", qUtf16Printable(dbName));
+ opts += QStringLiteral(";QSQLITE_ENABLE_NON_ASCII_CASE_FOLDING");
}
auto db = QSqlDatabase::addDatabase(driver, cName);
@@ -137,7 +139,7 @@ public:
db.setPassword(passwd);
db.setHostName(host);
db.setPort(port);
- db.setConnectOptions(params);
+ db.setConnectOptions(opts);
dbNames.append(cName);
}
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 7ab17802b9..6f471cb55e 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -4454,7 +4454,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
.arg(tableName)));
QVERIFY_SQL(q, exec("SELECT MAX(txt) FROM " + tableName));
- QVERIFY(q.next());
+ QVERIFY_SQL(q, next());
if (dbType == QSqlDriver::SQLite)
QCOMPARE(q.record().field(0).metaType().id(), QMetaType::UnknownType);
else
@@ -4469,6 +4469,19 @@ void tst_QSqlQuery::aggregateFunctionTypes()
QVERIFY(q.next());
QCOMPARE(q.value(0).toString(), QLatin1String("upper"));
QCOMPARE(q.record().field(0).metaType().id(), QMetaType::QString);
+
+ QVERIFY_SQL(q, exec(QLatin1String("DELETE FROM %1").arg(tableName)));
+ QVERIFY_SQL(q, exec(QString::fromUtf8("INSERT INTO %1 (id, txt) VALUES (1, 'löW€RÄ')")
+ .arg(tableName)));
+ QVERIFY_SQL(q, exec("SELECT LOWER(txt) FROM " + tableName));
+ QVERIFY(q.next());
+ QCOMPARE(q.value(0).toString(), QString::fromUtf8("löw€rä"));
+ QCOMPARE(q.record().field(0).metaType().id(), QMetaType::QString);
+
+ QVERIFY_SQL(q, exec("SELECT UPPER(txt) FROM " + tableName));
+ QVERIFY(q.next());
+ QCOMPARE(q.value(0).toString(), QString::fromUtf8("LÖW€RÄ"));
+ QCOMPARE(q.record().field(0).metaType().id(), QMetaType::QString);
}
}