From 999d856bc8569455c21850dc524a595e6b6f52b6 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 22 Dec 2021 15:09:23 +0100 Subject: Adapt SQL drivers to Qt 6 change of QVariant::isNull In Qt 5, QVariant::isNull returned true if either the variant didn't contain a value, or if the value was of a nullable type where the type's isNull member function returned true. In Qt 6, QVariant::isNull only returns true for variants that don't contain a value; if the value contained is e.g. a null-QString or QDateTime, then QVariant::isNull returns false. This change requires a follow up in the SQL drivers, which must still treat null-values the same as null-variants, lest they write data into the data base. Add a static helper to QSqlResultPrivate that implements isNull-checking of variants that contain a nullable type relevant for Sql, and add a test case to the QSqlQuery test that exercises that code. Pick-to: 6.2 6.3 Fixes: QTBUG-99408 Fixes: QTBUG-98471 Change-Id: I08b74a33aa3235c37d974f182da1f2bdcfd8217e Reviewed-by: Fabian Kosmale --- src/plugins/sqldrivers/ibase/qsql_ibase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/sqldrivers/ibase/qsql_ibase.cpp') diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp index ba820a4416..d8cb3ae5f3 100644 --- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp +++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp @@ -968,7 +968,7 @@ bool QIBaseResult::exec() setAt(QSql::BeforeFirstRow); if (d->inda) { - QList& values = boundValues(); + const QList &values = boundValues(); int i; if (values.count() > d->inda->sqld) { qWarning() << QLatin1String("QIBaseResult::exec: Parameter mismatch, expected") << @@ -984,7 +984,7 @@ bool QIBaseResult::exec() continue; const QVariant val(values[i]); if (d->inda->sqlvar[para].sqltype & 1) { - if (val.isNull()) { + if (QSqlResultPrivate::isVariantNull(val)) { // set null indicator *(d->inda->sqlvar[para].sqlind) = -1; // and set the value to 0, otherwise it would count as empty string. -- cgit v1.2.3