Results 1 to 2 of 2

Thread: QVariant not returning proper type for SQLite REAL

  1. #1
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default QVariant not returning proper type for SQLite REAL

    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:
    Attached Images Attached Images

  2. #2
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: QVariant not returning proper type for SQLite REAL

    This is a bug in QT, in qsql_sqlite.cpp

    Qt Code:
    1. static QVariant::Type qGetColumnType(const QString &tpName)
    2. {
    3. const QString typeName = tpName.toLower();
    4.  
    5. if (typeName == QLatin1String("integer")
    6. || typeName == QLatin1String("int"))
    7. return QVariant::Int;
    8. if (typeName == QLatin1String("double")
    9. || typeName == QLatin1String("float")
    10. || typeName.startsWith(QLatin1String("numeric")))
    11. return QVariant::Double;
    12. if (typeName == QLatin1String("blob"))
    13. return QVariant::ByteArray;
    14. return QVariant::String;
    15. }
    To copy to clipboard, switch view to plain text mode 

    It does not account for REAL, although according to the sql documentation, float and doubles are not types, only real is.
    http://www.sqlite.org/datatype3.html

Similar Threads

  1. Convert between a custom data type wrapped in a QVariant
    By darkadept in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 09:07
  2. QVariant custom/user type comparison
    By gri in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2008, 14:36
  3. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.