diff options
author | Liang Qi <liang.qi@qt.io> | 2016-06-13 09:04:09 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-06-13 19:06:06 +0200 |
commit | 4d2f743baaf6869693f4540df668e1b998154785 (patch) | |
tree | ba712b420e5d299be28faf641d30585ae8dce4e7 /src/imports/localstorage/plugin.cpp | |
parent | 0c5a9ff9876cb1af53317720d1de8baae003e21d (diff) | |
parent | 0932a59971f606f07b41da19f3974d51b7008180 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
Change-Id: I26d6435a29cac3840bb567ade5149c2562a94bf9
Diffstat (limited to 'src/imports/localstorage/plugin.cpp')
-rw-r--r-- | src/imports/localstorage/plugin.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 3fd36f3f0d..a619030100 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -270,6 +270,15 @@ static ReturnedValue qmlsqldatabase_rows_item(CallContext *ctx) return qmlsqldatabase_rows_index(r, scope.engine, ctx->argc() ? ctx->args()[0].toUInt32() : 0); } +static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValue &value) +{ + // toVariant() maps a null JS value to QVariant(VoidStar), but the SQL module + // expects a null variant. (this is because of QTBUG-40880) + if (value->isNull()) + return QVariant(); + return engine->toVariant(value, /*typehint*/-1); +} + static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) { QV4::Scope scope(ctx); @@ -300,8 +309,9 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) ScopedArrayObject array(scope, values); quint32 size = array->getLength(); QV4::ScopedValue v(scope); - for (quint32 ii = 0; ii < size; ++ii) - query.bindValue(ii, scope.engine->toVariant((v = array->getIndexed(ii)), -1)); + for (quint32 ii = 0; ii < size; ++ii) { + query.bindValue(ii, toSqlVariant(scope.engine, (v = array->getIndexed(ii)))); + } } else if (values->as<Object>()) { ScopedObject object(scope, values); ObjectIterator it(scope, object, ObjectIterator::WithProtoChain|ObjectIterator::EnumerableOnly); @@ -311,7 +321,7 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) key = it.nextPropertyName(val); if (key->isNull()) break; - QVariant v = scope.engine->toVariant(val, -1); + QVariant v = toSqlVariant(scope.engine, val); if (key->isString()) { query.bindValue(key->stringValue()->toQString(), v); } else { @@ -320,7 +330,7 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) } } } else { - query.bindValue(0, scope.engine->toVariant(values, -1)); + query.bindValue(0, toSqlVariant(scope.engine, values)); } } if (query.exec()) { |