Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enhance compatibility for SqlServer 2008 #200

Merged
merged 2 commits into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ language: ruby
rvm:
- 2.0
- 2.2.3
- 2.3.0
- jruby-head

gemfile:
Expand Down
6 changes: 3 additions & 3 deletions lib/closure_tree/finders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def find_all_by_generation(generation_level)
SELECT descendant_id
FROM #{_ct.quoted_hierarchy_table_name}
WHERE ancestor_id = #{_ct.quote(self.id)}
GROUP BY 1
GROUP BY descendant_id
HAVING MAX(#{_ct.quoted_hierarchy_table_name}.generations) = #{generation_level.to_i}
) AS descendants ON (#{_ct.quoted_table_name}.#{_ct.base_class.primary_key} = descendants.descendant_id)
SQL
Expand Down Expand Up @@ -74,7 +74,7 @@ def leaves
INNER JOIN (
SELECT ancestor_id
FROM #{_ct.quoted_hierarchy_table_name}
GROUP BY 1
GROUP BY ancestor_id
HAVING MAX(#{_ct.quoted_hierarchy_table_name}.generations) = 0
) AS leaves ON (#{_ct.quoted_table_name}.#{primary_key} = leaves.ancestor_id)
SQL
Expand All @@ -100,7 +100,7 @@ def find_all_by_generation(generation_level)
INNER JOIN (
SELECT ancestor_id, descendant_id
FROM #{_ct.quoted_hierarchy_table_name}
GROUP BY 1, 2
GROUP BY ancestor_id, descendant_id
HAVING MAX(generations) = #{generation_level.to_i}
) AS descendants ON (
#{_ct.quoted_table_name}.#{primary_key} = descendants.descendant_id
Expand Down
2 changes: 1 addition & 1 deletion lib/closure_tree/numeric_deterministic_ordering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def roots_and_descendants_preordered
JOIN (
SELECT descendant_id, max(generations) AS max_depth
FROM #{_ct.quoted_hierarchy_table_name}
GROUP BY 1
GROUP BY descendant_id
) AS depths ON depths.descendant_id = anc.#{_ct.quoted_id_column_name}
SQL
joins(join_sql)
Expand Down