diff options
Diffstat (limited to 'store/sqlstore/preference_store.go')
-rw-r--r-- | store/sqlstore/preference_store.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/store/sqlstore/preference_store.go b/store/sqlstore/preference_store.go index 6765a74f8..a97c3aea7 100644 --- a/store/sqlstore/preference_store.go +++ b/store/sqlstore/preference_store.go @@ -18,10 +18,6 @@ type SqlPreferenceStore struct { SqlStore } -const ( - FEATURE_TOGGLE_PREFIX = "feature_enabled_" -) - func NewSqlPreferenceStore(sqlStore SqlStore) store.PreferenceStore { s := &SqlPreferenceStore{sqlStore} @@ -50,7 +46,7 @@ func (s SqlPreferenceStore) DeleteUnusedFeatures() { WHERE Category = :Category AND Value = :Value - AND Name LIKE '` + FEATURE_TOGGLE_PREFIX + `%'` + AND Name LIKE '` + store.FEATURE_TOGGLE_PREFIX + `%'` queryParams := map[string]string{ "Category": model.PREFERENCE_CATEGORY_ADVANCED_SETTINGS, @@ -105,7 +101,7 @@ func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *mode "Value": preference.Value, } - if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL { + if s.DriverName() == model.DATABASE_DRIVER_MYSQL { if _, err := transaction.Exec( `INSERT INTO Preferences @@ -116,7 +112,7 @@ func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *mode Value = :Value`, params); err != nil { result.Err = model.NewAppError("SqlPreferenceStore.save", "store.sql_preference.save.updating.app_error", nil, err.Error(), http.StatusInternalServerError) } - } else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES { + } else if s.DriverName() == model.DATABASE_DRIVER_POSTGRES { // postgres has no way to upsert values until version 9.5 and trying inserting and then updating causes transactions to abort count, err := transaction.SelectInt( `SELECT @@ -246,7 +242,7 @@ func (s SqlPreferenceStore) IsFeatureEnabled(feature, userId string) store.Store WHERE UserId = :UserId AND Category = :Category - AND Name = :Name`, map[string]interface{}{"UserId": userId, "Category": model.PREFERENCE_CATEGORY_ADVANCED_SETTINGS, "Name": FEATURE_TOGGLE_PREFIX + feature}); err != nil { + AND Name = :Name`, map[string]interface{}{"UserId": userId, "Category": model.PREFERENCE_CATEGORY_ADVANCED_SETTINGS, "Name": store.FEATURE_TOGGLE_PREFIX + feature}); err != nil { result.Err = model.NewAppError("SqlPreferenceStore.IsFeatureEnabled", "store.sql_preference.is_feature_enabled.app_error", nil, err.Error(), http.StatusInternalServerError) } else { result.Data = value == "true" |