diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-07-17 17:37:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-17 17:37:39 -0400 |
commit | 589adea81c2f6ff04178a09986a455f6b7062dcc (patch) | |
tree | eafb27c1e5f3ce3b13f3d3431e6504b2452e5ba9 /activerecord/lib/active_record/associations | |
parent | f0b16afa581fd0ba51583bc026a3e300add2287a (diff) | |
parent | ea09bf5419ec752dd020d26b03533afa457d09d6 (diff) | |
download | rails-589adea81c2f6ff04178a09986a455f6b7062dcc.tar.gz rails-589adea81c2f6ff04178a09986a455f6b7062dcc.tar.bz2 rails-589adea81c2f6ff04178a09986a455f6b7062dcc.zip |
Merge pull request #29828 from kamipo/fix_using_custom_table_with_joins
Fix `JoinDependency` with using a custom table
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_base.rb | 11 |
2 files changed, 9 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 5c8ecf42b4..4a3fb6eaec 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -88,11 +88,11 @@ module ActiveRecord # associations # => [:appointments] # joins # => [] # - def initialize(base, associations, joins, eager_loading: true) + def initialize(base, table, associations, joins, eager_loading: true) @alias_tracker = AliasTracker.create_with_joins(base.connection, base.table_name, joins) @eager_loading = eager_loading tree = self.class.make_tree associations - @join_root = JoinBase.new base, build(tree, base) + @join_root = JoinBase.new(base, table, build(tree, base)) @join_root.children.each { |child| construct_tables! @join_root, child } end diff --git a/activerecord/lib/active_record/associations/join_dependency/join_base.rb b/activerecord/lib/active_record/associations/join_dependency/join_base.rb index f5f22ebfca..d4e26d5397 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_base.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_base.rb @@ -4,14 +4,17 @@ module ActiveRecord module Associations class JoinDependency # :nodoc: class JoinBase < JoinPart # :nodoc: + attr_reader :table + + def initialize(base_klass, table, children) + super(base_klass, children) + @table = table + end + def match?(other) return true if self == other super && base_klass == other.base_klass end - - def table - base_klass.arel_table - end end end end |