SQL/PostgreSQL: fix comment for formatting QDateTime
The comment to convert a QDateTime to a PostgreSQL compatible string was outdated. Adjust it to the current state and make clear that the PostgreSQL documentation is unclear here. Task-number: QTBUG-129983 Change-Id: I46e45082f2154881ab34278c5e9887cb2274dd64 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit d6a7e51fa36c51a39c609ff0b2cd8bc10bd01e86) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
97d342f0c4
commit
df1118b4e0
@ -1454,9 +1454,9 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
|
||||
case QMetaType::QDateTime: {
|
||||
const auto dt = field.value().toDateTime();
|
||||
if (dt.isValid()) {
|
||||
// we force the value to be considered with a timezone information, and we force it to be UTC
|
||||
// this is safe since postgresql stores only the UTC value and not the timezone offset (only used
|
||||
// while parsing), so we have correct behavior in both case of with timezone and without tz
|
||||
// even though the documentation (https://www.postgresql.org/docs/current/datatype-datetime.html)
|
||||
// states that any time zone indication for 'timestamp without tz' columns will be ignored,
|
||||
// it is stored as the correct utc timestamp - so we can pass the utc offset here
|
||||
r = QStringLiteral("TIMESTAMP WITH TIME ZONE ") + u'\'' +
|
||||
dt.toOffsetFromUtc(dt.offsetFromUtc()).toString(Qt::ISODateWithMs) + u'\'';
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user