Skip to content

Commit

Permalink
fix upsert sql
Browse files Browse the repository at this point in the history
  • Loading branch information
Szer committed Sep 28, 2023
1 parent 82dcc88 commit b5ae0c4
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/VahterBanBot/DB.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,29 @@ ON CONFLICT (id) DO UPDATE
WHEN EXCLUDED.username != "user".username THEN COALESCE(EXCLUDED.username, "user".username)
ELSE "user".username
END,
updated_at =
CASE
WHEN EXCLUDED.updated_at != "user".updated_at THEN EXCLUDED.username
ELSE "user".updated_at
END,
ban_reason =
CASE
WHEN EXCLUDED.ban_reason != "user".ban_reason THEN EXCLUDED.ban_reason
WHEN EXCLUDED.ban_reason != "user".ban_reason THEN COALESCE(EXCLUDED.ban_reason, "user".ban_reason)
ELSE "user".ban_reason
END,
banned_at =
CASE
WHEN EXCLUDED.banned_at != "user".banned_at THEN EXCLUDED.ban_reason
WHEN EXCLUDED.banned_at != "user".banned_at THEN COALESCE(EXCLUDED.banned_at, "user".banned_at)
ELSE "user".banned_at
END,
banned_by =
CASE
WHEN EXCLUDED.banned_by != "user".banned_by THEN EXCLUDED.ban_reason
WHEN EXCLUDED.banned_by != "user".banned_by THEN COALESCE(EXCLUDED.banned_by, "user".banned_by)
ELSE "user".banned_by
END,
created_at =
CASE
WHEN EXCLUDED.created_at != "user".created_at THEN EXCLUDED.ban_reason
WHEN EXCLUDED.created_at != "user".created_at THEN EXCLUDED.created_at
ELSE "user".created_at
END,
updated_at =
CASE
WHEN EXCLUDED.updated_at != "user".updated_at THEN EXCLUDED.ban_reason
WHEN EXCLUDED.updated_at != "user".updated_at THEN EXCLUDED.updated_at
ELSE "user".updated_at
END
RETURNING *;
Expand Down

0 comments on commit b5ae0c4

Please sign in to comment.