Closed akvus closed 2 months ago
Interesting situation. Thanks for bringing it up. I'm not sure if there is a good way to obtain the correct error while keeping the migration logic. Feel free to open a PR if you experiment a possible fix. There is a test suite related to SQLCipher in the example folder. One of the tests opens a v3 database, so it should be easy to add another test case for when the password is incorrect and check for the correct error message.
@akvus Hello! I've just published a new version of the package that doesn't hide the original exception. Thanks for reporting!
Thank you @davidmartos96!
(Android)
openDatabase
can fail for many reasons. The current implementation catches the original exception and tries to open the database again withPRAGMA cipher_migrate;
. When this call fails, then we receive an error"SQL logic error: , while compiling: select count(*) from sqlite_master;"
which is caused by the migration not working, while that's not the problem. The problem may be an incorrect password. However, we will never know that in Flutter, because the original exception was swallowed.See https://github.com/davidmartos96/sqflite_sqlcipher/blob/e6dc64dfdb67d427b6c490f971778552ce93aa04/sqflite/android/src/main/java/com/davidmartos96/sqflite_sqlcipher/Database.java#L71C10-L71C10