From 8f774361e94afd2ba303222b3a19f14d8a877e65 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 9 Sep 2024 17:13:41 +0200 Subject: [PATCH] Added User.clientData (even though not used yet but to not have to change db schema afterwards) --- .../banking/dataaccess/SqliteBankingRepository.kt | 4 ++-- .../sqldelight/net/codinux/banking/ui/User.sq | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt index 1b580e8..5e40efb 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt @@ -30,7 +30,7 @@ open class SqliteBankingRepository( val tanMethods = getAllTanMethods().groupBy { it.userId } val tanMedia = getAllTanMedia().groupBy { it.userId } - return userQueries.selectAllUsers { id, bankCode, loginName, password, bankName, bic, customerName, userId, selectedTanMethodIdentifier, selectedTanMediumIdentifier, bankingGroup, serverAddress, userSetDisplayName, displayIndex, iconUrl, wrongCredentialsEntered -> + return userQueries.selectAllUsers { id, bankCode, loginName, password, bankName, bic, customerName, userId, selectedTanMethodIdentifier, selectedTanMediumIdentifier, bankingGroup, serverAddress, userSetDisplayName, clientData, displayIndex, iconUrl, wrongCredentialsEntered -> UserEntity(id, bankCode, loginName, password, bankName, bic, customerName, userId, bankAccounts[id] ?: emptyList(), selectedTanMethodIdentifier, tanMethods[id] ?: emptyList(), selectedTanMediumIdentifier, tanMedia[id] ?: emptyList(), bankingGroup?.let { BankingGroup.valueOf(it) }, serverAddress, userSetDisplayName, displayIndex.toInt(), iconUrl, wrongCredentialsEntered) }.executeAsList() @@ -40,7 +40,7 @@ open class SqliteBankingRepository( return userQueries.transactionWithResult { userQueries.insertUser(user.bankCode, user.loginName, user.password, user.bankName, user.bic, user.customerName, user.userId, user.selectedTanMethodIdentifier, user.selectedTanMediumIdentifier, - user.bankingGroup?.name, user.serverAddress, user.userSetDisplayName, user.displayIndex.toLong(), user.iconUrl, user.wrongCredentialsEntered + user.bankingGroup?.name, user.serverAddress, null, user.userSetDisplayName, user.displayIndex.toLong(), user.iconUrl, user.wrongCredentialsEntered ) val userId = getLastInsertedId() // getLastInsertedId() / last_insert_rowid() has to be called in a transaction with the insert operation, otherwise it will not work diff --git a/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/User.sq b/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/User.sq index ef9b881..5a57a72 100644 --- a/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/User.sq +++ b/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/User.sq @@ -20,6 +20,8 @@ CREATE TABLE IF NOT EXISTS User ( bankingGroup TEXT, serverAddress TEXT, + clientData TEXT, + userSetDisplayName TEXT, displayIndex INTEGER NOT NULL, @@ -44,6 +46,8 @@ INSERT INTO User( bankingGroup, serverAddress, + clientData, + userSetDisplayName, displayIndex, iconUrl, @@ -58,8 +62,13 @@ VALUES( ?, ?, ?, + + ?, + ?, ?, - ?, ? + + ?, + ? );