diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-12-31 22:16:07 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-01 05:26:35 +0900 |
commit | e4c6a84fb15c7856b66d8fb478d396d68ba50c34 (patch) | |
tree | eb77df908e26a3911c8fb0d4ca38dfbe3100556e /activerecord/lib | |
parent | b5580e439a24b64eba5aede0965f2c4f57463792 (diff) | |
download | rails-e4c6a84fb15c7856b66d8fb478d396d68ba50c34.tar.gz rails-e4c6a84fb15c7856b66d8fb478d396d68ba50c34.tar.bz2 rails-e4c6a84fb15c7856b66d8fb478d396d68ba50c34.zip |
Remove `association_primary_key_type` from `AssociationReflection` and `ThroughReflection`
This method was introduced in #26718, which is internally used only in
`CollectionAssociation`. There is no need to be in the reflection
classes.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 8 |
2 files changed, 2 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 921237a735..de8afc9ccb 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -52,11 +52,11 @@ module ActiveRecord # Implements the ids writer method, e.g. foo.item_ids= for Foo.has_many :items def ids_writer(ids) - pk_type = reflection.association_primary_key_type + primary_key = reflection.association_primary_key + pk_type = klass.type_for_attribute(primary_key.to_s) ids = Array(ids).reject(&:blank?) ids.map! { |i| pk_type.cast(i) } - primary_key = reflection.association_primary_key records = klass.where(primary_key => ids).index_by do |r| r.public_send(primary_key) end.values_at(*ids).compact diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index e45228a2ec..a3f8bfd1f1 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -458,10 +458,6 @@ module ActiveRecord options[:primary_key] || primary_key(klass || self.klass) end - def association_primary_key_type - klass.type_for_attribute(association_primary_key.to_s) - end - def active_record_primary_key @active_record_primary_key ||= options[:primary_key] || primary_key(active_record) end @@ -859,10 +855,6 @@ module ActiveRecord actual_source_reflection.options[:primary_key] || primary_key(klass || self.klass) end - def association_primary_key_type - klass.type_for_attribute(association_primary_key.to_s) - end - # Gets an array of possible <tt>:through</tt> source reflection names in both singular and plural form. # # class Post < ActiveRecord::Base |