qt6-bb10/src/sql/kernel
Edward Welbourne dcd87049bb Treat invalid Q(Date)?Time as null when used as an SQL value
In Qt 5, QVariant::isNull() was true when the contained object had an
isNull() that was true; this is no longer true in Qt 6, so we now have
QSqlResultPrivate::isVariantNull() to test is-or-contains
null. However, for date-times, QSqlDriver::formatValue() treats
invalid QDateTime as NULL, since it needs its toString(Qt::ISODate),
which will be empty if invalid. As QDateTime's isValid() is more
stringent than its !isNull(), this can lead to one that's neither
valid nor null, such as QDateTime(QDate(), QTime(0, 0)), producing an
invalid entry in a database.

Do the same for QTime, as its isValid() is more stringent than
!isNull(), and its toString() likewise returns empty on invalid
(although it's not clear it's possible to construct one that's neither
valid nor null). For QDate valid and null are simply complementary.

[ChangeLog][QSql] Handling of QDateTime and QTime values passed to SQL
now consistently treats invalid as null. Some values of these types
are neither valid nor null, which could lead to invalid data being
given to the SQL database. Invalid values are now treated as null to
prevent this.

Task-number: QTBUG-98471
Pick-to: 6.3
Change-Id: I145411280d6bcc53dc0dc5f4a1cb938d995fd6bc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-21 20:37:28 +01:00
..
qsql.qdoc Unify license header usage. 2016-03-29 10:20:03 +00:00
qsqlcachedresult.cpp Adjust code format, add space after 'if' 2020-11-16 12:53:37 +00:00
qsqlcachedresult_p.h Use QList instead of QVector in sql 2020-06-25 07:54:21 +02:00
qsqldatabase.cpp QSql/QSqlite: return extended error codes by default 2021-01-11 19:55:43 +01:00
qsqldatabase.h Add overload of QSqlDatabase::cloneDatabase to allow cloning cross threads 2018-12-23 11:41:36 +00:00
qsqldriver.cpp Deprecate QVariant::Type uses in QSqlField 2020-08-15 10:56:33 +02:00
qsqldriver.h Introduce maximumIdentifierLength to return database limits for names 2020-08-11 22:13:13 +02:00
qsqldriver_p.h QtSql: cleanup QSqlDriverPrivate and QSqlResultPrivate 2020-02-19 06:50:21 +01:00
qsqldriverplugin.cpp
qsqldriverplugin.h Replace Q_NULLPTR with nullptr where possible 2017-09-19 11:53:55 +00:00
qsqlerror.cpp QSqlError: protect against self-assignment 2021-03-17 17:22:08 +01:00
qsqlerror.h QSqlError: Remove unused members, kept for binary compatibility 2020-08-30 03:22:31 +02:00
qsqlfield.cpp Doc: Ensure deprecated APIs in Qt Sql are documented as such 2021-07-22 07:08:56 +02:00
qsqlfield.h Deprecate QVariant::Type 2020-10-23 09:58:57 +02:00
qsqlindex.cpp Inline the size and begin pointer in QVector 2019-12-08 18:19:38 +01:00
qsqlindex.h Use QList instead of QVector in qtbase 2020-07-07 11:48:45 +02:00
qsqlnulldriver_p.h Replace Q_DECL_OVERRIDE with override where possible 2017-09-19 11:53:42 +00:00
qsqlquery.cpp Check for null driver() before trying to exec() 2022-01-25 16:18:35 +01:00
qsqlquery.h QSqlQuery: make it a move only type 2021-03-21 10:16:56 +01:00
qsqlrecord.cpp Use QList instead of QVector in qtbase 2020-07-07 11:48:45 +02:00
qsqlrecord.h Make QStringList an alias to QList<QString> 2020-09-12 23:37:15 +02:00
qsqlresult.cpp Treat invalid Q(Date)?Time as null when used as an SQL value 2022-02-21 20:37:28 +01:00
qsqlresult.h Use QList instead of QVector in sql 2020-06-25 07:54:21 +02:00
qsqlresult_p.h Adapt SQL drivers to Qt 6 change of QVariant::isNull 2022-01-12 17:41:07 +01:00
qtsqlglobal.h Migrate to autogenerated cpp exports 2021-06-25 19:33:12 +02:00
qtsqlglobal_p.h Sql: Add a feature for the SQL item models 2018-02-20 09:09:01 +00:00