File tree 2 files changed +4
-4
lines changed
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)
39
39
SELECT descendant_id
40
40
FROM #{ _ct . quoted_hierarchy_table_name }
41
41
WHERE ancestor_id = #{ _ct . quote ( self . id ) }
42
- GROUP BY 1
42
+ GROUP BY descendant_id
43
43
HAVING MAX(#{ _ct . quoted_hierarchy_table_name } .generations) = #{ generation_level . to_i }
44
44
) AS descendants ON (#{ _ct . quoted_table_name } .#{ _ct . base_class . primary_key } = descendants.descendant_id)
45
45
SQL
@@ -74,7 +74,7 @@ def leaves
74
74
INNER JOIN (
75
75
SELECT ancestor_id
76
76
FROM #{ _ct . quoted_hierarchy_table_name }
77
- GROUP BY 1
77
+ GROUP BY ancestor_id
78
78
HAVING MAX(#{ _ct . quoted_hierarchy_table_name } .generations) = 0
79
79
) AS leaves ON (#{ _ct . quoted_table_name } .#{ primary_key } = leaves.ancestor_id)
80
80
SQL
@@ -100,7 +100,7 @@ def find_all_by_generation(generation_level)
100
100
INNER JOIN (
101
101
SELECT ancestor_id, descendant_id
102
102
FROM #{ _ct . quoted_hierarchy_table_name }
103
- GROUP BY 1, 2
103
+ GROUP BY ancestor_id, descendant_id
104
104
HAVING MAX(generations) = #{ generation_level . to_i }
105
105
) AS descendants ON (
106
106
#{ _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
72
72
JOIN (
73
73
SELECT descendant_id, max(generations) AS max_depth
74
74
FROM #{ _ct . quoted_hierarchy_table_name }
75
- GROUP BY 1
75
+ GROUP BY descendant_id
76
76
) AS depths ON depths.descendant_id = anc.#{ _ct . quoted_id_column_name }
77
77
SQL
78
78
joins ( join_sql )
You can’t perform that action at this time.
0 commit comments