Skip to content

Commit

Permalink
fixed wrong comparison of nullable values
Browse files Browse the repository at this point in the history
  • Loading branch information
Szer committed Sep 28, 2023
1 parent 4cd11bb commit d9e47b7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/VahterBanBot/DB.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d9e47b7

Please sign in to comment.