diff options
author | Christian Ehrlicher <[email protected]> | 2025-03-27 21:02:13 +0100 |
---|---|---|
committer | Christian Ehrlicher <[email protected]> | 2025-03-31 20:40:12 +0200 |
commit | 219e9fe7a2312538635aaf1c0bc79b98df21723e (patch) | |
tree | 8bfdb335fb69f1aa92262da039bdedfce5beb33b /src/plugins/sqldrivers/mysql/qsql_mysql.cpp | |
parent | 06ef995a7d348c9769091b07e4511c3c9511a104 (diff) |
SQL/MySQL: use utc datetime in formatValue()
We store timestamps as utc in the database but QSqlDriver::formatValue()
does not format the datetime string as utc. Fix it by converting the
datetime object to utc first.
This amends 2781c3b6248fe4410a7afffd41bad72d8567fc95
Pick-to: 6.9 6.8
Fixes: QTBUG-135135
Change-Id: Id26b251e9ed9800d6caff7f43de25fd9e9b08f43
Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'src/plugins/sqldrivers/mysql/qsql_mysql.cpp')
-rw-r--r-- | src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 7e04a20da5b..e87435b38c2 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -1614,7 +1614,7 @@ QString QMYSQLDriver::formatValue(const QSqlField &field, bool trimStrings) cons } Q_FALLTHROUGH(); case QMetaType::QDateTime: - if (QDateTime dt = field.value().toDateTime(); dt.isValid()) { + if (QDateTime dt = field.value().toDateTime().toUTC(); dt.isValid()) { // MySQL format doesn't like the "Z" at the end, but does allow // "+00:00" starting in version 8.0.19. However, if we got here, // it's because the MySQL server is too old for prepared queries |