VictorKabata / Notflix

Kotlin Multiplatform playground
589 stars 82 forks source link

App Crash when accessing detailed movies #2

Closed peyrusse closed 2 years ago

peyrusse commented 3 years ago

1/ Launch the App 2/ Select a movie on the home page to access to the detail page 3/ The view starts to display then crashes with this error message : android.database.sqlite.SQLiteException: no such column: true (Sqlite code 1 SQLITE_ERROR): , while compiling: SELECT isFavorite FROM Movies Table WHERE id=? AND isFavorite=true, (OS error - 11:Try again) at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1030) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:637) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:610) at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:66) at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:37) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1482) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1452) at androidx.sqlite.db.framework.FrameworkSQLiteDatabase.query(FrameworkSQLiteDatabase.java:161) at androidx.room.RoomDatabase.query(RoomDatabase.java:446) at androidx.room.util.DBUtil.query(DBUtil.java:83) at com.vickikbt.cache.daos.MoviesDao_Impl$10.call(MoviesDao_Impl.java:594) at com.vickikbt.cache.daos.MoviesDao_Impl$10.call(MoviesDao_Impl.java:591) at androidx.room.CoroutinesRoom$Companion$createFlow$1$1.invokeSuspend(CoroutinesRoom.kt:122) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) 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:929)

peyrusse commented 3 years ago

Solved it by changing on MoviesDao Interface (under data/cache)

this line

@Query("SELECT isFavorite FROM Movies Table WHERE id=:movieId AND isFavorite=1=true")

by this line

@Query("SELECT isFavorite FROM Movies Table WHERE id=:movieId AND isFavorite=1")

VictorKabata commented 2 years ago

Fixed the issue