From ba019b025681fc6f623ab07f62488b509f10bb4a Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 23 Feb 2018 11:16:41 +0100 Subject: [PATCH] [qt] Fix issue if resources not being found on the database Once again QVariant getting confused about its contents datatype. With this patch we use QString directly and copy the contents, which should be cheap with Qt implicity sharing. --- platform/qt/src/sqlite3.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/platform/qt/src/sqlite3.cpp b/platform/qt/src/sqlite3.cpp index 80efd6a32..eb4a79804 100644 --- a/platform/qt/src/sqlite3.cpp +++ b/platform/qt/src/sqlite3.cpp @@ -270,20 +270,15 @@ void Statement::bind(int offset, optional value) { } } -void Statement::bind(int offset, const char* value, std::size_t length, bool retain) { +void Statement::bind(int offset, const char* value, std::size_t length, bool /* retain */) { assert(impl); if (length > std::numeric_limits::max()) { // Kept for consistence with the default implementation. throw std::range_error("value too long"); } - // Qt SQLite driver treats QByteArray as blob: we need to explicitly - // declare the variant type as string. - QVariant text(QVariant::Type::String); - text.setValue(retain ? QByteArray(value, length) : QByteArray::fromRawData(value, length)); - // Field numbering starts at 0. - impl->query.bindValue(offset - 1, std::move(text), QSql::In); + impl->query.bindValue(offset - 1, QString(QByteArray(value, length)), QSql::In); checkQueryError(impl->query); }