Skip to content

Commit

Permalink
patch bug fix for activerecord-hackery#1447
Browse files Browse the repository at this point in the history
  • Loading branch information
jberhang committed Mar 1, 2024
1 parent dbffa8b commit 87a57a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,21 @@ def construct_tables_for_association!(join_root, association)
private

def table_aliases_for(parent, node)
@joined_tables ||= {}
node.reflection.chain.map { |reflection|
alias_tracker.aliased_table_for(reflection.klass.arel_table) do
root = reflection == node.reflection
name = reflection.alias_candidate(parent.table_name)
root ? name : "#{name}_join"
table, terminated = @joined_tables[reflection]
root = reflection == node.reflection

if table && (!root || !terminated)
@joined_tables[reflection] = [table, true] if root
table
else
table = alias_tracker.aliased_table_for(reflection.klass.arel_table) do
name = reflection.alias_candidate(parent.table_name)
root ? name : "#{name}_join"
end
@joined_tables[reflection] ||= [table, root] if join_type == Arel::Nodes::OuterJoin
table
end
}
end
Expand Down Expand Up @@ -89,4 +99,4 @@ def walk_tree(associations, hash)
end

end
end
end
2 changes: 1 addition & 1 deletion lib/ransack/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Ransack
VERSION = '4.0.0'
VERSION = '4.0.1'
end

0 comments on commit 87a57a7

Please sign in to comment.