Fixed
Status Update
Comments
da...@google.com <da...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 11a3cb30e7c9067a27eb10bf96e89afdc283ba2e
Author: pingxuanli <pingxuanli@google.com>
Date: Mon Aug 22 13:03:03 2022
Adding error message check in EntityUpsertionAdapter.
Bug: 243039555
Test: Tests are in EntityUpsertionAdapterTest file. By using toy, can check for foreign key constraint. (FK violation is commented out to prevent crash but the errors were thrown correctly)
Relnote: restrict the minimum version that supports Upsert to at least 16
Change-Id: I5f67f2ab5d41a313c48dac42f485f8345f74c1b1
M room/room-common/api/current.txt
M room/room-runtime/api/restricted_current.txt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DaoConflictStrategyTest.java
M room/room-common/src/main/java/androidx/room/Upsert.kt
M room/room-common/api/public_plus_experimental_current.txt
M room/room-runtime/api/current.txt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/LiveDataQueryTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/EntityUpsertionAdapterTest.java
M room/room-runtime/api/public_plus_experimental_current.txt
M room/room-runtime/src/main/java/androidx/room/EntityUpsertionAdapter.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/vo/Toy.java
M room/room-common/api/restricted_current.txt
https://android-review.googlesource.com/2191947
Branch: androidx-main
commit 11a3cb30e7c9067a27eb10bf96e89afdc283ba2e
Author: pingxuanli <pingxuanli@google.com>
Date: Mon Aug 22 13:03:03 2022
Adding error message check in EntityUpsertionAdapter.
Bug: 243039555
Test: Tests are in EntityUpsertionAdapterTest file. By using toy, can check for foreign key constraint. (FK violation is commented out to prevent crash but the errors were thrown correctly)
Relnote: restrict the minimum version that supports Upsert to at least 16
Change-Id: I5f67f2ab5d41a313c48dac42f485f8345f74c1b1
M room/room-common/api/current.txt
M room/room-runtime/api/restricted_current.txt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DaoConflictStrategyTest.java
M room/room-common/src/main/java/androidx/room/Upsert.kt
M room/room-common/api/public_plus_experimental_current.txt
M room/room-runtime/api/current.txt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/LiveDataQueryTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/EntityUpsertionAdapterTest.java
M room/room-runtime/api/public_plus_experimental_current.txt
M room/room-runtime/src/main/java/androidx/room/EntityUpsertionAdapter.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/vo/Toy.java
M room/room-common/api/restricted_current.txt
Description
room-common (androidX)
room-coroutines (androidX)
Kotlin
Version used: 2.1.0-alpha03
Devices/Android versions reproduced on: Compilation error
This issue happens when you try to make a concret Room Dao inherit from a generic Dao using coroutine (with suspend keyword on them), it displays the following error :
error: Type of the parameter must be a class annotated with @Entity or a collection/array of it.
kotlin.coroutines.Continuation<? super kotlin.Unit> p1);
^
Classes I use to reproduce this problem :
@Database(
version = 1,
entities = [
User::class
],
exportSchema = true
)
abstract class RoomDB : RoomDatabase() {
abstract fun getUserDao(): UserDao
}
@Entity(tableName = "user")
data class User(
@PrimaryKey(autoGenerate = true) val id: Long = 0,
val firstName: String,
val lastName: String
)
interface BaseDao<T> {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertOrUpdate(entity: T)
}
@Dao
interface UserDao: BaseDao<User> {
@Query("SELECT * FROM user")
suspend fun loadAll(): List<User>
}
I tried several things, like using varags in parameter on insertOrUpdate method, or giving it an output (List<Int> or Int) without any change in the error.
A sample project is in attachment to reproduce this bug.
Thank you in advance