Status Update
Comments
ja...@gmail.com <ja...@gmail.com> #2
Branch: androidx-main
commit 10279986f24d1648952e740ea38c72b7bc44fdc7
Author: Elif Bilgin <elifbilgin@google.com>
Date: Tue Oct 26 16:59:42 2021
Resolving auto migration issue where SQLite keywords are failed to be escaped in column names.
The issue was arising from the part of AutoMigrationWriter generating code to transfer data from the old table to the new table, preserving the order of the columns. The SQL statement used did not utilize `` to escape the column names, resulting in a compiler error in scenarios where a SQLite keyword was being used as a column name.
Issue was repro'd in the tests by using the column name "index" and confirming the escape is working as expected with the new changes.
Test: AutoMigrationTest.java
Bug: 197133152
Change-Id: Idbed488acb2027fb1c0d9c302d1cc83ed5bfba2c
M room/room-compiler/src/main/kotlin/androidx/room/writer/AutoMigrationWriter.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/AutoMigrationDb.java
M room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.AutoMigrationDb/1.json
de...@gmail.com <de...@gmail.com> #3
de...@gmail.com <de...@gmail.com> #4
ho...@gmail.com <ho...@gmail.com> #5
da...@google.com <da...@google.com> #6
Thanks for the report I was able to reproduce the issue and indeed it occurs when using Kotlin 1.7.0. Sadly I don't have a workaround yet, but will investigate further.
da...@google.com <da...@google.com> #7
and just to clarify, we see the issue when using Room 2.4.2, but not with Room 2.5.0-alpha02.
yy...@gmail.com <yy...@gmail.com> #8
ma...@gmail.com <ma...@gmail.com> #9
I updated everything - It wasn't running.
With ext.kotlin_version = "1.6.21" - it is running.
za...@gotocme.com <za...@gotocme.com> #10
da...@google.com <da...@google.com> #11
Hey all, looks like the issue is related to a change in Kotlin's @Metadata
annotation and the way Room reads it, Room 2.4.2 is using an older version of the kotlinx-metadata-jvm
library which does not support reading Kotlin 1.7 information, where as in Room 2.5.0 we updated the library.
To workaround this issue please force upgrade the dependency by adding it to your annotation processor path, i.e. add kapt "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.5.0"
if you are using Room 2.4.x.
Meanwhile, I'll work on releasing a Room 2.4.3 that is compatible with Kotlin 1.7 since Room 2.5.x is still in development.
si...@gmail.com <si...@gmail.com> #12
zs...@gmail.com <zs...@gmail.com> #13
Thanks! Do you think 2.4.3
is something that will be released in the next couple weeks? Trying to decide if I want to use the workaround or just wait until it is released.
da...@google.com <da...@google.com> #14
ge...@gmail.com <ge...@gmail.com> #15
da...@google.com <da...@google.com>
19...@gmail.com <19...@gmail.com> #16
pi...@gmail.com <pi...@gmail.com> #17
Maybe reopen this.
@Query("SELECT * FROM ${SetupData.TABLE_NAME}")
suspend fun selectAll(): Cursor
[ksp] SetupDataDao.kt:24: Not sure how to convert a Cursor to this method's return type (android.database.Cursor).
Duh!
- Room 2.5.2
- Kotlin 1.9
- KSP 1.9.0-1.0.11
te...@gmail.com <te...@gmail.com> #18
da...@google.com <da...@google.com> #19
The diagnosis is the same, Room needs to update its kotlinx-metadata-jvm dependency to be able to read Kotlin 1.9+ metadata. An upcoming patch release (Room 2.5.3) will have the dep updated.
da...@google.com <da...@google.com> #20
Alternative if you use the KSP version of Room, this shouldn't be an issue.
io...@gmail.com <io...@gmail.com> #21
ri...@gmail.com <ri...@gmail.com> #22
bl...@gmail.com <bl...@gmail.com> #23
da...@davwheat.dev <da...@davwheat.dev> #24
ra...@gmail.com <ra...@gmail.com> #25
ma...@gmail.com <ma...@gmail.com> #26
sh...@navi.com <sh...@navi.com> #27
rc has been out since 20th sept
mr...@gmail.com <mr...@gmail.com> #28
pa...@gmail.com <pa...@gmail.com> #29
ah...@gmail.com <ah...@gmail.com> #30
Upgraded room to version to 2.6.1 and the issue is resolved!
ni...@gmail.com <ni...@gmail.com> #31
Issue is still present if you want to return Cursor
Room 2.7.0-alpha12 kotlinVersion = "2.1.0" kspVersion = "2.1.0-1.0.29"
Sample: @Query("SELECT * FROM ${SetupData.TABLE_NAME}") suspend fun selectAll(): Cursor [ksp] Not sure how to convert a Cursor to this method's return type (android.database.Cursor).
Description
Component used: Room with suspend functions i.e. coroutines
error:
/Users/jayshah/AndroidStudioProjects/SampleMemoryNotes/app/build/tmp/kapt3/stubs/debug/com/example/samplememorynotes/framework/db/NoteDao.java:17: error: Not sure how to convert a Cursor to this method's return type (java.lang.Object). public abstract java.lang.Object getNoteEntity(long id, @org.jetbrains.annotations.NotNull()
Usage:
Version used:
Devices/Android versions reproduced on: Android emulator
If this is a bug in the library, we would appreciate if you could attach: