diff --git a/src/VahterBanBot/DB.fs b/src/VahterBanBot/DB.fs index a94d72e..891f9eb 100644 --- a/src/VahterBanBot/DB.fs +++ b/src/VahterBanBot/DB.fs @@ -21,22 +21,26 @@ VALUES (@id, @username, @banReason, @bannedAt, @bannedBy, @createdAt, @updatedAt ON CONFLICT (id) DO UPDATE SET username = CASE - WHEN EXCLUDED.username != "user".username THEN COALESCE(EXCLUDED.username, "user".username) + WHEN EXCLUDED.username IS DISTINCT FROM "user".username + THEN COALESCE(EXCLUDED.username, "user".username) ELSE "user".username END, ban_reason = CASE - WHEN EXCLUDED.ban_reason != "user".ban_reason THEN COALESCE(EXCLUDED.ban_reason, "user".ban_reason) + WHEN EXCLUDED.ban_reason IS DISTINCT FROM "user".ban_reason + THEN COALESCE(EXCLUDED.ban_reason, "user".ban_reason) ELSE "user".ban_reason END, - banned_at = + banned_at = CASE - WHEN EXCLUDED.banned_at != "user".banned_at THEN COALESCE(EXCLUDED.banned_at, "user".banned_at) + WHEN EXCLUDED.banned_at IS DISTINCT FROM "user".banned_at + THEN COALESCE(EXCLUDED.banned_at, "user".banned_at) ELSE "user".banned_at END, - banned_by = + banned_by = CASE - WHEN EXCLUDED.banned_by != "user".banned_by THEN COALESCE(EXCLUDED.banned_by, "user".banned_by) + WHEN EXCLUDED.banned_by IS DISTINCT FROM "user".banned_by + THEN COALESCE(EXCLUDED.banned_by, "user".banned_by) ELSE "user".banned_by END, updated_at = GREATEST(EXCLUDED.updated_at, "user".updated_at)