Fix regression: the entire hstore field is replaced when updating settings

This commit is contained in:
Frédéric Guillot 2020-06-16 19:50:55 -07:00
parent da4ea18003
commit f52f00abcf
2 changed files with 2 additions and 2 deletions

View file

@ -16,5 +16,5 @@ type Profile struct {
} }
func (p Profile) String() string { func (p Profile) String() string {
return fmt.Sprintf(`ID=%s ; Username=%s`, p.ID, p.Username) return fmt.Sprintf(`Key=%s ; ID=%s ; Username=%s`, p.Key, p.ID, p.Username)
} }

View file

@ -88,7 +88,7 @@ func (s *Storage) CreateUser(user *model.User) (err error) {
// UpdateExtraField updates an extra field of the given user. // UpdateExtraField updates an extra field of the given user.
func (s *Storage) UpdateExtraField(userID int64, field, value string) error { func (s *Storage) UpdateExtraField(userID int64, field, value string) error {
query := fmt.Sprintf(`UPDATE users SET extra = hstore('%s', $1) WHERE id=$2`, field) query := fmt.Sprintf(`UPDATE users SET extra = extra || hstore('%s', $1) WHERE id=$2`, field)
_, err := s.db.Exec(query, value, userID) _, err := s.db.Exec(query, value, userID)
if err != nil { if err != nil {
return fmt.Errorf(`store: unable to update user extra field: %v`, err) return fmt.Errorf(`store: unable to update user extra field: %v`, err)