QIbaseResult: qWarning, when disallowed null parameter becomes zero

QIbaseResult turns null into zero when database field doesn't
accept a null argument.

This patch adds a warning in that case. It would be better to return
with an error, but that breaks existing behavior with code relying on
it.

Fixes: QTBUG-114683
Change-Id: Ib50b7b6b4dd6c51489ba8b355f7baa8b1b14dc15
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit a7deddba519fc1f6fd637496e92ca5daccf6d453)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Axel Spoerl 2023-07-03 16:01:25 +02:00 committed by Qt Cherry-pick Bot
parent c1f6fbdd4e
commit dcef040b9d

View File

@ -1051,6 +1051,9 @@ bool QIBaseResult::exec()
} }
// a value of 0 means non-null. // a value of 0 means non-null.
*(d->inda->sqlvar[para].sqlind) = 0; *(d->inda->sqlvar[para].sqlind) = 0;
} else {
qWarning() << "QIBaseResult::exec: Null value replaced by zero for"_L1
<< d->inda->sqlvar[para].ownname;
} }
switch(d->inda->sqlvar[para].sqltype & ~1) { switch(d->inda->sqlvar[para].sqltype & ~1) {
case SQL_INT64: case SQL_INT64: