aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-10-28 18:06:01 +0100
committerJon Leighton <j@jonathanleighton.com>2010-10-28 18:06:01 +0100
commitfc276e5635821e65c04b8961170cc6bd3c11b923 (patch)
tree9bd4ed018858611248e9b6aa7392dced92bc814a /activerecord/lib/active_record/associations.rb
parent8e53e058acea471eab7a1609dc150aa9fdbfa833 (diff)
parent6a3d6b7f1352efd3e7b931533740252b04850e27 (diff)
downloadrails-fc276e5635821e65c04b8961170cc6bd3c11b923.tar.gz
rails-fc276e5635821e65c04b8961170cc6bd3c11b923.tar.bz2
rails-fc276e5635821e65c04b8961170cc6bd3c11b923.zip
Merge branch 'master' into nested_has_many_through
Conflicts: activerecord/CHANGELOG activerecord/lib/active_record/association_preload.rb activerecord/lib/active_record/associations.rb activerecord/test/schema/schema.rb
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rw-r--r--activerecord/lib/active_record/associations.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 25be9a52ff..ee2e2765bc 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -2043,7 +2043,7 @@ module ActiveRecord
association_proxy = record.send("set_#{join_part.reflection.name}_target", association)
association_proxy.__send__(:set_inverse_instance, association, record)
end
-
+
# A JoinPart represents a part of a JoinDependency. It is an abstract class, inherited
# by JoinBase and JoinAssociation. A JoinBase represents the Active Record which
# everything else is being joined onto. A JoinAssociation represents an association which
@@ -2055,38 +2055,38 @@ module ActiveRecord
# this is the actual base model, for a JoinAssociation this is the target model of the
# association.
attr_reader :active_record
-
+
delegate :table_name, :column_names, :primary_key, :reflections, :sanitize_sql, :arel_engine, :to => :active_record
-
+
def initialize(active_record)
@active_record = active_record
@cached_record = {}
end
-
+
def ==(other)
raise NotImplementedError
end
-
+
# An Arel::Table for the active_record
def table
raise NotImplementedError
end
-
+
# The prefix to be used when aliasing columns in the active_record's table
def aliased_prefix
raise NotImplementedError
end
-
+
# The alias for the active_record's table
def aliased_table_name
raise NotImplementedError
end
-
+
# The alias for the primary key of the active_record's table
def aliased_primary_key
"#{aliased_prefix}_r0"
end
-
+
# An array of [column_name, alias] pairs for the table
def column_names_with_alias
unless defined?(@column_names_with_alias)
@@ -2116,7 +2116,7 @@ module ActiveRecord
class JoinBase < JoinPart # :nodoc:
# Extra joins provided when the JoinDependency was created
attr_reader :table_joins
-
+
def initialize(active_record, joins = nil)
super(active_record)
@table_joins = joins
@@ -2144,16 +2144,16 @@ module ActiveRecord
class JoinAssociation < JoinPart # :nodoc:
# The reflection of the association represented
attr_reader :reflection
-
+
# The JoinDependency object which this JoinAssociation exists within. This is mainly
# relevant for generating aliases which do not conflict with other joins which are
# part of the query.
attr_reader :join_dependency
-
+
# 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
@@ -2165,7 +2165,7 @@ module ActiveRecord
def initialize(reflection, join_dependency, parent = nil)
reflection.check_validity!
-
+
if reflection.options[:polymorphic]
raise EagerLoadPolymorphicError.new(reflection)
end
@@ -2192,7 +2192,7 @@ module ActiveRecord
self.parent == join_part
end
end
-
+
def join_to(relation)
# The chain starts with the target table, but we want to end with it here (makes
# more sense in this context)
@@ -2282,7 +2282,7 @@ module ActiveRecord
self.join_type = Arel::OuterJoin
joining_relation.joins(self)
end
-
+
def table
if @tables.last.is_a?(Array)
@tables.last.first