Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.8.2
-
None
Description
When writing a QDateTime in a DATETIME sql field (in a MySQL datatbase) QMYSQLDriver::formatValue returns a string like that
r = u'\'' + dt.date().toString(Qt::ISODate) + u'T' + dt.time().toString(Qt::ISODate) + u'\'';
and QMYSQLResult::data reads it like that
return QDateTime(date, time, QTimeZone::UTC);
Assuming it is always stored in UTC.
However, if a localTime is passed to the formatValue method (for instance QDateTime(2025-03-25 11:14:25.000 CET Qt::LocalTime)) it is stored in this format "2025-03-25T11:14:25". But when it is retrived with a SELECT, it is returned as QDateTime(2025-03-25 11:14:25.000 UTC Qt::UTC)
Edit: I know that in the docs https://doc.qt.io/qt-6/sql-driver.html#timestamp-support it says it is normal, but since MySQL does not store any timezone information, the retrieved data should not be assumed to be UTC
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-135135 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
635278,5 | SQL/MySQL: use utc datetime in formatValue() | dev | qt/qtbase | Status: INTEGRATING | +2 | 0 |