diff options
author | Derick Hawcroft <derick.hawcroft@nokia.com> | 2009-07-07 23:20:31 (GMT) |
---|---|---|
committer | Derick Hawcroft <derick.hawcroft@nokia.com> | 2009-07-07 23:31:41 (GMT) |
commit | e5049ecc4590896a75dedcb098da9e991e1764ee (patch) | |
tree | 82687d8f1269c3b1d463b578436650737dc79684 /src/sql | |
parent | f37bd111f7622a34b3a7bd63f5a82f6042dc0f0d (diff) | |
download | Qt-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.cpp | 17 |
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; |