Status Update
Comments
ap...@google.com <ap...@google.com> #2
Branch: androidx-main
commit a4d19c00399a78d24bb32050927310bed0520197
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Apr 17 17:44:46 2024
Disallow @RawQuery usages in non-Android targets.
Instead trying to compile badly generated code, show a clear error that @RawQuery is currently not supported in KMP.
Bug: 330586815
Test: n/a
Change-Id: I60a2fd85bc4e9a4a09ee96b22bfe1f37f6eae591
M room/room-compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/room-compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
ap...@google.com <ap...@google.com> #3
Branch: androidx-main
commit fce71c215eef5279fdfb3e95c016f80a864cc396
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Tue Jul 09 08:16:27 2024
Support for @RawQuery in Room KMP
Support is added by creating a new API, similar to SupportSQLiteQuery that holds the SQL query string and, in the case of this new API, a function to bind arguments into a statement. The API is named RoomRawQuery and is the common type that can be used as a the single parameter of a @RawQuery annotated DAO function. The statement received in the binding lambda will throw an error if other non bind functions are invoked.
Bug: 330586815
Test: BaseQueryTest
Relnote: "Support for @RawQuery in Room KMP by adding a new API called RoomRawQuery that is similar to SupportSQLiteQuery in terms of holding into the raw SQL string and a function to bind arguments into a statement. @RawQuery annotated functions can now accept a RoomRawQuery as their single parameter."
Change-Id: Iea84484b18c0c969b4012977e737eb12c4b4f2c6
M room/integration-tests/multiplatformtestapp/src/commonTest/kotlin/androidx/room/integration/multiplatformtestapp/test/BaseQueryTest.kt
M room/integration-tests/multiplatformtestapp/src/commonTest/kotlin/androidx/room/integration/multiplatformtestapp/test/SampleDatabase.kt
M room/room-common/src/commonMain/kotlin/androidx/room/RawQuery.kt
M room/room-compiler/src/main/kotlin/androidx/room/ext/xpoet_ext.kt
M room/room-compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/room-compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
M room/room-compiler/src/main/kotlin/androidx/room/vo/RawQueryMethod.kt
M room/room-compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
M room/room-compiler/src/test/kotlin/androidx/room/writer/DaoKotlinCodeGenTest.kt
M room/room-compiler/src/test/test-data/kotlinCodeGen/rawQuery.kt
M room/room-runtime/api/current.txt
M room/room-runtime/api/restricted_current.txt
M room/room-runtime/bcv/native/current.txt
A room/room-runtime/src/commonMain/kotlin/androidx/room/RoomRawQuery.kt
da...@google.com <da...@google.com>
pr...@google.com <pr...@google.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.room:room-common:2.7.0-alpha06
androidx.room:room-common-iosarm64:2.7.0-alpha06
androidx.room:room-common-iossimulatorarm64:2.7.0-alpha06
androidx.room:room-common-iosx64:2.7.0-alpha06
androidx.room:room-common-jvm:2.7.0-alpha06
androidx.room:room-common-linuxx64:2.7.0-alpha06
androidx.room:room-common-macosarm64:2.7.0-alpha06
androidx.room:room-common-macosx64:2.7.0-alpha06
androidx.room:room-compiler:2.7.0-alpha06
androidx.room:room-runtime:2.7.0-alpha06
androidx.room:room-runtime-android:2.7.0-alpha06
androidx.room:room-runtime-iosarm64:2.7.0-alpha06
androidx.room:room-runtime-iossimulatorarm64:2.7.0-alpha06
androidx.room:room-runtime-iosx64:2.7.0-alpha06
androidx.room:room-runtime-jvm:2.7.0-alpha06
androidx.room:room-runtime-linuxx64:2.7.0-alpha06
androidx.room:room-runtime-macosarm64:2.7.0-alpha06
androidx.room:room-runtime-macosx64:2.7.0-alpha06
ds...@gmail.com <ds...@gmail.com> #5
ju...@gmail.com <ju...@gmail.com> #7
Hi, this still seems to be a problem in 2.7.0-alpha11. However, I do not use @RawQuery in my code. I have a custom class that makes use of @Embedded an @Relation which seems to use this under the hood since I receive this honestly meaningless error message The @Database class must be annotated with @ConstructedBy since the source is targeting non-Android platforms.
.
I only found out about this being related to the missing implementation of @RawQuery on other platforms than Android by running a search with parts of it in quotation marks as the only reference I could find was a single commit in a Git-Repository:
This is a breaking problem for me at the moment since it prevents me from building APKs. Running the app on an emulator works just fine. This issue is marked as fixed and the fix got merged but as I said earlier, it seems to still be there. Is there anything that need to be changed in the code? If the fix isn't rolled out in a new room-Version, when will the time be? Thanks in advance!
da...@google.com <da...@google.com> #8
re @RawQuery
APIs, can you please file a new bug?
If you are having issue with Room's KMP setup see the following comment for things to checkout:
Description
The current API for
@RawQuery
is to write a DAO function that receives aSupportSQLiteQuery
and return some POJO / Entity. There is no SQLite KMP API likeSupportSQLiteQuery
and its builder.