ownSql: create an null value of an empty string in bindValue.

This commit is contained in:
Klaas Freitag 2014-10-16 11:20:50 +02:00
parent 8c7953a47c
commit e51c299937

View file

@ -188,10 +188,15 @@ void SqlQuery::bindValue(int pos, const QVariant& value)
break;
}
case QVariant::String: {
// lifetime of string == lifetime of its qvariant
const QString *str = static_cast<const QString*>(value.constData());
res = sqlite3_bind_text16(_stmt, pos, str->utf16(),
(str->size()) * sizeof(QChar), SQLITE_STATIC);
if( !value.toString().isNull() ) {
// lifetime of string == lifetime of its qvariant
const QString *str = static_cast<const QString*>(value.constData());
res = sqlite3_bind_text16(_stmt, pos, str->utf16(),
(str->size()) * sizeof(QChar), SQLITE_STATIC);
} else {
// unbound value create a null entry.
res = SQLITE_OK;
}
break; }
default: {
QString str = value.toString();