[Qt-interest] Formatting Boolean values for databases
Jason H
scorp1us at yahoo.com
Sun May 29 13:29:02 CEST 2011
I've played ignorant of true and false and i thin for SQLite I do get "true" or
"false". It's been some time though But everything in SQLite is a string...
----- Original Message ----
From: Robert Hairgrove <evorgriahr at hispeed.ch>
To: "qt-interest at qt.nokia.com" <qt-interest at qt.nokia.com>
Sent: Sun, May 29, 2011 6:58:19 AM
Subject: [Qt-interest] Formatting Boolean values for databases
In the Qt source code for the function QSqlDriver::formatValue(), I
noticed that the default behavior is to translate Boolean values to 1
and 0:
switch (field.type()) {
case QVariant::Int:
case QVariant::UInt:
if (field.value().type() == QVariant::Bool)
r = field.value().toBool() ? QLatin1String("1") :
QLatin1String("0");
else
r = field.value().toString();
break;
I was wondering why the strings "TRUE" and "FALSE" are not returned
instead? This would work with databases which implement Boolean values
differently -- for example, MS-Access uses -1 and 0, but its SQL engine
still understands the literal strings "TRUE" and "FALSE".
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list