From b5116604c101b42ac381acfb14d420e3e7f395b8 Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 18 Oct 2024 05:34:02 +0200 Subject: [PATCH] Fixed loading the renamed TanMethodTypes --- .../persistence/SqliteBankingRepository.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt b/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt index d3a6bc2..d125635 100644 --- a/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt +++ b/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt @@ -37,6 +37,13 @@ expect fun createSqlDriverDriver(dbName: String, schema: SqlSchema> mapEnum(enum: Enum): String = enum.name private fun > mapToEnum(enumName: String, values: EnumEntries): E = - values.first { it.name == enumName } + try { + values.first { it.name == enumName } + } catch (e: Throwable) { + log.error(e) { "Could not map enumName '$enumName' to ${values.first()::class}"} + throw e + } + + + private fun > mapToEnum(enumName: String, values: EnumEntries, enumNamesToMigrate: Map): E = + mapToEnum(enumNamesToMigrate[enumName] ?: enumName, values) private fun > mapToEnumNullable(enumName: String, values: EnumEntries): E? { val mapped = values.firstOrNull { it.name == enumName }