Commit b25319f9 authored by Andreas Brandl's avatar Andreas Brandl

More readable SQL query.

parent 3dbec2c2
...@@ -38,9 +38,13 @@ class MembersFinder ...@@ -38,9 +38,13 @@ class MembersFinder
<<~SQL <<~SQL
SELECT DISTINCT ON (user_id, invite_email) member_union.* SELECT DISTINCT ON (user_id, invite_email) member_union.*
FROM (#{union.to_sql}) AS member_union FROM (#{union.to_sql}) AS member_union
ORDER BY ORDER BY user_id,
user_id, invite_email, invite_email,
CASE WHEN type = 'ProjectMember' THEN 1 WHEN type = 'GroupMember' THEN 2 ELSE 3 END CASE
WHEN type = 'ProjectMember' THEN 1
WHEN type = 'GroupMember' THEN 2
ELSE 3
END
SQL SQL
else else
# Older versions of MySQL do not support window functions (and DISTINCT ON is postgres-specific). # Older versions of MySQL do not support window functions (and DISTINCT ON is postgres-specific).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment