hunk.code_window: 		query += " WHERE Id = :UserId"
   		if _, err := us.GetMaster().Exec(query, map[string]interface{}{"LastPasswordUpdate": updateAt, "UpdateAt": updateAt, "UserId": userId, "AuthService": service, "AuthData": authData, "Email": email}); err != nil {
   			if IsUniqueConstraintError(err.Error(), []string{"Email", "users_email_key", "idx_users_email_unique", "AuthData", "users_authdata_key"}) {
   				result.Err = model.NewLocAppError("SqlUserStore.UpdateAuthData", "store.sql_user.update_auth_data.email_exists.app_error", map[string]interface{}{"Service": service, "Email": email}, "user_id="+userId+", "+err.Error())
   			} else {
   				result.Err = model.NewLocAppError("SqlUserStore.UpdateAuthData", "store.sql_user.update_auth_data.app_error", nil, "id="+userId+", "+err.Error())
   			}
  
hunk.labels: keep keep keep replace keep keep keep keep
hunk.after_edit: 			if IsUniqueConstraintError(err, []string{"Email", "users_email_key", "idx_users_email_unique", "AuthData", "users_authdata_key"}) {
  
hunk.file_path: store/sql_user_store.go
hunk.type: replace
file: // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
  // See License.txt for license information.
  
  package model
  
  import (
  	"encoding/json"
  	"strings"
  	"testing"
  )
  
  func TestPreferenceIsValid(t *testing.T) {
  	preference := Preference{
  		UserId:   "1234garbage",
  		Category: PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW,
  		Name:     NewId(),
  	}
  
  	if err := preference.IsValid(); err == nil {
  		t.Fatal()
  	}
  
  	preference.UserId = NewId()
  	if err := preference.IsValid(); err != nil {
  		t.Fatal(err)
  	}
  
  	preference.Category = strings.Repeat("01234567890", 20)
  	if err := preference.IsValid(); err == nil {
  		t.Fatal()
  	}
  
  	preference.Category = PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW
  	if err := preference.IsValid(); err != nil {
  		t.Fatal(err)
  	}
  
  	preference.Name = strings.Repeat("01234567890", 20)
  	if err := preference.IsValid(); err == nil {
  		t.Fatal()
  	}
  
  	preference.Name = NewId()
  	if err := preference.IsValid(); err != nil {
  		t.Fatal(err)
  	}
  
  	preference.Value = strings.Repeat("01234567890", 201)
  	if err := preference.IsValid(); err == nil {
  		t.Fatal()
  	}
  
  	preference.Value = "1234garbage"
  	if err := preference.IsValid(); err != nil {
  		t.Fatal(err)
  	}
  
  	preference.Category = PREFERENCE_CATEGORY_THEME
  	if err := preference.IsValid(); err == nil {
  		t.Fatal()
  	}
  
  	preference.Value = `{"color": "#ff0000", "color2": "#faf"}`
  	if err := preference.IsValid(); err != nil {
  		t.Fatal(err)
  	}
  }
  
  func TestPreferencePreUpdate(t *testing.T) {
  	preference := Preference{
  		Category: PREFERENCE_CATEGORY_THEME,
  		Value:    `{"color": "#ff0000", "color2": "#faf", "codeTheme": "github", "invalid": "invalid"}`,
  	}
  
  	preference.PreUpdate()
  
  	var props map[string]string
  	if err := json.NewDecoder(strings.NewReader(preference.Value)).Decode(&props); err != nil {
  		t.Fatal(err)
  	}
  
  	if props["color"] != "#ff0000" || props["color2"] != "#faf" || props["codeTheme"] != "github" {
  		t.Fatal("shouldn't have changed valid props")
  	}
  
  	if props["invalid"] == "invalid" {
  		t.Fatal("should have changed invalid prop")
  	}
  }
  