Skip to content

Add Room 3.0 snippets#956

Open
danysantiago wants to merge 7 commits into
android:mainfrom
danysantiago:room3
Open

Add Room 3.0 snippets#956
danysantiago wants to merge 7 commits into
android:mainfrom
danysantiago:room3

Conversation

@danysantiago

@danysantiago danysantiago commented Jun 17, 2026

Copy link
Copy Markdown

Snippets for the soon-to-be-added Room 3.0 documentation.

@snippet-bot

snippet-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 87 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread gradle/libs.versions.toml

@kkuan2011 kkuan2011 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build is failing due to some formatting issues, so try to run ./gradlew spotlessApply to see if that fixes it

Comment thread room/build.gradle.kts
Comment thread settings.gradle.kts Outdated
Comment thread room3/build.gradle.kts Outdated
Comment thread room3/src/main/java/com/example/snippets/room3/prepopulate/PrepopulateSnippets.kt Outdated
@danysantiago danysantiago requested review from a team as code owners June 18, 2026 22:59
@danysantiago danysantiago requested a review from rebeccasg June 18, 2026 22:59

@kkuan2011 kkuan2011 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use a more inclusive term like Placeholder or Example?

Comment thread room/build.gradle.kts
@ProvidedColumnTypeConverter
class ExampleConverter {
@ColumnTypeConverter
fun StringToExample(string: String?): ExampleType? {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants