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:
commit
d92a0d040d
1 changed files with 3 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue