brodycj / cordova-sqlite-ext

A Cordova/PhoneGap plugin to open and use sqlite databases on Android/iOS/macOS/Windows with REGEXP (Android/macOS/iOS) and pre-populated databases (Android/iOS/macOS/Windows)
Other
72 stars 55 forks source link

Query with RENAME breaks on Android 8, 9 and 10, but only with new versions #95

Open CRTCTY opened 2 years ago

CRTCTY commented 2 years ago

I was tasked with getting an older cordova app to work. It used cordova-sqlite-ext 2.3.0 and worked up until Android 11. After that the DB did not start due to:

java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String io.liteglue.SQLDatabaseHandle.getLastErrorMessage()' on a null object reference

A similar issue exists in the cordova-sqlite-storage repo, it is storesafe/cordova-sqlite-storage#995 and can apparently be solved by updating to a newer version.

I decided to do that and updated to the latest cordova-sqlite-ext version, 6.0.0 and the DB started to work on Android 12 devices. (it seems that any version >= 4.0.0 works).

However, this broke compatibility with Android 8 devices. On those a previously working query:

ALTER TABLE "<name of the table>" RENAME COLUMN <name of the column> TO <new name>;

now fails with a SQLiteException:

(near "COLUMN": syntax error (code 1): , while compiling: ALTER TABLE "<name of the table>" RENAME COLUMN <name of the column> TO <new name>;)

I have not touched this query and it definitely worked fine before updating. The only thing I could find about this up to now was that maybe the RENAME keyword is not supported? Which does not really make sense since it used to work?

CRTCTY commented 2 years ago

I also managed to recreate the error on a Samsung Galaxy S8 with Android 9.0 and a Samsung Galaxy S9 with Android 10.0. A Samsung Galaxy S20 with Android 11.0 worked fine.