Status Update
Comments
da...@google.com <da...@google.com> #2
Thanks for trying Room KMP! It looks like bad code generation from the processor, we'll investigate.
ri...@ffw.com <ri...@ffw.com> #3
It looks like this is resolved with 2.7.0-alpha03 Sorry, it's not fixed, I looked at the wrong project :/
el...@google.com <el...@google.com> #4
Closing this issue based on your last comment - please let us know if this issue arises again. Thanks!
ak...@gmail.com <ak...@gmail.com> #5
I still have the same issue on iOS with room version 2.7.0 alpha03
da...@google.com <da...@google.com>
va...@gmail.com <va...@gmail.com> #6
```
@Transaction
@Query("SELECT * FROM person_local WHERE uid = :uid")
fun getPersonWithFilesByUid(uid: Long): Flow<PeopleWithFiles>
```
```
import androidx.room.Embedded
import androidx.room.Relation
data class PeopleWithFiles(
@Embedded val person: Person,
@Relation(
parentColumn = "uid",
entityColumn = "personUid"
)
val filesEntity: List<PeopleFileEntity> = emptyList()
) {
fun toFilePaths(): List<String> {
return filesEntity.map { it.filePath }
}
}
```
```
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
@Entity(
tableName = "person_local_files",
foreignKeys = [
ForeignKey(
entity = Person::class,
parentColumns = ["uid"],
childColumns = ["personUid"],
onDelete = ForeignKey.CASCADE
)
],
indices = [Index(value = ["personUid"])] // Add this line
)
data class PeopleFileEntity(
@PrimaryKey(autoGenerate = true) val fileId: Long = 0,
@ColumnInfo(name = "personUid") val personUid: Long,
@ColumnInfo(name = "filePath") val filePath: String,
@ColumnInfo(name = "fileTag") val fileTag: String
)
```
> Task :composeApp:compileKotlinIosArm64 FAILED
/Users/vaxela/Documents/projects/test/Room-CMP/composeApp/build/generated/ksp/iosArm64/iosArm64Main/kotlin/database/PeopleDao_Impl.kt:13:27: error: Unresolved reference: recursiveFetchLongSparseArray
/Users/vaxela/Documents/projects/test/Room-CMP/composeApp/build/generated/ksp/iosArm64/iosArm64Main/kotlin/database/PeopleDao_Impl.kt:675:7: error: Unresolved reference: recursiveFetchLongSparseArray
/Users/vaxela/Documents/projects/test/Room-CMP/composeApp/build/generated/ksp/iosArm64/iosArm64Main/kotlin/database/PeopleDao_Impl.kt:675:51: error: Cannot infer a type for this parameter. Please specify it explicitly.
The import import androidx.room.util.recursiveFetchLongSparseArray
``` private
fun __fetchRelationshippersonLocalFilesAsdatabasePeopleFileEntity(_connection: SQLiteConnection,
_map: LongSparseArray<MutableList<PeopleFileEntity>>) {
if (_map.isEmpty()) {
return
}
if (_map.size() > 999) {
recursiveFetchLongSparseArray(_map, true) { _tmpMap ->
__fetchRelationshippersonLocalFilesAsdatabasePeopleFileEntity(_connection, _tmpMap)
}
return
}
```
I attach the builded file
de...@gmail.com <de...@gmail.com> #7
el...@google.com <el...@google.com>
el...@google.com <el...@google.com> #9
Hi there! We were able to reproduce and fix the issue on our end. Should be fixed in the next release of Room.
de...@gmail.com <de...@gmail.com> #10
I am looking to make use of room asap. When can we expect the next release of Room?
el...@google.com <el...@google.com> #11
Should be late June or early July!
el...@google.com <el...@google.com>
ap...@google.com <ap...@google.com> #12
Branch: androidx-main
commit fd4a29dca9fcd48555399ec9f018e8caf603d075
Author: elifbilgin <elifbilgin@google.com>
Date: Thu May 30 13:49:02 2024
Resolve invalid Relation codegen.
Users were encountering a "missing recursiveFetchLongSparseArray()" error in
codegen for iOS. This issue was due to the fact that room-runtime was not
depending on androidx.collection in common. Now that androidx.collection is
available in KMP (and, therefore, LongSparseArray is available) we can
depend on it in room-runtime.
This issue was reproduced and verified by adding the androidx.collection
dependency to the common source set of the kotlin multiplatform test app
and using existing tests that use @Relation on the iOS target. Once verified, the
dependency was added to room-runtime common source sets, and the
`recursiveFetchLongSparseArray()` function has been moved from the
Android-only RelationUtil.android.kt to the common RelationUtil.kt.
Bug: 341002184
Test: BaseQueryTest.kt
Change-Id: Id1afde6c5eeb46c3fe0bf9cc14c52eccb161be72
M room/room-runtime/build.gradle
M room/room-runtime/src/androidMain/kotlin/androidx/room/util/RelationUtil.android.kt
M room/room-runtime/src/commonMain/kotlin/androidx/room/util/RelationUtil.kt
va...@hotmail.fr <va...@hotmail.fr> #13
el...@google.com <el...@google.com> #14
Yes, this fix will be included in androidx.room:2.7.0-alpha05.
ri...@ffw.com <ri...@ffw.com> #15
The same issue happens on desktop target, does this fix all targets?
el...@google.com <el...@google.com> #16
Thanks for letting us know - Yes, the fix covers all targets.
lz...@gmail.com <lz...@gmail.com> #17
el...@google.com <el...@google.com> #18
Yes, we plan on having it land with the July 10th, 2024 release.
na...@google.com <na...@google.com> #19
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.room:room-runtime:2.7.0-alpha05
androidx.room:room-runtime-android:2.7.0-alpha05
androidx.room:room-runtime-iosarm64:2.7.0-alpha05
androidx.room:room-runtime-iossimulatorarm64:2.7.0-alpha05
androidx.room:room-runtime-iosx64:2.7.0-alpha05
androidx.room:room-runtime-jvm:2.7.0-alpha05
androidx.room:room-runtime-linuxx64:2.7.0-alpha05
androidx.room:room-runtime-macosarm64:2.7.0-alpha05
androidx.room:room-runtime-macosx64:2.7.0-alpha05
Description
Version used: 2.7.0-alpha01/02
Sample project:
Add the following Relation
```
data class TeamWithPlayers(
@Embedded val team: Team,
@Relation(
parentColumn = "id",
entityColumn = "id",
entity = Player::class,
)
val players: List<Player>,
)
```
Add the following to the FantasyPremierLeagueDao
```
@Query("SELECT * FROM Team")
@Transaction
fun getTeamsWithPlayers(): Flow<List<TeamWithPlayers>>
```
Result:
> Task :common:compileKotlinIosSimulatorArm64 FAILED
/../FantasyPremierLeague/common/build/generated/ksp/iosSimulatorArm64/iosSimulatorArm64Main/kotlin/dev/johnoreilly/common/database/FantasyPremierLeagueDao_Impl.kt:11:27: error: Unresolved reference: recursiveFetchLongSparseArray
/../FantasyPremierLeague/common/build/generated/ksp/iosSimulatorArm64/iosSimulatorArm64Main/kotlin/dev/johnoreilly/common/database/FantasyPremierLeagueDao_Impl.kt:395:7: error: Unresolved reference: recursiveFetchLongSparseArray
/../FantasyPremierLeague/common/build/generated/ksp/iosSimulatorArm64/iosSimulatorArm64Main/kotlin/dev/johnoreilly/common/database/FantasyPremierLeagueDao_Impl.kt:395:51: error: Cannot infer a type for this parameter. Please specify it explicitly.
I know id wouldn't match, I just want to show that parentColumn and entityColumn something other than String will result in this. Same with id being an actual Long value. If I change parentColumn and entityColumn to use "name", it works as both are Strings and it uses "recursiveFetchMap" instead of "recursiveFetchLongSparseArray"