Help needed using changeVersion
I'm working on adding new features to a Qt app I wrote (https://github.com/hoelzro/harbour-sudoku), and one of the features requires a schema change. I wrote a helper routine to detect a storage version mismatch and call changeVersion if needed, but Qt gives me some less-than-helpful output:
Here's the helper routine I wrote:
I tried this with a standalone example using qmlscene and was able to duplicate the behavior. Here's the QML file I wrote:
After looking at the code for the local storage module, it seems that the database connection is cached by QSqlDatabase, but then the routine exits in failure before setting the database name. So when there's a version mismatch, it becomes impossible (I think) to open a connection to that database.
Am I using the changeVersion API completely wrong, or is this a bug? If the latter, what sort of workaround could I use?
So I figured out a solution to my problem. Unfortunately, it relies on undocumented behavior in the LocalStorage module, but it gets the job done. If you specify an empty string for the version, no version check is done; the database is simply opened.