This commit is contained in:
David Rodríguez 2020-11-23 18:45:40 +01:00
parent 46212f1212
commit a8ae1ce26b
No known key found for this signature in database
GPG Key ID: 1008A258BB37309C
2 changed files with 9 additions and 2 deletions

View File

@ -28,9 +28,14 @@ module Polyamorous
end
end
def join_constraints(joins_to_add, alias_tracker)
def join_constraints(joins_to_add, alias_tracker, references)
@alias_tracker = alias_tracker
@joined_tables = {}
@references = {}
references.each do |table_name|
@references[table_name.to_sym] = table_name if table_name.is_a?(String)
end
joins = make_join_constraints(join_root, join_type)

View File

@ -99,7 +99,9 @@ module Ransack
def join_sources
base, joins = begin
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, @object.table.name, [])
constraints = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
constraints = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_1_ALPHA)
@join_dependency.join_constraints(@object.joins_values, alias_tracker, @object.references_values)
elsif ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
@join_dependency.join_constraints(@object.joins_values, alias_tracker)
else
@join_dependency.join_constraints(@object.joins_values, @join_type, alias_tracker)