Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.4.0
-
916af48cff66e0acbeb6da39997498ce3b9626ce (qtbase/5.5, 18.2.2015, 5.5.0)
Description
Inserting NaN value to a PostgrSQL database requires apostrophes around it. QPSQL doesn't add those and the insertion fails with
QSqlError("42703", "QPSQL: Unable to create query", "ERROR: column "nan" does not exist
LINE 1: EXECUTE qpsqlpstmt_1 (nan)
This problem has been fixed for double type in https://bugreports.qt.io/browse/QTBUG-3088. Equal check in QPSQLDriver::formatValue() for float type would do the trick, which leads to another minor "problem" that QSqlField.type is QVariant::Type, which doesn't have the float type.
Tested with following code snippet:
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL"); db.setDatabaseName("postgres"); QSqlQuery query; query.exec("create table foo (id int primary key, " "bar float)"); query.prepare("insert into foo values(1, :fValue)"); query.bindValue(":fValue", static_cast<float>(qQNaN())); qDebug() << query.lastError() << query.exec();