Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rails 6.1 Compatability #32

Merged
merged 4 commits into from
May 26, 2021
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source 'https://rubygems.org'
gemspec

gem 'pg', '>= 0.21', '< 1.3'
gem 'activerecord', '>= 5.0', '< 6.1'
gem 'activerecord', '>= 5.0', '< 6.2'

group :local do
gem 'yard'
Expand Down
4 changes: 2 additions & 2 deletions activerecord-hierarchical_query.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = %w(lib)

spec.add_dependency 'activerecord', '>= 5.0', '< 6.1'
spec.add_dependency 'activerecord', '>= 5.0', '< 6.2'
spec.add_dependency 'pg', '>= 0.21', '< 1.3'

spec.add_development_dependency 'bundler', '~> 1.16'
spec.add_development_dependency 'bundler', '>= 1.16'
spec.add_development_dependency 'rake', '~> 12.3'
spec.add_development_dependency 'rspec', '~> 3.8'
spec.add_development_dependency 'database_cleaner', '~> 1.7'
Expand Down
23 changes: 23 additions & 0 deletions gemfiles/rails6.1.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "pg", ">= 0.21", "< 1.2"
gem "activerecord", "~> 6.1.0.rc1"

group :local do
gem "yard"
gem "redcarpet"
gem "github-markup"
gem "appraisal", ">= 1.0.0"
end

group :development do
gem "pry"
end

group :travis do
gem "coveralls", "~> 0.8.21"
end

gemspec path: "../"
20 changes: 17 additions & 3 deletions lib/active_record/hierarchical_query/cte/columns.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'arel/visitors/depth_first'

module ActiveRecord
module HierarchicalQuery
module CTE
Expand All @@ -18,7 +16,23 @@ def to_a

private
def connect_by_columns
@query.join_conditions.grep(Arel::Attributes::Attribute) { |column| column.name.to_s }
columns = []
traverse(@query.join_conditions) do |node|
columns << node.name.to_s if node.is_a?(Arel::Attributes::Attribute)
end
columns
end

def traverse(ast, &blck)
if ast && ast.respond_to?(:left) && ast.left
traverse(ast.left, &blck)
end

if ast && ast.respond_to?(:right) && ast.right
traverse(ast.right, &blck)
end

yield ast
end
end
end
Expand Down