Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
4.6.3
-
None
-
kubuntu 10.04
g++ 4.2.4
PostgreSQL 8.4
Description
The bug occurs in QSqlTableModelPrivate::exec().
When the prepared statement contains a NULL value for some field, for example :
DELETE FROM aTable WHERE "id" = ? AND "field1" = ? AND "field2" IS NULL AND "field3" = ?
Then this leads to a SQL error like :
ERROR: wrong number of parameters for prepared statement "qpsqlpstmt_1" DETAIL: Expected 3 parameters but got 4
The problem is located in qsqltablemodel.cpp, line 204 :
204 if (rec.isGenerated(i) && rec.value(i).type() != QVariant::Invalid)
205 editQuery.addBindValue(rec.value(i));
"rec.value( i )" can be a valid NULL QVariant (like QVariant(QVariant::Int)), and in this case line 205 is executed (which should not).