aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-03-05 22:07:30 +0000
committerJon Leighton <j@jonathanleighton.com>2011-03-05 22:07:30 +0000
commit7fddb942624478a23173dfa379f7ade6a0fc9218 (patch)
treebca8fd4125105ff26f1e4cafba432760d8897d44 /activerecord/lib/active_record/associations
parentddf83d14f1c7ddae07a285a8ad7c45f652edc843 (diff)
downloadrails-7fddb942624478a23173dfa379f7ade6a0fc9218.tar.gz
rails-7fddb942624478a23173dfa379f7ade6a0fc9218.tar.bz2
rails-7fddb942624478a23173dfa379f7ade6a0fc9218.zip
Push source_type and polymorphic conditions out of ThroughAssociation and JoinDependency::JoinAssociation and into the reflection instead.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb18
-rw-r--r--activerecord/lib/active_record/associations/through_association.rb17
2 files changed, 0 insertions, 35 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 890e77fca9..5da3416023 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -76,8 +76,6 @@ module ActiveRecord
when :has_many, :has_one
key = reflection.foreign_key
foreign_key = reflection.active_record_primary_key
-
- conditions << polymorphic_conditions(reflection, table)
when :has_and_belongs_to_many
# For habtm, we need to deal with the join table at the same time as the
# target table (because unlike a :through association, there is no reflection
@@ -103,8 +101,6 @@ module ActiveRecord
when :belongs_to
key = reflection.association_primary_key
foreign_key = reflection.foreign_key
-
- conditions << source_type_conditions(reflection, foreign_table)
when :has_many, :has_one
key = reflection.foreign_key
foreign_key = reflection.source_reflection.active_record_primary_key
@@ -239,20 +235,6 @@ module ActiveRecord
end
end
- def source_type_conditions(reflection, foreign_table)
- if reflection.options[:source_type]
- foreign_table[reflection.source_reflection.foreign_type].
- eq(reflection.options[:source_type])
- end
- end
-
- def polymorphic_conditions(reflection, table)
- if reflection.options[:as]
- table[reflection.type].
- eq(reflection.active_record.base_class.name)
- end
- end
-
end
end
end
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb
index 8e9259a28d..11263d5def 100644
--- a/activerecord/lib/active_record/associations/through_association.rb
+++ b/activerecord/lib/active_record/associations/through_association.rb
@@ -89,7 +89,6 @@ module ActiveRecord
right_table,
left_table[left.foreign_key],
right_table[right.association_primary_key],
- polymorphic_conditions(left, left),
reflection_conditions(right_index)
)
when :has_and_belongs_to_many
@@ -107,7 +106,6 @@ module ActiveRecord
right_table,
left_table[left.association_primary_key],
right_table[left.foreign_key],
- source_type_conditions(left),
reflection_conditions(right_index)
)
when :has_many, :has_one
@@ -119,7 +117,6 @@ module ActiveRecord
right_table,
left_table[left.foreign_key],
right_table[left.source_reflection.active_record_primary_key],
- polymorphic_conditions(left, left.source_reflection),
reflection_conditions(right_index)
)
@@ -254,20 +251,6 @@ module ActiveRecord
end
end
- def polymorphic_conditions(reflection, polymorphic_reflection)
- if polymorphic_reflection.options[:as]
- tables[reflection][polymorphic_reflection.type].
- eq(polymorphic_reflection.active_record.base_class.name)
- end
- end
-
- def source_type_conditions(reflection)
- if reflection.options[:source_type]
- tables[reflection.through_reflection][reflection.foreign_type].
- eq(reflection.options[:source_type])
- end
- end
-
# TODO: Think about this in the context of nested associations
def stale_state
if through_reflection.macro == :belongs_to