Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch all cursor errors so migration can proceed #1137

Merged
merged 2 commits into from
Nov 2, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ abstract class AppDatabase : RoomDatabase() {
val sensors = mutableListOf<ContentValues>()
var migrationSuccessful = false
var migrationFailed = false
if (cursor.moveToFirst()) {
try {
try {
if (cursor.moveToFirst()) {
while (cursor.moveToNext()) {
sensors.add(ContentValues().also {
it.put("id", cursor.getString(cursor.getColumnIndex("unique_id")))
Expand All @@ -187,10 +187,10 @@ abstract class AppDatabase : RoomDatabase() {
})
}
migrationSuccessful = true
} catch (e: Exception) {
migrationFailed = true
Log.e(TAG, "Unable to migrate, proceeding with recreating the table", e)
}
} catch (e: Exception) {
migrationFailed = true
Log.e(TAG, "Unable to migrate, proceeding with recreating the table", e)
}
cursor.close()
dshokouhi marked this conversation as resolved.
Show resolved Hide resolved
database.execSQL("DROP TABLE IF EXISTS `sensors`")
Expand Down Expand Up @@ -222,8 +222,8 @@ abstract class AppDatabase : RoomDatabase() {
val sensors = mutableListOf<ContentValues>()
var migrationSuccessful = false
var migrationFailed = false
if (cursor.moveToFirst()) {
try {
try {
if (cursor.moveToFirst()) {
while (cursor.moveToNext()) {
sensors.add(ContentValues().also {
it.put("id", cursor.getString(cursor.getColumnIndex("id")))
Expand All @@ -241,10 +241,10 @@ abstract class AppDatabase : RoomDatabase() {
})
}
migrationSuccessful = true
} catch (e: Exception) {
migrationFailed = true
Log.e(TAG, "Unable to migrate, proceeding with recreating the table", e)
}
} catch (e: Exception) {
migrationFailed = true
Log.e(TAG, "Unable to migrate, proceeding with recreating the table", e)
}
cursor.close()
dshokouhi marked this conversation as resolved.
Show resolved Hide resolved
database.execSQL("DROP TABLE IF EXISTS `sensors`")
Expand Down