Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Use excluded.xxx in the ON CONFLICT statement for upserting instance_user

天舟8f9be8718b8d
diff --git a/store/instance_user.go b/store/instance_user.go
index 8dd3ef165b..e9bd8bcf5c 100644
--- a/store/instance_user.go
+++ b/store/instance_user.go
@@ -94,7 +94,9 @@ func upsertInstanceUser(ctx context.Context, tx *Tx, upsert *api.InstanceUserUps
grant
)
VALUES (?, ?, ?, ?, ?)
- ON CONFLICT (instance_id, name) DO UPDATE SET updater_id = ?, grant = ?
+ ON CONFLICT (instance_id, name) DO UPDATE SET
+ updater_id = excluded.updater_id,
+ grant = excluded.grant
RETURNING id, instance_id, name, grant
`,
upsert.CreatorId,
@@ -102,8 +104,6 @@ func upsertInstanceUser(ctx context.Context, tx *Tx, upsert *api.InstanceUserUps
upsert.InstanceId,
upsert.Name,
upsert.Grant,
- upsert.CreatorId,
- upsert.Grant,
)
if err != nil {