1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #25179 from kamipo/reuse_result_of_associated_table

Reuse a result of `table.associated_table(column)` in `AssociationQueryHandler.value_for`
This commit is contained in:
Sean Griffin 2016-05-30 16:22:43 -04:00
commit d92a0d040d

View file

@ -2,13 +2,14 @@ module ActiveRecord
class PredicateBuilder
class AssociationQueryHandler # :nodoc:
def self.value_for(table, column, value)
klass = if table.associated_table(column).polymorphic_association? && ::Array === value && value.first.is_a?(Base)
associated_table = table.associated_table(column)
klass = if associated_table.polymorphic_association? && ::Array === value && value.first.is_a?(Base)
PolymorphicArrayValue
else
AssociationQueryValue
end
klass.new(table.associated_table(column), value)
klass.new(associated_table, value)
end
def initialize(predicate_builder)