SQL/ODBC: convert QVariant to QDateTime only once

... instead three times in a row.

Pick-to: 6.7
Change-Id: If08b4c092cfb5b7d224f9a94afb7d395ce2b2eca
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
bb10
Christian Ehrlicher 2024-01-21 17:21:38 +01:00
parent 2ec2c54e05
commit efd6786e52
1 changed files with 4 additions and 3 deletions

View File

@ -2529,9 +2529,10 @@ QString QODBCDriver::formatValue(const QSqlField &field,
r = "NULL"_L1;
} else if (field.metaType().id() == QMetaType::QDateTime) {
// Use an escape sequence for the datetime fields
if (field.value().toDateTime().isValid()){
QDate dt = field.value().toDateTime().date();
QTime tm = field.value().toDateTime().time();
const QDateTime dateTime = field.value().toDateTime();
if (dateTime.isValid()) {
const QDate dt = dateTime.date();
const QTime tm = dateTime.time();
// Dateformat has to be "yyyy-MM-dd hh:mm:ss", with leading zeroes if month or day < 10
r = "{ ts '"_L1 +
QString::number(dt.year()) + u'-' +