Skip to content

Commit

Permalink
Don't record empty string (#135)
Browse files Browse the repository at this point in the history
Prevent empty transactions and comments from being written to the database

Closes #133
  • Loading branch information
LucaBernstein authored Apr 12, 2022
1 parent 06fc34c commit aa4a550
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions db/crud/bot_transaction.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package crud

import (
"fmt"

"github.com/LucaBernstein/beancount-bot-tg/helpers"
tb "gopkg.in/tucnak/telebot.v2"
)

func (r *Repo) RecordTransaction(chatId int64, tx string) error {
if tx == "" {
return fmt.Errorf("a transaction inserted into the database must not be empty")
}
_, err := r.db.Exec(`
INSERT INTO "bot::transaction" ("tgChatId", "value")
VALUES ($1, $2);`, chatId, tx)
Expand Down

0 comments on commit aa4a550

Please sign in to comment.