Skip to content

Commit

Permalink
Delegate alias_tracker creation to AR Relation rather than doing it o…
Browse files Browse the repository at this point in the history
…urselves. Closes #1491.
  • Loading branch information
robinator authored and gregmolnar committed Jul 10, 2024
1 parent 489bf8f commit 007f9e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ransack/adapters/active_record/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def klassify(obj)
#
def join_sources
base, joins = begin
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, @object.table.name, [])
alias_tracker = @object.alias_tracker
constraints = @join_dependency.join_constraints(@object.joins_values, alias_tracker, @object.references_values)

[
Expand Down Expand Up @@ -278,7 +278,7 @@ def build_joins(relation)

join_list = join_nodes + convert_join_strings_to_ast(relation.table, string_joins)

alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, relation.table.name, join_list)
alias_tracker = relation.alias_tracker(join_list)
join_dependency = Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins, Arel::Nodes::OuterJoin)
join_dependency.instance_variable_set(:@alias_tracker, alias_tracker)
join_nodes.each do |join|
Expand Down

0 comments on commit 007f9e1

Please sign in to comment.