diff --git a/sync/service/postgres.go b/sync/service/postgres.go index 863445a..62b6b86 100644 --- a/sync/service/postgres.go +++ b/sync/service/postgres.go @@ -111,9 +111,17 @@ func (p *Postgres) Updated(ks []item.Kind, t time.Time) ([]item.Item, error) { for rows.Next() { var item item.Item var recurNext sql.NullTime - if err := rows.Scan(&item.ID, &item.Kind, &item.Updated, &item.Deleted, &item.Body, &item.Recurrer, &recurNext); err != nil { + var recurrerJSON []byte + if err := rows.Scan(&item.ID, &item.Kind, &item.Updated, &item.Deleted, &item.Body, &recurrerJSON, &recurNext); err != nil { return nil, fmt.Errorf("%w: %v", ErrPostgresFailure, err) } + if len(recurrerJSON) > 0 { + var recurrer item.Recur + if err := json.Unmarshal(recurrerJSON, &recurrer); err != nil { + return nil, fmt.Errorf("%w: %v", ErrPostgresFailure, err) + } + item.Recurrer = &recurrer + } if recurNext.Valid { item.RecurNext = recurNext.Time } @@ -139,9 +147,17 @@ func (p *Postgres) RecursBefore(date time.Time) ([]item.Item, error) { for rows.Next() { var item item.Item var recurNext sql.NullTime - if err := rows.Scan(&item.ID, &item.Kind, &item.Updated, &item.Deleted, &item.Body, &item.Recurrer, &recurNext); err != nil { + var recurrerJSON []byte + if err := rows.Scan(&item.ID, &item.Kind, &item.Updated, &item.Deleted, &item.Body, &recurrerJSON, &recurNext); err != nil { return nil, fmt.Errorf("%w: %v", ErrPostgresFailure, err) } + if len(recurrerJSON) > 0 { + var recurrer item.Recur + if err := json.Unmarshal(recurrerJSON, &recurrer); err != nil { + return nil, fmt.Errorf("%w: %v", ErrPostgresFailure, err) + } + item.Recurrer = &recurrer + } if recurNext.Valid { item.RecurNext = recurNext.Time }