eclarkso
12th November 2009, 18:18
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/qsqldatatype-table.html#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:
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?
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.
http://doc.trolltech.com/4.5/qsqldatatype-table.html#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:
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?
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.