File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def find_all_by_generation(generation_level)
3939 SELECT descendant_id
4040 FROM #{ _ct . quoted_hierarchy_table_name }
4141 WHERE ancestor_id = #{ _ct . quote ( self . id ) }
42- GROUP BY 1
42+ GROUP BY descendant_id
4343 HAVING MAX(#{ _ct . quoted_hierarchy_table_name } .generations) = #{ generation_level . to_i }
4444 ) AS descendants ON (#{ _ct . quoted_table_name } .#{ _ct . base_class . primary_key } = descendants.descendant_id)
4545 SQL
@@ -74,7 +74,7 @@ def leaves
7474 INNER JOIN (
7575 SELECT ancestor_id
7676 FROM #{ _ct . quoted_hierarchy_table_name }
77- GROUP BY 1
77+ GROUP BY ancestor_id
7878 HAVING MAX(#{ _ct . quoted_hierarchy_table_name } .generations) = 0
7979 ) AS leaves ON (#{ _ct . quoted_table_name } .#{ primary_key } = leaves.ancestor_id)
8080 SQL
@@ -100,7 +100,7 @@ def find_all_by_generation(generation_level)
100100 INNER JOIN (
101101 SELECT ancestor_id, descendant_id
102102 FROM #{ _ct . quoted_hierarchy_table_name }
103- GROUP BY 1, 2
103+ GROUP BY ancestor_id, descendant_id
104104 HAVING MAX(generations) = #{ generation_level . to_i }
105105 ) AS descendants ON (
106106 #{ _ct . quoted_table_name } .#{ primary_key } = descendants.descendant_id
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ def roots_and_descendants_preordered
7272 JOIN (
7373 SELECT descendant_id, max(generations) AS max_depth
7474 FROM #{ _ct . quoted_hierarchy_table_name }
75- GROUP BY 1
75+ GROUP BY descendant_id
7676 ) AS depths ON depths.descendant_id = anc.#{ _ct . quoted_id_column_name }
7777 SQL
7878 joins ( join_sql )
You can’t perform that action at this time.
0 commit comments