fix: dont prematurely close transaction
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 4m25s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 5m7s

This commit was merged in pull request #140.
This commit is contained in:
2025-05-29 20:08:11 +02:00
parent c2b96145f3
commit 4fa605bd8f

View File

@@ -56,7 +56,9 @@ func (s TransactionImpl) Add(tx *sqlx.Tx, user *types.User, transactionInput typ
}
var err error
ownsTransaction := false
if tx == nil {
ownsTransaction = true
tx, err = s.db.Beginx()
err = db.TransformAndLogDbError("transaction Add", nil, err)
if err != nil {
@@ -104,11 +106,13 @@ func (s TransactionImpl) Add(tx *sqlx.Tx, user *types.User, transactionInput typ
}
}
if ownsTransaction {
err = tx.Commit()
err = db.TransformAndLogDbError("transaction Add", nil, err)
if err != nil {
return nil, err
}
}
return transaction, nil
}