qtquick2ubuntu-touch

db.changeVersion doesn't work as expected


I'm trying to upgrade a DB in an app for Ubuntu Touch. I use QtQuick.LocalStorage 2.0.

When I call db.changeVersion it works, but db.version doesn't change until app restarts.

db.changeVersion(db.version, "2", function(tx){...}); // Update database to version 2
console.log(db.version); //Should return "2", instead returns previous version of database

How can have the new db.version without restart the app?


Solution

  • This has been recently fixed in Qt. The changeVersion function will now return a new db object which has the version field updated.

    https://bugreports.qt.io/browse/QTBUG-71838

    Previous Qt versions required the user to reopen the database to see the updated version, as evidenced by the test code:

    http://code.qt.io/cgit/qt/qtdeclarative.git/tree/tests/auto/qml/qqmlsqldatabase/data/changeversion.js