aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/table_metadata.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-01-29 08:34:33 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-01-29 09:24:14 +0900
commit159b21b59dba120e58eeb8bff89b9d322e720c44 (patch)
tree4961855b5e5d01f0dd9332869f94539b81422caa /activerecord/lib/active_record/table_metadata.rb
parent6b8c161fc2cabdadd33826d21f9bd099041b8069 (diff)
downloadrails-159b21b59dba120e58eeb8bff89b9d322e720c44.tar.gz
rails-159b21b59dba120e58eeb8bff89b9d322e720c44.tar.bz2
rails-159b21b59dba120e58eeb8bff89b9d322e720c44.zip
Fix expanding an array of `composed_of` objects which have multiple mappings
Follow up of #31724. If `composed_of` objects have multiple mappings, array predicate handler can not correctly handle the expanded condition. We need to handle it like polymorphic association objects.
Diffstat (limited to 'activerecord/lib/active_record/table_metadata.rb')
-rw-r--r--activerecord/lib/active_record/table_metadata.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/table_metadata.rb b/activerecord/lib/active_record/table_metadata.rb
index 0459cbdc59..507f08a974 100644
--- a/activerecord/lib/active_record/table_metadata.rb
+++ b/activerecord/lib/active_record/table_metadata.rb
@@ -65,6 +65,14 @@ module ActiveRecord
association && association.polymorphic?
end
+ def aggregated_with?(aggregation_name)
+ klass && reflect_on_aggregation(aggregation_name)
+ end
+
+ def reflect_on_aggregation(aggregation_name)
+ klass.reflect_on_aggregation(aggregation_name)
+ end
+
# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected