Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(db): quote postgres keywords #383

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions server/store/database/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var _ store.SettingStore = (*settingsStore)(nil)
// GetAllowKeylessAccess implements store.SettingStore.
func (*settingsStore) GetAllowKeylessAccess(ctx context.Context, tx db.Handler) (bool, error) {
var allow bool
query := tx.Rebind(`SELECT value FROM settings WHERE key = "allow_keyless"`)
query := tx.Rebind(`SELECT value FROM settings WHERE "key" = 'allow_keyless'`)
if err := tx.GetContext(ctx, &allow, query); err != nil {
return false, db.WrapError(err)
}
Expand All @@ -25,7 +25,7 @@ func (*settingsStore) GetAllowKeylessAccess(ctx context.Context, tx db.Handler)
// GetAnonAccess implements store.SettingStore.
func (*settingsStore) GetAnonAccess(ctx context.Context, tx db.Handler) (access.AccessLevel, error) {
var level string
query := tx.Rebind(`SELECT value FROM settings WHERE key = "anon_access"`)
query := tx.Rebind(`SELECT value FROM settings WHERE "key" = 'anon_access'`)
if err := tx.GetContext(ctx, &level, query); err != nil {
return access.NoAccess, db.WrapError(err)
}
Expand All @@ -34,14 +34,14 @@ func (*settingsStore) GetAnonAccess(ctx context.Context, tx db.Handler) (access.

// SetAllowKeylessAccess implements store.SettingStore.
func (*settingsStore) SetAllowKeylessAccess(ctx context.Context, tx db.Handler, allow bool) error {
query := tx.Rebind(`UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE key = "allow_keyless"`)
query := tx.Rebind(`UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE "key" = 'allow_keyless'`)
_, err := tx.ExecContext(ctx, query, allow)
return db.WrapError(err)
}

// SetAnonAccess implements store.SettingStore.
func (*settingsStore) SetAnonAccess(ctx context.Context, tx db.Handler, level access.AccessLevel) error {
query := tx.Rebind(`UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE key = "anon_access"`)
query := tx.Rebind(`UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE "key" = 'anon_access'`)
_, err := tx.ExecContext(ctx, query, level.String())
return db.WrapError(err)
}