fix: Handle nil recurrer in PostgreSQL JSON update query
This commit is contained in:
parent
4a71d685da
commit
e6c6dabb1b
|
@ -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 {
|
func (p *Postgres) Update(i item.Item, ts time.Time) error {
|
||||||
var recurrerJSON []byte
|
var recurrerJSON interface{}
|
||||||
var err error
|
|
||||||
if i.Recurrer != nil {
|
if i.Recurrer != nil {
|
||||||
|
var err error
|
||||||
recurrerJSON, err = json.Marshal(i.Recurrer)
|
recurrerJSON, err = json.Marshal(i.Recurrer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%w: %v", ErrPostgresFailure, err)
|
return fmt.Errorf("%w: %v", ErrPostgresFailure, err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
recurrerJSON = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = p.db.Exec(`
|
_, err = p.db.Exec(`
|
||||||
|
|
Loading…
Reference in New Issue