ctripcorp / SQLlin

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

Uncaught Kotlin exception: com.ctrip.sqllin.driver.SQLiteResultCode: error rawExecSql: PRAGMA user_version = 1;, attempt to write a readonly database | error code SQLITE_READONLY #53

Closed nbransby closed 8 months ago

nbransby commented 8 months ago

Got a new issue now - are you calling PRAGMA user_version = 1 internally in SQLlin somewhere?

nbransby commented 8 months ago

im guessing its here https://github.com/ctripcorp/SQLlin/blob/776e1f995259e36086d97bc4c578cf17ad9ca006/sqllin-driver/src/commonMain/kotlin/com/ctrip/sqllin/driver/Extension.kt#L99C1-L100C1

nbransby commented 8 months ago

And then thrown from here https://github.com/ctripcorp/SQLlin/blob/776e1f995259e36086d97bc4c578cf17ad9ca006/sqllin-driver/src/nativeMain/kotlin/com/ctrip/sqllin/driver/ExtensionNative.kt#L46

qiaoyuang commented 8 months ago

Okay, I will look at this issue today.

qiaoyuang commented 8 months ago

I think this is a reasonable behavior. If users use read-only mode, they should ensure the value of DatabaseConfiguration.version same with the value in database file. So, I would add a separate check for this situation and throw an IllegalArgumentException with the related message.

nbransby commented 8 months ago

Does that number have to be greater than 0?

qiaoyuang commented 8 months ago

Yes, if we create a new database, usually set the version is 1.

nbransby commented 8 months ago

OK great thanks

qiaoyuang commented 8 months ago

You're welcome