Created
June 16, 2017 21:11
-
-
Save Ragmaanir/c649cfbbd1fe4918fd5f18dc934bf6c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
IF user_id IS NULL THEN | |
INSERT INTO scores(issue_id, user_id, group_id, value, created_at, updated_at) | |
VALUES($1, NULL, $3, $4, $5, $6) | |
ON CONFLICT(issue_id, group_id) DO UPDATE | |
SET value = $4, updated_at = $6 | |
ELSE | |
INSERT INTO scores(issue_id, user_id, group_id, value, created_at, updated_at) | |
VALUES($1, $2, NULL, $4, $5, $6) | |
ON CONFLICT(issue_id, user_id) DO UPDATE | |
SET value = $4, updated_at = $6 | |
END IF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment