Skip to content

Commit d056bfe

Browse files
committed
Merge branch 'group_by_for_mssql' of https://github.com/MartinKoerner/closure_tree into pr200
2 parents d8dc649 + 6a30536 commit d056bfe

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
### 6.2.0
4+
5+
* Fix for [MySQL lock lengths](https://github.com/mceachen/closure_tree/issues/231).
6+
Thanks to [Liam](https://github.com/hut8)!
7+
* [Tom Smyth](https://github.com/hooverlunch) added [eager tree loading](https://github.com/mceachen/closure_tree/pull/232)
8+
* Merged [PR 200](https://github.com/mceachen/closure_tree/pull/200) which may or may not add support to SQLServer 2008 (but this is not a supported RDBMS).
9+
310
### 6.1.0
411

512
* Added official support for ActiveRecord 5.0! Thanks to [Abdelkader Boudih](https://github.com/seuros),

lib/closure_tree/finders.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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

lib/closure_tree/numeric_deterministic_ordering.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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)

lib/closure_tree/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ClosureTree
2-
VERSION = Gem::Version.new('6.1.0')
2+
VERSION = Gem::Version.new('6.2.0')
33
end

0 commit comments

Comments
 (0)