diff --git a/platform/qt/src/sqlite3.cpp b/platform/qt/src/sqlite3.cpp index f5e5f7a69..1d1894636 100644 --- a/platform/qt/src/sqlite3.cpp +++ b/platform/qt/src/sqlite3.cpp @@ -305,18 +305,19 @@ void Statement::bindBlob(int offset, const std::vector& value, bool ret bool Statement::run() { assert(impl); - if (impl->query.isValid()) { - return impl->query.next(); + if (!impl->query.isValid()) { + if (impl->query.exec()) { + impl->lastInsertRowId = impl->query.lastInsertId().value(); + impl->changes = impl->query.numRowsAffected(); + } else { + checkQueryError(impl->query); + } } - if (!impl->query.exec()) { - checkQueryError(impl->query); - } + const bool hasNext = impl->query.next(); + if (!hasNext) impl->query.finish(); - impl->lastInsertRowId = impl->query.lastInsertId().value(); - impl->changes = impl->query.numRowsAffected(); - - return impl->query.next(); + return hasNext; } template bool Statement::get(int);