aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-09 11:23:45 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-09 11:23:45 -0700
commit217aedf1bf4255696c4f95976ee5056054dc9231 (patch)
tree2c446b98e08ead837428b4a9d433f0091af524af /activerecord/lib
parent40ad4397c1f992ff506a85c7a33a940f9e81a092 (diff)
downloadrails-217aedf1bf4255696c4f95976ee5056054dc9231.tar.gz
rails-217aedf1bf4255696c4f95976ee5056054dc9231.tar.bz2
rails-217aedf1bf4255696c4f95976ee5056054dc9231.zip
push parent up to the superclass
We always want a linked list back to the root node.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb7
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_base.rb4
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_part.rb7
3 files changed, 11 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
index f6a04ef9f1..e2ac892e71 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -9,10 +9,6 @@ module ActiveRecord
# The reflection of the association represented
attr_reader :reflection
- # A JoinBase instance representing the active record we are joining onto.
- # (So in Author.has_many :posts, the Author would be that base record.)
- attr_reader :parent
-
# What type of join will be generated, either Arel::InnerJoin (default) or Arel::OuterJoin
attr_accessor :join_type
@@ -25,11 +21,10 @@ module ActiveRecord
delegate :options, :through_reflection, :source_reflection, :chain, :to => :reflection
def initialize(reflection, index, parent, join_type, alias_tracker)
- super(reflection.klass)
+ super(reflection.klass, parent)
@reflection = reflection
@alias_tracker = alias_tracker
- @parent = parent
@join_type = join_type
@aliased_prefix = "t#{ index }"
@tables = construct_tables.reverse
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 c689d06594..c90ae80e4a 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_base.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_base.rb
@@ -4,6 +4,10 @@ module ActiveRecord
module Associations
class JoinDependency # :nodoc:
class JoinBase < JoinPart # :nodoc:
+ def initialize(klass)
+ super(klass, nil)
+ end
+
def ==(other)
other.class == self.class &&
other.base_klass == base_klass
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_part.rb b/activerecord/lib/active_record/associations/join_dependency/join_part.rb
index e27beb3b6f..3e9bdbfbab 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_part.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_part.rb
@@ -10,6 +10,10 @@ module ActiveRecord
class JoinPart # :nodoc:
include Enumerable
+ # A JoinBase instance representing the active record we are joining onto.
+ # (So in Author.has_many :posts, the Author would be that base record.)
+ attr_reader :parent
+
# The Active Record class which this join part is associated 'about'; for a JoinBase
# this is the actual base model, for a JoinAssociation this is the target model of the
# association.
@@ -17,8 +21,9 @@ module ActiveRecord
delegate :table_name, :column_names, :primary_key, :arel_engine, :to => :base_klass
- def initialize(base_klass)
+ def initialize(base_klass, parent)
@base_klass = base_klass
+ @parent = parent
@cached_record = {}
@column_names_with_alias = nil
@children = []