Help needed using changeVersion
-
Hi all,
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:
https://gist.github.com/hoelzro/9021552
Here's the helper routine I wrote:
https://github.com/hoelzro/harbour-sudoku/blob/db-upgrade/qml/pages/SudokuBoard.qml#L126
I tried this with a standalone example using qmlscene and was able to duplicate the behavior. Here's the QML file I wrote:
https://gist.github.com/hoelzro/9021573
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?
Thanks,
Rob -
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.