From f52f00abcfab98da29f679f3bc0951d3c510e2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Tue, 16 Jun 2020 19:50:55 -0700 Subject: [PATCH] Fix regression: the entire hstore field is replaced when updating settings --- oauth2/profile.go | 2 +- storage/user.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oauth2/profile.go b/oauth2/profile.go index 471b478d..c3e013e0 100644 --- a/oauth2/profile.go +++ b/oauth2/profile.go @@ -16,5 +16,5 @@ type Profile struct { } 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) } diff --git a/storage/user.go b/storage/user.go index 8c96569c..53f0a8ce 100644 --- a/storage/user.go +++ b/storage/user.go @@ -88,7 +88,7 @@ func (s *Storage) CreateUser(user *model.User) (err error) { // UpdateExtraField updates an extra field of the given user. 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) if err != nil { return fmt.Errorf(`store: unable to update user extra field: %v`, err)