Skip to content

Instantly share code, notes, and snippets.

@sgrif sgrif/hell.sql Secret
Created Aug 29, 2019

Embed
What would you like to do?
SELECT ... FROM crates ...
WHERE (
(canon_crate_name(name) = canon_crate_name("foo")) IS NOT NULL
AND
(canon_crate_name(name) = canon_crate_name("foo")) <
(
SELECT canon_crate_name(name) = canon_crate_name("foo")
FROM crates
WHERE id = 1234
LIMIT 1
)
IS NOT FALSE
) OR (
(canon_crate_name(name) = canon_crate_name("foo")) IS NOT DISTINCT FROM
(
SELECT canon_crate_name(name) = canon_crate_name("foo")
FROM crates
WHERE id = 1234
LIMIT 1
)
AND (
downloads IS NOT NULL
AND
downloads <
(
SELECT downloads
FROM crates
WHERE id = 1234
LIMIT 1
)
IS NOT FALSE
)
) OR (
(canon_crate_name(name) = canon_crate_name("foo")) IS NOT DISTINCT FROM
(
SELECT canon_crate_name(name) = canon_crate_name("foo")
FROM crates
WHERE id = 1234
LIMIT 1
)
AND
downloads IS NOT DISTINCT FROM
(
SELECT downloads
FROM crates
WHERE id = 1234
LIMIT 1
)
IS NOT FALSE
AND (
id IS NULL
OR
id >
(
SELECT id
FROM crates
WHERE id = 1234
LIMIT 1
)
IS TRUE
)
)
ORDER BY
canon_crate_name(name) = canon_crate_name("foo") DESC,
downloads DESC,
id ASC
LIMIT 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.