Misleading QSqlField type of MYSQL database
-
Hi all,
I have a QSqlDatabase connection to a MySQL database. I retrieve the table qsqlrecord and when checking the column types (through QSqlField) i find out that a MySQL TIME column type is mapped to a QString type. Taking into consideration this documentation https://doc.qt.io/qt-5/sql-types.html i was expecting a QTime type. For DATE and DATETIME is working properly. Is there a issue with qsqlfield or am i seeing something wrong?I am getting the same issue for using ODBC driver to connect a sql server database. In this case REAL type is converted to Int type, and DATE/TIME to QString. Are this type of convertion not reliable?
Thanks in advance,
Davide -
For mysql see the comment in the source code:
case FIELD_TYPE_TIME : // A time field can be within the range '-838:59:59' to '838:59:59' so // use QString instead of QTime since QTime is limited to 24 hour clock type = QMetaType::QString; break;
For ODBC blame your ODBC driver vendor: https://code.woboq.org/qt5/qtbase/src/plugins/sqldrivers/odbc/qsql_odbc.cpp.html#383
-