Last active
July 14, 2021 22:12
-
-
Save msullivan/ecacbf65e8da0142e9710e9b429a8a9c to your computer and use it in GitHub Desktop.
simulate a FULL OUTER JOIN in edgeql
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
# Do a FULL OUTER JOIN on User.name[0] = Card.name[0] | |
# (the seed computable is to demonstrate that it works with computed data) | |
WITH | |
L := User { seed := random() }, | |
R := Card, | |
joined := DISTINCT { | |
(FOR l IN {L} UNION ([l.id], [(SELECT R FILTER l.name[0] = R.name[0]).id] ?? <array<uuid>>[])), | |
(FOR r IN {R} UNION (([(SELECT L FILTER L.name[0] = r.name[0]).id] ?? <array<uuid>>[]), [r.id])), | |
}, | |
FOR row in {joined} UNION ( | |
{ | |
l := (SELECT L { name, seed } FILTER .id = array_unpack(row.0) LIMIT 1), | |
r := (SELECT R { name, cost, element } FILTER .id = array_unpack(row.1) LIMIT 1), | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment