27

SQLite Android status · Issue #578 · JetBrains/Exposed · GitHub

 4 years ago
source link: https://github.com/JetBrains/Exposed/issues/578
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Join GitHub today

GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.

Sign up

SQLite Android status #578

lamba92 opened this issue on Jun 12, 2019 · 2 comments

Comments

lamba92 commented on Jun 12, 2019

edited

I may be mistaken but, no JDBC driver works for SQLite on Android, which means no SQLite Exposed on Android.

Here's a list of issues related to that problem:

SQLDroid is out of question since the jdbc postfix is not one of the registered here, unless adding something like:

registerDialect(SqlDroidDialect.dialectName) { MysqlDialect() }

Anybody has a solution so far? I was happy to try Exposed on Android as well to replace Room but so far no success cry

Digging a little deep I noticed that the problem resides in the metadata.url in the Database class here. metadata.url returns null instead of the actual URL and since everything is evaluated lazily the error message gets a little confused. This happens with the SQLDroid drivers as well and I was not able to figure out why confused

Contributor

Tapac commented on Jun 12, 2019

@lamba92 Do you have any suggestion about how I could test Exposed against android sqlite?

Author

lamba92 commented on Jun 12, 2019

edited

I'd say a Gradle module with the Android plugin. You can launch an activity and initialize something like this:

class CacheTransactionManagerImpl @Inject constructor(val context: Context) : CacheTransactionManager {

    private val database by lazy {
        Database.connectSQLite(File(context.cacheDir, "localCache.sqlite").absolutePath)
                .also {
                    serializableTransaction(it) { SchemaUtils.createMissingTablesAndColumns(...) }
                }
    }

    override fun <T> execute(block: Transaction.() -> T) = serializableTransaction(database, function = block)

}

You can either provide a context using DI or just creating it during execution.

As soon as some R/W operation occurs, all the lazy variables will be triggered until metadata.url is requested, returns null and Kotlin throws NPE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Linked pull requests

Successfully merging a pull request may close this issue.

None yet

2 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK