Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
I encountered an issue when using a prepacked database file that includes views. To maintain schema consistency, I used the @DatabaseView annotation to create a view class in the code. However, when building the project, an error appears stating that the views in the preloaded database and in the code are inconsistent. The error occurs solely due to differences in whitespace, line breaks, keyword case sensitivity, and whether table names are enclosed in backticks. These minor formatting differences should not result in a schema error. This seems to be a bug in the Room library.
core error message in logcat:
java.lang.IllegalStateException: Pre-packaged database has an invalid schema: vw_course_with_math_type(com.example.roominvalidschemaaboutviews.CourseView).
Expected:
ViewInfo{name='vw_course_with_math_type', sql='CREATE VIEW `vw_course_with_math_type` AS SELECT *
FROM course
WHERE type = 'math''}
Found:
ViewInfo{name='vw_course_with_math_type', sql='CREATE VIEW vw_course_with_math_type AS
SELECT *
FROM course
WHERE type = 'math''}
at androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.kt:158)
Component used:
Room Database
Version used:
room = "2.6.1"
kapt = "2.0.20"
Devices/Android versions reproduced on:
android 12.0
Additional Information:
reproduce repository:
full error message in logcat from reproduce repository:
java.lang.IllegalStateException: Pre-packaged database has an invalid schema: vw_course_with_math_type(com.example.roominvalidschemaaboutviews.CourseView).
Expected:
ViewInfo{name='vw_course_with_math_type', sql='CREATE VIEW `vw_course_with_math_type` AS SELECT *
FROM course
WHERE type = 'math''}
Found:
ViewInfo{name='vw_course_with_math_type', sql='CREATE VIEW vw_course_with_math_type AS
SELECT *
FROM course
WHERE type = 'math''}
at androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.kt:158)
at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.kt:127)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.kt:287)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:446)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:331)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableOrReadableDatabase(FrameworkSQLiteOpenHelper.kt:232)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.innerGetDatabase(FrameworkSQLiteOpenHelper.kt:190)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getSupportDatabase(FrameworkSQLiteOpenHelper.kt:151)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.kt:104)
at androidx.room.SQLiteCopyOpenHelper.getWritableDatabase(SQLiteCopyOpenHelper.kt:71)
at androidx.room.RoomDatabase.inTransaction(RoomDatabase.kt:632)
at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.kt:451)
at androidx.room.RoomDatabase.query(RoomDatabase.kt:480)
at androidx.room.util.DBUtil.query(DBUtil.kt:75)
at com.example.roominvalidschemaaboutviews.CourseDao_Impl$1.call(CourseDao_Impl.java:40)
at com.example.roominvalidschemaaboutviews.CourseDao_Impl$1.call(CourseDao_Impl.java:36)
at androidx.room.CoroutinesRoom$Companion$execute$4$job$1.invokeSuspend(CoroutinesRoom.kt:87)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:933)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@2f19bcd, androidx.compose.runtime.BroadcastFrameClock@be5fc82, StandaloneCoroutine{Cancelling}@2684f93, AndroidUiDispatcher@d5adbd0]