Open AlecKazakova opened 5 years ago
Hmm. You can use an in memory db with a param, and the name is used so you can have more than one distinct in memory db but also have multiple connections to it. Will think about config more, though.
An auto-generated name could be used under the hood when passing null
as the name, so every new call creates a database with a different name that won't clash with other instances.
Example generated name: in_memory_database_1
where the number is taken from a Long
that auto-increments.
Just got hit by this. Looks like passing DatabaseConfiguration.inMemory = true
and DatabaseConfiguration.name = null
is invalid? All my statements fail compilation with this (while it's ok if I pass en actual name). Maybe just throw in that case?
It's not invalid to sqliter, but may be in the context of the sqldelight driver. The basic difference is sqlite lets you create an in memory db with multiple connections using a shared memory cache with a name( "file:${configuration.name}?mode=memory&cache=shared"
). However, that needs to be managed and deleted like any other db or it'll just accumulate. Probably not an issue in most cases, but not ideal either.
A null name creates a connection like you'd usually expect for in memory, but it can only have one connection. The sqldelight driver and sqliter's feature sets probably drifted independently. Will need to actually solve for this. For now, add a name and delete when done.
specifically the
name
property ofDatabaseConfiguration
should be nullable, and when null should mean the created SQLite db is in memory