Daniele B
09/19/2023, 4:36 PMinternal val localDb by lazy { LocalDb(sqlDriver) }
and now it seems I need to do this way:
internal val localDb by lazy { LocalDb(sqlDriver, Countries.Adapter(IntColumnAdapter,IntColumnAdapter,IntColumnAdapter)) }
because I have 3 integers, which for some reason require an adapter.
Wasn't it possible to implicitly avoid such verbose definition?jw
09/19/2023, 4:38 PMDaniele B
09/19/2023, 4:39 PMimport <http://kotlin.Int|kotlin.Int>;
import kotlin.Boolean;
CREATE TABLE Countries (
name TEXT NOT NULL PRIMARY KEY,
population INTEGER AS Int NOT NULL,
first_doses INTEGER AS Int NOT NULL,
fully_vaccinated INTEGER AS Int NOT NULL,
favorite INTEGER AS Boolean NOT NULL DEFAULT 0
);
This is what got generated:
public data class Countries(
public val name: String,
public val population: Int,
public val first_doses: Int,
public val fully_vaccinated: Int,
public val favorite: Boolean,
) {
public class Adapter(
public val populationAdapter: ColumnAdapter<Int, Long>,
public val first_dosesAdapter: ColumnAdapter<Int, Long>,
public val fully_vaccinatedAdapter: ColumnAdapter<Int, Long>,
)
}
public operator fun invoke(driver: SqlDriver, CountriesAdapter: Countries.Adapter): LocalDb =
LocalDb::class.newInstance(driver, CountriesAdapter)
jw
09/19/2023, 5:41 PMDaniele B
09/19/2023, 5:55 PMpublic operator fun invoke(driver: SqlDriver): LocalDb {
val adapter = Countries.Adapter(IntColumnAdapter,IntColumnAdapter, IntColumnAdapter)
return LocalDb::class.newInstance(driver, adapter)
}
jw
09/19/2023, 5:56 PMDaniele B
09/19/2023, 6:02 PM