Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Fix 4.1 adapter under Rubinius #351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 10 additions & 5 deletions lib/squeel/adapters/active_record/4.1/relation_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,23 @@ def build_join_dependency(manager, joins)
%w(where having group order).each do |visitor|
define_method "#{visitor}_visit" do |values|
join_dependencies = [join_dependency] + stashed_join_dependencies
join_dependencies.each do |jd|
result = join_dependencies.find do |jd|
context = Adapters::ActiveRecord::Context.new(jd)
begin
return Visitors.const_get("#{visitor.capitalize}Visitor").new(context).accept!(values)
# Don't use return here, it breaks Rubinius 2.3.0.
break Visitors.const_get("#{visitor.capitalize}Visitor").new(context).accept!(values)
rescue Adapters::ActiveRecord::Context::NoParentFoundError => e
next
end
end

# Fail Safe, call the normal accept method.
context = Adapters::ActiveRecord::Context.new(join_dependency)
Visitors.const_get("#{visitor.capitalize}Visitor").new(context).accept(values)
if result.nil?
# Fail Safe, call the normal accept method.
context = Adapters::ActiveRecord::Context.new(join_dependency)
Visitors.const_get("#{visitor.capitalize}Visitor").new(context).accept(values)
else
result
end
end
end

Expand Down