ctripcorp / SQLlin

A DSL ORM library for Kotlin Multiplatform.
Apache License 2.0
219 stars 10 forks source link

use SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE to retry when SQLITE_OPEN_READWRITE fails on native platforms. #51

Closed nbransby closed 8 months ago

qiaoyuang commented 8 months ago

Hi, I have seen your commits. But, after your modification, if a user set isReadOnly = true, he will get a writable database on Android, and a read-only database on the native platform. If it has the big difference on different platforms, I don't think that is a good idea.

And, I don't understand if I set isReadOnly = false, why the code would try to open the database twice with the same flags(sqliteCreateFlags).

nbransby commented 8 months ago

Good points, what about now? Sorry I am doing all these edits in the GitHub web editor - you'll definitely want to squash when merging!

qiaoyuang commented 8 months ago

Yeah, It's OK. Let's run a round workflow.

nbransby commented 8 months ago

@qiaoyuang are you able to create a new release today? We need the fix asap, otherwise we'll try and publish one internally

qiaoyuang commented 8 months ago

Yes, I am planning to do this. Do you mind me updating the Kotlin version to 1.9.10 in this release version?

nbransby commented 8 months ago

Great, yes thats fine, we are already using 1.9.10

On Wed, 18 Oct 2023 at 12:10, Yuang Qiao @.***> wrote:

Yes, I am planning to do this. Do you mind me updating the Kotlin version to 1.9.10 in this release version?

— Reply to this email directly, view it on GitHub https://github.com/ctripcorp/SQLlin/pull/51#issuecomment-1767606264, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKSQ37ONLFU3RRVEBDWS23X75JEHAVCNFSM6AAAAAA6DJZYESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRXGYYDMMRWGQ . You are receiving this because you authored the thread.Message ID: @.***>

qiaoyuang commented 8 months ago

Hi, @nbransby. I submitted a PR for this new release. I commented out these code in NativeDatabase:

if ((sqliteFlags and SQLITE_OPEN_READWRITE > 0) && sqlite3_db_readonly(db, null) != 0) {
       sqlite3_close_v2(db)
       throw sqliteException("Could not open the database in read/write mode")
}

Because, I think we should return a read-only database object to users when OS ban the writing permission or the situation of full disk. So, we don't check whether the database is writable anymore. You can review my code in there. And, I also fix the format of code.