View Full Version : QVariant not returning proper type for SQLite REAL

15th September 2009, 19:51
I setup a table with columns that use type REAL, such as "TimestampNumeric" When I query this table using model.record().field(columnIndex).type the QVariant type is 10, which is String. This is incorrect, it should be returning QVariant::Double.

This does work correctly with SQLite type INT however.

Within C++, if I use "PRAGMA table_info(tableName);" as a query on SQLite, it returns REAL as it obviously should.

See the screenshots for this bug:

15th September 2009, 21:25
This is a bug in QT, in qsql_sqlite.cpp

static QVariant::Type qGetColumnType(const QString &tpName)
const QString typeName = tpName.toLower();

if (typeName == QLatin1String("integer")
|| typeName == QLatin1String("int"))
return QVariant::Int;
if (typeName == QLatin1String("double")
|| typeName == QLatin1String("float")
|| typeName.startsWith(QLatin1String("numeric")))
return QVariant::Double;
if (typeName == QLatin1String("blob"))
return QVariant::ByteArray;
return QVariant::String;

It does not account for REAL, although according to the sql documentation, float and doubles are not types, only real is.