Add Room 3.0 snippets#956
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new room3 module containing comprehensive code snippets and tests for Room 3.0 features, including migrations, database views, relationships, and asynchronous queries. The review feedback identifies several critical issues that must be addressed: incorrect dependency coordinates in libs.versions.toml and wrong package imports (using androidx.room3 instead of androidx.room) which will cause build and compilation failures. Additionally, the reviewer recommends offloading database and network operations to a background thread using .flowOn(Dispatchers.IO) in AsyncQueriesSnippets.kt, fixing a typo in a column name (fist_name), and properly closing the RoomDatabase instance in MigrationTest.kt to prevent resource leaks.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
kkuan2011
left a comment
There was a problem hiding this comment.
The build is failing due to some formatting issues, so try to run ./gradlew spotlessApply to see if that fixes it
kkuan2011
left a comment
There was a problem hiding this comment.
Looks good from a snippets repo perspective. I don't know if you need someone with more Room expertise to review? or if that was already done elsewhere?
Otherwise, once comments are addressed, feel free to submit. Thank you Dany for adding/migrating these snippets!!
| // [END android_room3_referencing_data_provided] | ||
|
|
||
| @Entity | ||
| data class DummyEntity(@PrimaryKey val id: Int) |
There was a problem hiding this comment.
can we use a more inclusive term like Placeholder or Example?
| @ProvidedColumnTypeConverter | ||
| class ExampleConverter { | ||
| @ColumnTypeConverter | ||
| fun StringToExample(string: String?): ExampleType? { |
There was a problem hiding this comment.
nit: is it intentional that these methods (StringToExample and ExampleToString) would start with an uppercase character?
| interface UserDao | ||
|
|
||
| // [START android_room3_creating_views_view] | ||
| @DatabaseView( |
There was a problem hiding this comment.
What do you think about this comment that came from an AI code review?
Suggestion: Match table name casing in @DatabaseView query
In this file, @entity data class User and Department are declared without explicit table names, meaning Room generates tables named "User" and "Department" (uppercase). However, the @DatabaseView raw query queries FROM user INNER JOIN department (lowercase).
While standard SQLite ASCII matching is case-insensitive, implicit casing mismatches between Kotlin class models and SQL strings can cause subtle issues across custom KMP SQLite drivers or strict query parsers.
To keep the SQL idiomatic and strictly aligned with the generated schema, consider matching the exact class casing in the SQL:
suggestion
"""
SELECT User.id, User.name, User.departmentId, Department.name AS departmentName
FROM User INNER JOIN Department ON User.departmentId = Department.id
"""
(Alternatively, if lowercase table names are preferred, we can annotate @entity(tableName = "user") on the data classes).
Snippets for the soon-to-be-added Room 3.0 documentation.