fix: data conflict handler

This commit is contained in:
Steven
2023-12-10 10:07:26 +08:00
parent d275713aff
commit 0127e08a28
5 changed files with 14 additions and 30 deletions

View File

@ -11,9 +11,11 @@ import (
func (d *DB) UpsertSystemSetting(ctx context.Context, upsert *store.SystemSetting) (*store.SystemSetting, error) {
qb := squirrel.Insert("system_setting").
Columns("name", "value", "description").
Values(upsert.Name, upsert.Value, upsert.Description)
Values(upsert.Name, upsert.Value, upsert.Description).
Suffix("ON CONFLICT (name) DO UPDATE SET value = EXCLUDED.value, description = EXCLUDED.description").
PlaceholderFormat(squirrel.Dollar)
query, args, err := qb.PlaceholderFormat(squirrel.Dollar).ToSql()
query, args, err := qb.ToSql()
if err != nil {
return nil, err
}