From 73b2c8ae9af46a7a4d1d3290d4b6b61856aa3064 Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Fri, 2 Oct 2026 23:48:43 +0200 Subject: [PATCH] feat(ios): give Room a way to construct the database without reflection `MantraDatabaseConstructor` has been in commonMain all along -- `expect`, `@Suppress`ed for having no actual, and referenced by nothing. Room's KSP only generates the actual when `@ConstructedBy` names the object, so on a target with no reflection there was no way into the database at all. This is the one annotation in the ios work that changes every other target too: the generator now emits an `actual object` for android and jvm as well, each returning `MantraDatabase_Impl()`, where before it emitted none. jvmTest is unmoved at 1174, and MantraDatabaseJvmTest's comment about the no-Context builder overload being available "because MantraDatabaseConstructor gives Room a way to instantiate without reflection" is now true rather than aspirational. Co-Authored-By: Claude Opus 5 --- .../kotlin/press/mantra/compose/database/MantraDatabase.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/composeApp/src/commonMain/kotlin/press/mantra/compose/database/MantraDatabase.kt b/composeApp/src/commonMain/kotlin/press/mantra/compose/database/MantraDatabase.kt index c0c690ba..f7cd28cc 100644 --- a/composeApp/src/commonMain/kotlin/press/mantra/compose/database/MantraDatabase.kt +++ b/composeApp/src/commonMain/kotlin/press/mantra/compose/database/MantraDatabase.kt @@ -2,6 +2,7 @@ package press.mantra.compose.database import androidx.room3.ColumnTypeConverters import androidx.room3.AutoMigration +import androidx.room3.ConstructedBy import androidx.room3.Database import androidx.room3.RoomDatabase import androidx.room3.immediateTransaction @@ -366,6 +367,7 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L) AutoMigration(from = 21, to = 22), ] ) +@ConstructedBy(MantraDatabaseConstructor::class) @ColumnTypeConverters(MantraConverters::class) abstract class MantraDatabase: RoomDatabase() { abstract fun broadcastNostrEventReceiptDao(): BroadcastNostrEventReceiptDao