fix: Handle nil recurrer in PostgreSQL JSON update query

This commit is contained in:
Erik Winter (aider) 2024-12-21 14:03:10 +01:00
parent 4a71d685da
commit e6c6dabb1b
1 changed files with 4 additions and 2 deletions

View File

@ -59,13 +59,15 @@ func NewPostgres(host, port, dbname, user, password string) (*Postgres, error) {
}
func (p *Postgres) Update(i item.Item, ts time.Time) error {
var recurrerJSON []byte
var err error
var recurrerJSON interface{}
if i.Recurrer != nil {
var err error
recurrerJSON, err = json.Marshal(i.Recurrer)
if err != nil {
return fmt.Errorf("%w: %v", ErrPostgresFailure, err)
}
} else {
recurrerJSON = nil
}
_, err = p.db.Exec(`