diff --git a/frameworks/C++/cutelyst/build.sh b/frameworks/C++/cutelyst/build.sh index cc9cc8f3c8a..3a77c321e97 100755 --- a/frameworks/C++/cutelyst/build.sh +++ b/frameworks/C++/cutelyst/build.sh @@ -1,8 +1,9 @@ #!/bin/bash -export ASQL_VER=0.74.0 +export ASQL_VER=0.84.0 export CUTELEE_VER=6.1.0 -export CUTELYST_VER=3.7.0 +export CUTELYST_TAG=v4.0.0-alpha1 +export CUTELYST_VER=4.0.0 apt update -qq && \ apt install -yqq --no-install-recommends \ @@ -21,8 +22,8 @@ wget -q https://github.com/cutelyst/cutelee/releases/download/v${CUTELEE_VER}/cu wget -q https://github.com/cutelyst/asql/releases/download/v${ASQL_VER}/libasql0-qt6_${ASQL_VER}_amd64.deb && \ apt install -yqq ./libasql0-qt6_${ASQL_VER}_amd64.deb -wget -q https://github.com/cutelyst/cutelyst/releases/download/v${CUTELYST_VER}/cutelyst3-qt6_${CUTELYST_VER}_amd64.deb && \ - apt install -yqq ./cutelyst3-qt6_${CUTELYST_VER}_amd64.deb +wget -q https://github.com/cutelyst/cutelyst/releases/download/${CUTELYST_TAG}/cutelyst4-qt6_${CUTELYST_VER}_amd64.deb && \ + apt install -yqq ./cutelyst4-qt6_${CUTELYST_VER}_amd64.deb cd ${TROOT} && \ mkdir -p build && \ diff --git a/frameworks/C++/cutelyst/src/CMakeLists.txt b/frameworks/C++/cutelyst/src/CMakeLists.txt index 38e6a06b54f..43a30c3d307 100644 --- a/frameworks/C++/cutelyst/src/CMakeLists.txt +++ b/frameworks/C++/cutelyst/src/CMakeLists.txt @@ -14,8 +14,8 @@ FetchContent_Declare( FetchContent_MakeAvailable(mimalloc) find_package(Qt6 6.2.0 REQUIRED COMPONENTS Core Network Sql) -find_package(ASqlQt6 0.74 REQUIRED) -find_package(Cutelyst3Qt6 3.6 REQUIRED) +find_package(ASqlQt6 0.84 REQUIRED) +find_package(Cutelyst4Qt6 3.6 REQUIRED) find_package(Cutelee6Qt6 6.1.0 REQUIRED) find_package(PostgreSQL REQUIRED) diff --git a/frameworks/C++/cutelyst/src/cachedqueries.cpp b/frameworks/C++/cutelyst/src/cachedqueries.cpp index 650338ea897..5a8d90b64c6 100644 --- a/frameworks/C++/cutelyst/src/cachedqueries.cpp +++ b/frameworks/C++/cutelyst/src/cachedqueries.cpp @@ -20,7 +20,7 @@ CachedQueries::CachedQueries(QObject *parent) void CachedQueries::cached_queries(Context *c) { - int queries = c->request()->queryParam(QStringLiteral("count")).toInt(); + int queries = c->request()->queryParam(u"count"_qs).toInt(); if (queries < 1) { queries = 1; } else if (queries > 500) { @@ -48,8 +48,8 @@ void CachedQueries::cached_queries(Context *c) auto it = result.begin(); int id = it[0].toInt(); auto obj = new QJsonObject({ - {QStringLiteral("id"), id}, - {QStringLiteral("randomNumber"), it[1].toInt()} + {u"id"_qs, id}, + {u"randomNumber"_qs, it[1].toInt()} }); array->append(*obj); cache.insert(id, obj, 1); diff --git a/frameworks/C++/cutelyst/src/cutelyst-benchmarks.cpp b/frameworks/C++/cutelyst/src/cutelyst-benchmarks.cpp index 0cd1300b04e..ff72ac56b1a 100644 --- a/frameworks/C++/cutelyst/src/cutelyst-benchmarks.cpp +++ b/frameworks/C++/cutelyst/src/cutelyst-benchmarks.cpp @@ -40,7 +40,7 @@ cutelyst_benchmarks::~cutelyst_benchmarks() bool cutelyst_benchmarks::init() { - if (config(QStringLiteral("SendDate")).value()) { + if (config(u"SendDate"_qs).value()) { qDebug() << "Manually send date"; auto dateT = new QTimer(this); dateT->setInterval(1000); @@ -63,9 +63,9 @@ bool cutelyst_benchmarks::init() new CachedQueries(this); if (defaultHeaders().server().isEmpty()) { - defaultHeaders().setServer(QStringLiteral("Cutelyst")); + defaultHeaders().setServer("Cutelyst"_qba); } - defaultHeaders().removeHeader(QStringLiteral("X-Cutelyst")); + defaultHeaders().removeHeader("X-Cutelyst"); return true; } @@ -75,48 +75,43 @@ bool cutelyst_benchmarks::postFork() QMutexLocker locker(&mutex); // QSqlDatabase::addDatabase is not thread-safe QSqlDatabase db; - const auto driver = config(QStringLiteral("Driver")).toString(); + const auto driver = config(u"Driver"_qs).toString(); if (driver == u"QPSQL") { - db = QSqlDatabase::addDatabase(driver, Sql::databaseNameThread(QStringLiteral("postgres"))); - db.setDatabaseName(QStringLiteral("hello_world")); - db.setUserName(QStringLiteral("benchmarkdbuser")); - db.setPassword(QStringLiteral("benchmarkdbpass")); - db.setHostName(config(QStringLiteral("DatabaseHostName")).toString()); + db = QSqlDatabase::addDatabase(driver, Sql::databaseNameThread(u"postgres"_qs)); + db.setDatabaseName(u"hello_world"_qs); + db.setUserName(u"benchmarkdbuser"_qs); + db.setPassword(u"benchmarkdbpass"_qs); + db.setHostName(config(u"DatabaseHostName"_qs).toString()); if (!db.open()) { qDebug() << "Error opening PostgreSQL db:" << db << db.connectionName() << db.lastError().databaseText(); return false; } } else if (driver == u"QMYSQL") { - db = QSqlDatabase::addDatabase(driver, Sql::databaseNameThread(QStringLiteral("mysql"))); - db.setDatabaseName(QStringLiteral("hello_world")); - db.setUserName(QStringLiteral("benchmarkdbuser")); - db.setPassword(QStringLiteral("benchmarkdbpass")); - db.setHostName(config(QStringLiteral("DatabaseHostName")).toString()); + db = QSqlDatabase::addDatabase(driver, Sql::databaseNameThread(u"mysql"_qs)); + db.setDatabaseName(u"hello_world"_qs); + db.setUserName(u"benchmarkdbuser"_qs); + db.setPassword(u"benchmarkdbpass"_qs); + db.setHostName(config(u"DatabaseHostName"_qs).toString()); if (!db.open()) { qDebug() << "Error opening MySQL db:" << db << db.connectionName() << db.lastError().databaseText(); return false; } } else if (driver == u"postgres") { - QUrl uri(QStringLiteral("postgresql://benchmarkdbuser:benchmarkdbpass@server/hello_world")); - uri.setHost(config(QStringLiteral("DatabaseHostName")).toString()); + QUrl uri(u"postgresql://benchmarkdbuser:benchmarkdbpass@server/hello_world"_qs); + uri.setHost(config(u"DatabaseHostName"_qs).toString()); qDebug() << "ASql URI:" << uri.toString(); APool::create(ASql::APg::factory(uri.toString())); APool::setMaxIdleConnections(128); - APool::setSetupCallback([](ADatabase &db) { + APool::setSetupCallback([](ADatabase db) { // Enable Pipeline mode db.enterPipelineMode(500); }); } qDebug() << "Connections" << QCoreApplication::applicationPid() << QThread::currentThread() << QSqlDatabase::connectionNames(); -// db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), QLatin1String("sqlite")); -// if (!db.open()) { -// qDebug() << "Error opening db:" << db << db.lastError().databaseText(); -// return false; -// } return true; } -//#include "moc_cutelyst-benchmarks.cpp" +#include "moc_cutelyst-benchmarks.cpp" diff --git a/frameworks/C++/cutelyst/src/databaseupdatestest.cpp b/frameworks/C++/cutelyst/src/databaseupdatestest.cpp index 07a21b90f97..7e3d0ee1f83 100644 --- a/frameworks/C++/cutelyst/src/databaseupdatestest.cpp +++ b/frameworks/C++/cutelyst/src/databaseupdatestest.cpp @@ -25,7 +25,7 @@ DatabaseUpdatesTest::DatabaseUpdatesTest(QObject *parent) : Controller(parent) void DatabaseUpdatesTest::updatep(Context *c) { - int queries = c->request()->queryParam(QStringLiteral("queries"), QStringLiteral("1")).toInt(); + int queries = c->request()->queryParam(u"queries"_qs, u"1"_qs).toInt(); if (queries < 1) { queries = 1; } else if (queries > 500) { @@ -66,7 +66,7 @@ void DatabaseUpdatesTest::updatep(Context *c) void DatabaseUpdatesTest::updateb(Context *c) { - int queries = c->request()->queryParam(QStringLiteral("queries"), QStringLiteral("1")).toInt(); + int queries = c->request()->queryParam(u"queries"_qs, u"1"_qs).toInt(); if (queries < 1) { queries = 1; } else if (queries > 500) { @@ -117,22 +117,22 @@ void DatabaseUpdatesTest::updateb(Context *c) void DatabaseUpdatesTest::updates_postgres(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT id, randomNumber FROM world WHERE id = :id"), - QStringLiteral("postgres")); + u"SELECT id, randomNumber FROM world WHERE id = :id"_qs, + u"postgres"_qs); QSqlQuery updateQuery = CPreparedSqlQueryThreadForDB( - QLatin1String("UPDATE world SET randomNumber = :randomNumber WHERE id = :id"), - QStringLiteral("postgres")); + u"UPDATE world SET randomNumber = :randomNumber WHERE id = :id"_qs, + u"postgres"_qs); processQuery(c, query, updateQuery); } void DatabaseUpdatesTest::updates_mysql(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT randomNumber, id FROM world WHERE id = :id"), - QStringLiteral("mysql")); + u"SELECT randomNumber, id FROM world WHERE id = :id"_qs, + u"mysql"_qs); QSqlQuery updateQuery = CPreparedSqlQueryThreadForDB( - QLatin1String("UPDATE world SET randomNumber = :randomNumber WHERE id = :id"), - QStringLiteral("mysql")); + u"UPDATE world SET randomNumber = :randomNumber WHERE id = :id"_qs, + u"mysql"_qs); processQuery(c, query, updateQuery); } @@ -140,7 +140,7 @@ void DatabaseUpdatesTest::processQuery(Context *c, QSqlQuery &query, QSqlQuery & { QJsonArray array; - int queries = c->request()->queryParam(QStringLiteral("queries"), QStringLiteral("1")).toInt(); + int queries = c->request()->queryParam(u"queries"_qs, u"1"_qs).toInt(); if (queries < 1) { queries = 1; } else if (queries > 500) { @@ -153,7 +153,7 @@ void DatabaseUpdatesTest::processQuery(Context *c, QSqlQuery &query, QSqlQuery & for (int i = 0; i < queries; ++i) { int id = (rand() % 10000) + 1; - query.bindValue(QStringLiteral(":id"), id); + query.bindValue(u":id"_qs, id); if (Q_UNLIKELY(!query.exec() || !query.next())) { c->res()->setStatus(Response::InternalServerError); return; @@ -164,13 +164,13 @@ void DatabaseUpdatesTest::processQuery(Context *c, QSqlQuery &query, QSqlQuery & randomNumbers.append(randomNumber); array.append(QJsonObject{ - {QStringLiteral("id"), id}, - {QStringLiteral("randomNumber"), randomNumber} + {u"id"_qs, id}, + {u"randomNumber"_qs, randomNumber} }); } - updateQuery.bindValue(QStringLiteral(":id"), ids); - updateQuery.bindValue(QStringLiteral(":randomNumber"), randomNumbers); + updateQuery.bindValue(u":id"_qs, ids); + updateQuery.bindValue(u":randomNumber"_qs, randomNumbers); if (Q_LIKELY(updateQuery.execBatch())) { c->response()->setJsonArrayBody(array); } else { @@ -182,24 +182,24 @@ APreparedQuery DatabaseUpdatesTest::getSql(int count) { auto iter = m_sqlMap.find(count); if (Q_UNLIKELY(iter == m_sqlMap.end())) { - QString sql = QStringLiteral("UPDATE WORLD SET randomnumber=CASE id "); + QString sql = u"UPDATE WORLD SET randomnumber=CASE id "_qs; sql.reserve(80 + count * 25); int placeholdersCounter = 1; for (int i = 0; i < count; i++) { - sql.append(QStringLiteral("WHEN $%1 THEN $%2 ").arg(placeholdersCounter).arg(placeholdersCounter + 1)); + sql.append(u"WHEN $%1 THEN $%2 "_qs.arg(placeholdersCounter).arg(placeholdersCounter + 1)); placeholdersCounter += 2; } - sql.append(QStringLiteral("ELSE randomnumber END WHERE id IN (")); + sql.append(u"ELSE randomnumber END WHERE id IN ("); for (int i = 0; i < count; i++) { - sql.append(QLatin1Char('$') + QString::number(placeholdersCounter) + QLatin1Char(',')); + sql.append(u'$' + QString::number(placeholdersCounter) + u','); ++placeholdersCounter; } if (count) { sql.remove(sql.size() - 1, 1); } - sql.append(QLatin1Char(')')); + sql.append(u')'); iter = m_sqlMap.insert(count, APreparedQuery(sql)); } diff --git a/frameworks/C++/cutelyst/src/fortunetest.cpp b/frameworks/C++/cutelyst/src/fortunetest.cpp index 2a1d79cb63a..1661cc3a359 100644 --- a/frameworks/C++/cutelyst/src/fortunetest.cpp +++ b/frameworks/C++/cutelyst/src/fortunetest.cpp @@ -33,7 +33,7 @@ void FortuneTest::fortunes_raw_p(Context *c) fortunes.emplace_back(Fortune{it[0].toInt(), it[1].toString()}); ++it; } - fortunes.emplace_back(Fortune{0, QStringLiteral("Additional fortune added at request time.")}); + fortunes.emplace_back(Fortune{0, u"Additional fortune added at request time."_qs}); std::sort(fortunes.begin(), fortunes.end(), [] (const Fortune &a1, const Fortune &a2) { return a1.message < a2.message; @@ -46,8 +46,8 @@ void FortuneTest::fortunes_raw_p(Context *c) void FortuneTest::fortunes_raw_postgres(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT id, message FROM fortune"), - QStringLiteral("postgres")); + u"SELECT id, message FROM fortune"_qs, + u"postgres"_qs); auto fortunes = processQuery(c, query); renderRaw(c, fortunes); } @@ -55,8 +55,8 @@ void FortuneTest::fortunes_raw_postgres(Context *c) void FortuneTest::fortunes_raw_mysql(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT id, message FROM fortune"), - QStringLiteral("mysql")); + u"SELECT id, message FROM fortune"_qs, + u"mysql"_qs); auto fortunes = processQuery(c, query); renderRaw(c, fortunes); } @@ -82,59 +82,59 @@ void FortuneTest::fortunes_c_p(Context *c) } fortunes.append(QVariant::fromValue(QVariantList{ - {0, QStringLiteral("Additional fortune added at request time.")}, + {0, u"Additional fortune added at request time."_qs}, })); std::sort(fortunes.begin(), fortunes.end(), [] (const QVariant &a1, const QVariant &a2) { return a1.toList()[1].toString() < a2.toList()[1].toString(); }); - c->setStash(QStringLiteral("template"), QStringLiteral("fortunes.html")); - c->setStash(QStringLiteral("fortunes"), fortunes); + c->setStash(u"template"_qs, u"fortunes.html"_qs); + c->setStash(u"fortunes"_qs, fortunes); static thread_local View *view = c->view(); view->execute(c); - c->response()->setContentType(QStringLiteral("text/html; charset=UTF-8")); + c->response()->setContentType("text/html; charset=UTF-8"_qba); }); } void FortuneTest::fortunes_cutelee_postgres(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT id, message FROM fortune"), - QStringLiteral("postgres")); + u"SELECT id, message FROM fortune"_qs, + u"postgres"_qs); if (query.exec()) { QVariantList fortunes = Sql::queryToList(query); fortunes.append(QVariant::fromValue(QVariantList{ - {0, QStringLiteral("Additional fortune added at request time.")}, + {0, u"Additional fortune added at request time."_qs}, })); std::sort(fortunes.begin(), fortunes.end(), [] (const QVariant &a1, const QVariant &a2) { return a1.toList()[1].toString() < a2.toList()[1].toString(); }); - c->setStash(QStringLiteral("template"), QStringLiteral("fortunes.html")); - c->setStash(QStringLiteral("fortunes"), fortunes); + c->setStash(u"template"_qs, u"fortunes.html"_qs); + c->setStash(u"fortunes"_qs, fortunes); static thread_local View *view = c->view(); view->execute(c); - c->response()->setContentType(QStringLiteral("text/html; charset=UTF-8")); + c->response()->setContentType("text/html; charset=UTF-8"_qba); } } void FortuneTest::fortunes_cutelee_mysql(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT id, message FROM fortune"), - QStringLiteral("mysql")); + u"SELECT id, message FROM fortune"_qs, + u"mysql"_qs); if (query.exec()) { QVariantList fortunes = Sql::queryToList(query); fortunes.append(QVariant::fromValue(QVariantList{ - {0, QStringLiteral("Additional fortune added at request time.")}, + {0, u"Additional fortune added at request time."_qs}, })); std::sort(fortunes.begin(), fortunes.end(), [] (const QVariant &a1, const QVariant &a2) { return a1.toList()[1].toString() < a2.toList()[1].toString(); }); - c->setStash(QStringLiteral("template"), QStringLiteral("fortunes.html")); - c->setStash(QStringLiteral("fortunes"), fortunes); + c->setStash(u"template"_qs, u"fortunes.html"_qs); + c->setStash(u"fortunes"_qs, fortunes); static thread_local View *view = c->view(); view->execute(c); - c->response()->setContentType(QStringLiteral("text/html; charset=UTF-8")); + c->response()->setContentType("text/html; charset=UTF-8"_qba); } } @@ -151,7 +151,7 @@ FortuneList FortuneTest::processQuery(Context *c, QSqlQuery &query) while (query.next()) { fortunes.push_back({query.value(0).toInt(), query.value(1).toString()}); } - fortunes.push_back({0, QStringLiteral("Additional fortune added at request time.")}); + fortunes.push_back({0, u"Additional fortune added at request time."_qs}); std::sort(fortunes.begin(), fortunes.end(), [] (const Fortune &a1, const Fortune &a2) { return a1.message < a2.message; @@ -183,5 +183,5 @@ void FortuneTest::renderRaw(Context *c, const FortuneList &fortunes) const auto response = c->response(); response->setBody(out); - response->setContentType(QStringLiteral("text/html; charset=UTF-8")); + response->setContentType("text/html; charset=UTF-8"_qba); } diff --git a/frameworks/C++/cutelyst/src/jsontest.cpp b/frameworks/C++/cutelyst/src/jsontest.cpp index d30dab8bd43..da3ce3619bc 100644 --- a/frameworks/C++/cutelyst/src/jsontest.cpp +++ b/frameworks/C++/cutelyst/src/jsontest.cpp @@ -12,7 +12,7 @@ JsonTest::JsonTest(QObject *parent) : Controller(parent) void JsonTest::json(Context *c) { - c->response()->setJsonObjectBody({ {QStringLiteral("message"), QStringLiteral("Hello, World!")} }); + c->response()->setJsonObjectBody({ {u"message"_qs, u"Hello, World!"_qs} }); } void JsonTest::pson(Context *c) diff --git a/frameworks/C++/cutelyst/src/multipledatabasequeriestest.cpp b/frameworks/C++/cutelyst/src/multipledatabasequeriestest.cpp index 50960101b06..a032c15f69b 100644 --- a/frameworks/C++/cutelyst/src/multipledatabasequeriestest.cpp +++ b/frameworks/C++/cutelyst/src/multipledatabasequeriestest.cpp @@ -21,7 +21,7 @@ MultipleDatabaseQueriesTest::MultipleDatabaseQueriesTest(QObject *parent) : Cont void MultipleDatabaseQueriesTest::queriesp(Context *c) { - int queries = c->request()->queryParam(QStringLiteral("queries")).toInt(); + int queries = c->request()->queryParam(u"queries"_qs).toInt(); if (queries < 1) { queries = 1; } else if (queries > 500) { @@ -39,8 +39,8 @@ void MultipleDatabaseQueriesTest::queriesp(Context *c) if (Q_LIKELY(!result.error() && result.size())) { auto it = result.begin(); array->append(QJsonObject{ - {QStringLiteral("id"), it[0].toInt()}, - {QStringLiteral("randomNumber"), it[1].toInt()} + {u"id"_qs, it[0].toInt()}, + {u"randomNumber"_qs, it[1].toInt()} }); if (i + 1 == queries) { @@ -57,16 +57,16 @@ void MultipleDatabaseQueriesTest::queriesp(Context *c) void MultipleDatabaseQueriesTest::query_postgres(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT id, randomNumber FROM world WHERE id = :id"), - QStringLiteral("postgres")); + u"SELECT id, randomNumber FROM world WHERE id = :id"_qs, + u"postgres"_qs); processQuery(c, query); } void MultipleDatabaseQueriesTest::query_mysql(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT id, randomNumber FROM world WHERE id = :id"), - QStringLiteral("mysql")); + u"SELECT id, randomNumber FROM world WHERE id = :id"_qs, + u"mysql"_qs); processQuery(c, query); } @@ -74,7 +74,7 @@ void MultipleDatabaseQueriesTest::processQuery(Context *c, QSqlQuery &query) { QJsonArray array; - int queries = c->request()->queryParam(QStringLiteral("queries")).toInt(); + int queries = c->request()->queryParam(u"queries"_qs).toInt(); if (queries < 1) { queries = 1; } else if (queries > 500) { @@ -84,11 +84,11 @@ void MultipleDatabaseQueriesTest::processQuery(Context *c, QSqlQuery &query) for (int i = 0; i < queries; ++i) { const int id = (rand() % 10000) + 1; - query.bindValue(QStringLiteral(":id"), id); + query.bindValue(u":id"_qs, id); if (Q_LIKELY(query.exec() && query.next())) { array.append(QJsonObject{ - {QStringLiteral("id"), query.value(0).toInt()}, - {QStringLiteral("randomNumber"), query.value(1).toInt()} + {u"id"_qs, query.value(0).toInt()}, + {u"randomNumber"_qs, query.value(1).toInt()} }); } else { c->res()->setStatus(Response::InternalServerError); diff --git a/frameworks/C++/cutelyst/src/plaintexttest.cpp b/frameworks/C++/cutelyst/src/plaintexttest.cpp index 770ba9ae6b4..d9f2afb259b 100644 --- a/frameworks/C++/cutelyst/src/plaintexttest.cpp +++ b/frameworks/C++/cutelyst/src/plaintexttest.cpp @@ -8,6 +8,6 @@ PlaintextTest::PlaintextTest(QObject *parent) : Controller(parent) void PlaintextTest::plaintext(Context *c) { Response *res = c->response(); - res->setBody(QByteArrayLiteral("Hello, World!")); - res->setContentType(QStringLiteral("text/plain")); + res->setBody("Hello, World!"_qba); + res->setContentType("text/plain"_qba); } diff --git a/frameworks/C++/cutelyst/src/singledatabasequerytest.cpp b/frameworks/C++/cutelyst/src/singledatabasequerytest.cpp index 7c610305adb..3b1d3e5836f 100644 --- a/frameworks/C++/cutelyst/src/singledatabasequerytest.cpp +++ b/frameworks/C++/cutelyst/src/singledatabasequerytest.cpp @@ -76,16 +76,16 @@ void SingleDatabaseQueryTest::db_asql_pipeline_pg(Context *c) void SingleDatabaseQueryTest::db_postgres(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT id, randomNumber FROM world WHERE id = :id"), - QStringLiteral("postgres")); + u"SELECT id, randomNumber FROM world WHERE id = :id"_qs, + u"postgres"_qs); processQuery(c, query); } void SingleDatabaseQueryTest::db_mysql(Context *c) { QSqlQuery query = CPreparedSqlQueryThreadForDB( - QLatin1String("SELECT id, randomNumber FROM world WHERE id = :id"), - QStringLiteral("mysql")); + u"SELECT id, randomNumber FROM world WHERE id = :id"_qs, + u"mysql"_qs); processQuery(c, query); } @@ -93,14 +93,14 @@ void SingleDatabaseQueryTest::processQuery(Context *c, QSqlQuery &query) { int id = (rand() % 10000) + 1; - query.bindValue(QStringLiteral(":id"), id); + query.bindValue(u":id"_qs, id); if (Q_UNLIKELY(!query.exec() || !query.next())) { c->res()->setStatus(Response::InternalServerError); return; } c->response()->setJsonObjectBody({ - {QStringLiteral("id"), query.value(0).toInt()}, - {QStringLiteral("randomNumber"), query.value(1).toInt()} + {u"id"_qs, query.value(0).toInt()}, + {u"randomNumber"_qs, query.value(1).toInt()} }); }