Results 1 to 3 of 3

Thread: QtSql data type mappings

  1. #1
    Join Date
    Oct 2009
    Location
    Atlanta, GA, USA
    Posts
    8
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QtSql data type mappings

    In debugging my DB-driven application, I happened on this documentation page talking about how DB data types are mapped into QVariant flavors.

    http://doc.trolltech.com/4.5/qsqldat...odbc-data-type

    Notably, I was surprised to find (for ODBC, which I am using, but also for other drivers) that 32/64bit float/double DB types are mapped "by default" to QString's! So my questions are thus:

    1. What is the reasoning behind this? I would think to avoid precision loss--but IEEE 754 double's are guaranteed to be 64bit. So why not use double's instead of QString?
    2. The docs explicitly says "by default" w/r/t to this mapping. Does that imply I can alter this mapping, and if so, how? Unfortunately, I don't see anything obvious in any of the likely QtSql classes (QSqlDatabase; QSqlDriver).


    I was surprised cursory google didn't reveal answers to either query. Appreciate any insights.

  2. #2
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QtSql data type mappings

    Having the same problem. Is I notice that behavior easy to change with the patch in Qt ODBC driver. So I did

    P.S. This is my own patch and I think it will never go upstream though.

  3. #3
    Join Date
    Oct 2009
    Location
    Atlanta, GA, USA
    Posts
    8
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtSql data type mappings

    This issue popped up again debugging some code and I just noticed the reply as well.

    The only update I have is an increased suspicion that the reasoning *may* be a loss-of-precision thing. Despite the IEEE 754 usage, a while back I was having funny behavior with high-precision numbers losing a digit when I did the QString>double conversion. IIRC, this only happened when 1) there were many (16 or 17 I'm guessing?) digits and 2) all digits were in the fractional part (e.g., 0.12435678901234567).

    I didn't investigate this very thoroughly because other factors made the issue moot, but perhaps this will help someone (or stoke someone to look into it... maybe I will sometime later).

Similar Threads

  1. Data type parameters.
    By vinny gracindo in forum Newbie
    Replies: 1
    Last Post: 28th October 2009, 09:00
  2. 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
  3. Data type error
    By MrShahi in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 14:01
  4. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  5. dummy question(Error)
    By Masih in forum Qt Programming
    Replies: 12
    Last Post: 19th July 2007, 23:38

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.