Skip to content

Commit

Permalink
Handle backups with categories having default category name (#745)
Browse files Browse the repository at this point in the history
We do not allow any category to have the default categories name ("default" case-insensitive).
In case the backup includes a category with this name, it won't be matched to any category in our database and also won't insert a new category.
This will then lead to an exception, causing the backup to fail.
  • Loading branch information
schroda authored Oct 30, 2023
1 parent 5d4d417 commit dcbb1c0
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ object ProtoBackupImport : ProtoBackupBase() {
val categoryMapping =
transaction {
backup.backupCategories.associate {
it.order to CategoryTable.select { CategoryTable.name eq it.name }.first()[CategoryTable.id].value
val dbCategory = CategoryTable.select { CategoryTable.name eq it.name }.firstOrNull()
val categoryId =
dbCategory?.let {
categoryResultRow ->
categoryResultRow[CategoryTable.id].value
} ?: Category.DEFAULT_CATEGORY_ID
it.order to categoryId
}
}

Expand Down

0 comments on commit dcbb1c0

Please sign in to comment.