mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
359adaedd9
When passing in an array of different types of objects to `where`, it would only take into account the class of the first object in the array. PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)]) # => SELECT "price_estimates".* FROM "price_estimates" WHERE ("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" IN (1, 2)) This is fixed to properly look for any records matching both type and id: PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)]) # => SELECT "price_estimates".* FROM "price_estimates" WHERE (("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" = 1) OR ("price_estimates"."estimate_of_type" = 'Car' AND "price_estimates"."estimate_of_id" = 2))
16 lines
239 B
YAML
16 lines
239 B
YAML
sapphire_1:
|
|
price: 10
|
|
estimate_of: sapphire (Treasure)
|
|
|
|
sapphire_2:
|
|
price: 20
|
|
estimate_of: sapphire (Treasure)
|
|
|
|
diamond:
|
|
price: 30
|
|
estimate_of: diamond (Treasure)
|
|
|
|
honda:
|
|
price: 40
|
|
estimate_of_type: Car
|
|
estimate_of_id: 1
|