Skip to content

Commit 3f60f44

Browse files
In TSqlObject, modified to set NULL into DB when the value is QString()
1 parent 48771cc commit 3f60f44

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/tsqlquery.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ QString TSqlQuery::formatValue(const QVariant &val, const QMetaType &type, const
163163
QSqlField field(QStringLiteral("dummy"), metaType);
164164
if (type.id() == QMetaType::Char || type.id() == QMetaType::UChar) {
165165
field.setValue(val.toInt()); // forced cast to int
166+
} else if (type.id() == QMetaType::QString) {
167+
QString str = val.toString();
168+
if (str.isNull()) {
169+
field.clear(); // sets it to NULL
170+
} else {
171+
field.setValue(val);
172+
}
166173
} else {
167174
field.setValue(val);
168175
}

0 commit comments

Comments
 (0)