Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
6.8.0
-
None
-
-
8ebf6dcd12937e9f74f5a6379338acc4bcd7efd6
Description
I have my application that reads from the DB. It was always working up to 6.8.0.
When it reads a datetime from my postgresql DB, it returns an invalid QDateTime.
I was able to recreate it with the attached program (of course you need to adapt the connection to your db cluster.
It seems to be on columns that are defined as "timestamp with time zone". Simple timestamps work just fine.
This is a fix that worked for me:
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 7b9521f..f802a2e 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -652,7 +652,7 @@ QVariant QPSQLResult::data(int i) return QVariant(QTime::fromString(QString::fromLatin1(val), Qt::ISODate)); case QMetaType::QDateTime: { QString tzString(QString::fromLatin1(val)); - if (!tzString.endsWith(u'Z')) + if (ptype != QTIMESTAMPTZOID && !tzString.endsWith(u'Z')) tzString.append(u'Z'); // make UTC return QVariant(QDateTime::fromString(tzString, Qt::ISODate)); }