Status Update
Comments
yb...@google.com <yb...@google.com> #2
For Kotlin 2.0 and KSP 2.0 the Cannot change attributes of configuration ':composeApp:debugFrameworkIosX64' after it has been locked for mutation
really seems like a KSP issue. You should file a bug in their repository with a sample app if possible.
If you downgrade to Kotlin 1.9 then things 'should' work, there are example apps out there with such configuration, like the following one:
mm...@commonsware.com <mm...@commonsware.com> #3
Will try to use the example provided by you to check if it fixes the issue.
de...@gtempaccount.com <de...@gtempaccount.com> #4
Note that this issue happens when applying the Compose, KSP and Room Plugin together in Kotlin 2.0.x, the workaround for now is to not use the Room Gradle Plugin and instead specify the schema location vis KSP arguments:
// In the build.gradle
ksp {
arg("room.schemaLocation", "${projectDir}/schemas")
}
sk...@gmail.com <sk...@gmail.com> #5
Hi, I encountered a similar problem and was able to resolve it by updating the dependencies
room = "2.7.0-alpha08"
ksp = "2.0.20-1.0.25"
compose-plugin = "1.6.11"
kotlin = "2.0.20"
be...@google.com <be...@google.com> #6
yb...@google.com <yb...@google.com>
ap...@google.com <ap...@google.com> #7
Branch: androidx-master-dev
commit c5dad6522e6c20bbd5ca8e53b8406a94cb84cfe8
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Jun 12 16:43:53 2019
Allow single-value @Relation field.
This change lifts the restriction of @Relation annotated fields needing
to be List or Set allowing for a more seamless representation of a
one-to-one relationship.
Changes in the generated code is so that it is not always assumed that
the relation field is a collection, thus not needing a temporary
collection when collecting the relating objects.
Bug: 62905145
Test: ./gradlew room:room-compiler:test \
room:integration-tests:room-testapp:cC
Change-Id: I462d59e89b55c43842df43cb84c1aeca0b2b743e
M room/common/src/main/java/androidx/room/Relation.java
M room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
M room/compiler/src/main/kotlin/androidx/room/writer/RelationCollectorMethodWriter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/PojoProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/PetDao.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/PojoWithRelationTest.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/vo/PetAndOwner.java
Description
Version used: 1.0.0-alpha3
Devices/Android versions reproduced on: n/a
@Relation must return a List<> or Set<>. This includes cases where we know that there should only be one value (e.g., the parent on a 1:N relation). As it stands, we then need to get the 0th entry out of the List or something to get to our one-and-only entity.
IMHO, @Relation should support return types of a single entity instance. If the query returns 2+ rows, I can see three possible responses:
- Throw an exception
- Return the first row's entity
- Either, configurable via an annotation property (and ideally configurable based on build type, as we might throw the exception on debug builds but stagger along with boffo results in production)
After all, in principle, we should have the exact same code ourselves to deal with the current collection-based response.
I'm uncertain how popular @Relation will turn out to be, so I certainly can't characterize this as especially important. I'm just putting it out there for tracking purposes.
Thanks!