Created
December 1, 2010 16:49
-
-
Save rymai/723780 to your computer and use it in GitHub Desktop.
Arel 2.0.5 LEFT OUTER JOIN bug
This file contains 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
TableA | |
has_and_belongs_to_many :table_b | |
TableB | |
has_and_belongs_to_many :table_a | |
TableC is the join table of TableA and TableB | |
--------------------------------------- | |
Arel 2.0.4 (Good query) | |
SELECT COUNT(DISTINCT "table_a"."id") | |
FROM "table_a" | |
LEFT OUTER JOIN "table_c" ON | |
"table_c"."table_a_id" = "table_a"."id" | |
LEFT OUTER JOIN "table_b" ON | |
"table_b"."id" = "table_c"."table_b_id" | |
--------------------------------------- | |
Arel 2.0.5 (Fucked-up query) | |
SELECT COUNT(DISTINCT "table_a"."id") | |
FROM "table_a" | |
LEFT OUTER JOIN "table_c" ON | |
'table_c' AND "table_c" AND 'table_a_id' AND "table_c"."table_a_id" AND 0 AND "table_a" AND 'id' AND "table_a"."id" AND | |
"table_c"."table_a_id" = "table_a"."id" | |
LEFT OUTER JOIN "table_b" ON | |
0 AND "table_b" AND 'id' AND "table_b"."id" AND 0 AND "table_c" AND 'table_b_id' AND "table_c"."table_b_id" AND | |
"table_b"."id" = "table_c"."table_b_id" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment