summaryrefslogtreecommitdiffstats
path: root/src/sql/kernel
diff options
context:
space:
mode:
authorBill King <bill.king@nokia.com>2009-04-06 05:49:40 (GMT)
committerBill King <bill.king@nokia.com>2009-04-06 21:41:32 (GMT)
commit948de0dc991e324cdfb01f2e84a6aadfbf8d737f (patch)
tree3263897da20472e38732f12146b7900cd62f2129 /src/sql/kernel
parent041a8ecdb5f11dfc499f8f8f77d85cb63508c093 (diff)
downloadQt-948de0dc991e324cdfb01f2e84a6aadfbf8d737f.zip
Qt-948de0dc991e324cdfb01f2e84a6aadfbf8d737f.tar.gz
Qt-948de0dc991e324cdfb01f2e84a6aadfbf8d737f.tar.bz2
Fixes: QSqlTableModel does not handle updates when one of the fields has
a NULL value Task-number: 189093
Diffstat (limited to 'src/sql/kernel')
-rw-r--r--src/sql/kernel/qsqldriver.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index ddebe45..a995005 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -406,9 +406,14 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
break;
case WhereStatement:
if (preparedStatement) {
- for (int i = 0; i < rec.count(); ++i)
- s.append(escapeIdentifier(rec.fieldName(i), FieldName)).append(
- QLatin1String(" = ? AND "));
+ for (int i = 0; i < rec.count(); ++i) {
+ s.append(escapeIdentifier(rec.fieldName(i), FieldName));
+ if (rec.isNull(i))
+ s.append(QLatin1String(" IS NULL"));
+ else
+ s.append(QLatin1String(" = ?"));
+ s.append(QLatin1String(" AND "));
+ }
} else {
for (i = 0; i < rec.count(); ++i) {
s.append(escapeIdentifier(rec.fieldName(i), FieldName));