diff options
Diffstat (limited to 'src/sql/kernel')
-rw-r--r-- | src/sql/kernel/qsqldriver.cpp | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlfield.cpp | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index c8a16c8..bbec21d 100644 --- a/src/sql/kernel/qsqldriver.cpp +++ b/src/sql/kernel/qsqldriver.cpp @@ -496,7 +496,7 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName, s.append(QLatin1String("UPDATE ")).append(tableName).append( QLatin1String(" SET ")); for (i = 0; i < rec.count(); ++i) { - if (!rec.isGenerated(i) || !rec.value(i).isValid()) + if (!rec.isGenerated(i)) continue; s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1Char('=')); if (preparedStatement) @@ -517,7 +517,7 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName, s.append(QLatin1String("INSERT INTO ")).append(tableName).append(QLatin1String(" (")); QString vals; for (i = 0; i < rec.count(); ++i) { - if (!rec.isGenerated(i) || !rec.value(i).isValid()) + if (!rec.isGenerated(i)) continue; s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1String(", ")); if (preparedStatement) diff --git a/src/sql/kernel/qsqlfield.cpp b/src/sql/kernel/qsqlfield.cpp index a1ab9e3..b7e58b7 100644 --- a/src/sql/kernel/qsqlfield.cpp +++ b/src/sql/kernel/qsqlfield.cpp @@ -162,6 +162,7 @@ public: QSqlField::QSqlField(const QString& fieldName, QVariant::Type type) { d = new QSqlFieldPrivate(fieldName, type); + val = QVariant(type); } /*! @@ -389,6 +390,8 @@ void QSqlField::setType(QVariant::Type type) { detach(); d->type = type; + if (!val.isValid()) + val = QVariant(type); } |