Hello! I'm playing with SQLDelight + Kotlin Multip...
# kotlin-native
a
Hello! I'm playing with SQLDelight + Kotlin Multiplatform + iOS, and trying to create a test in-memory database for unit tests. I'm using the following code:
Copy code
TodoDatabase(
        NativeSqliteDriver(
            DatabaseConfiguration(
                name = "",
                version = 1,
                create = { wrapConnection(it, TodoDatabase.Schema::create) },
                inMemory = true
            )
        )
    )
I added some logs and it seems that it actually executes Schema.create. However all queries to this database in tests are failing with errors like
no such table
. Also I see the following message in the logs: Invalid connection:
com.apple.coresymbolicationd
. Not sure if it is related actually. Could somebody give me some advice?
k
Not sure. We have a similar setup in KaMP Kit. The only meaningful differences are db name and version coming from schema, but I'm not sure the version would matter (it's presumably 1). In-memory and db name may be an issue, but I honestly don't recall off hand: https://github.com/touchlab/KaMPKit/blob/master/shared/src/iosTest/kotlin/co/touchlab/kampkit/TestUtilIOS.kt
a
Thanks! I will check.
r
I think the upgrade lambda might be necessary but it's been a long time since I've done anything beyond copy/pasting that config
a
I could not find the
upgrade
function, but I will double check. Thank you!
b
Upgrade lambda is definitely needed. also, make sure your sqlite has SQLITE_USE_URI enabled: https://sqlite.org/uri.html
🙏 1
a
Ok, turned out that the database name must not be an empty string. Thank you all for the hints!
113 Views