summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorDerick Hawcroft <derick.hawcroft@nokia.com>2009-07-07 23:20:31 (GMT)
committerDerick Hawcroft <derick.hawcroft@nokia.com>2009-07-07 23:31:41 (GMT)
commite5049ecc4590896a75dedcb098da9e991e1764ee (patch)
tree82687d8f1269c3b1d463b578436650737dc79684 /src/sql
parentf37bd111f7622a34b3a7bd63f5a82f6042dc0f0d (diff)
downloadQt-e5049ecc4590896a75dedcb098da9e991e1764ee.zip
Qt-e5049ecc4590896a75dedcb098da9e991e1764ee.tar.gz
Qt-e5049ecc4590896a75dedcb098da9e991e1764ee.tar.bz2
Handle special number cases (nan,{+-}infinity) in PostgreSQL
When contructing the EXECUTE statement, there is a special case that we need to handle whereby we explicitly put quotes around the special float values before submutting the statement for execution Task-number:233829 Reviewed-by: Bill King
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index 69697da..64b2a23 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -54,6 +54,8 @@
#include <qstringlist.h>
#include <qmutex.h>
+#include <qdebug.h>
+
#include <libpq-fe.h>
#include <pg_config.h>
@@ -1144,6 +1146,21 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
qPQfreemem(data);
break;
}
+ case QVariant::Double: {
+ double val = field.value().toDouble();
+ if (isnan(val))
+ r = QLatin1String("'NaN'");
+ else {
+ int res = isinf(val);
+ if (res == 1)
+ r = QLatin1String("'Infinity'");
+ else if (res == -1)
+ r = QLatin1String("'-Infinity'");
+ else
+ r = QSqlDriver::formatValue(field, trimStrings);
+ }
+ break;
+ }
default:
r = QSqlDriver::formatValue(field, trimStrings);
break;