aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/fixtures
diff options
context:
space:
mode:
authorPhilippe Huibonhoa <phuibonhoa@gmail.com>2015-11-21 01:58:17 -0800
committerPhilippe Huibonhoa <phuibonhoa@gmail.com>2016-02-16 10:41:26 -0800
commit359adaedd95293af3abde954279ad51e11856d57 (patch)
treec8b8ada1a07783f0e049f8b94fa283c9d83db19c /activerecord/test/fixtures
parentb0b61b62f9c27eff5b9e0797a0de0d35d64d1620 (diff)
downloadrails-359adaedd95293af3abde954279ad51e11856d57.tar.gz
rails-359adaedd95293af3abde954279ad51e11856d57.tar.bz2
rails-359adaedd95293af3abde954279ad51e11856d57.zip
Fixed `where` for polymorphic associations when passed an array containing different types.
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))
Diffstat (limited to 'activerecord/test/fixtures')
-rw-r--r--activerecord/test/fixtures/price_estimates.yml11
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/fixtures/price_estimates.yml b/activerecord/test/fixtures/price_estimates.yml
index 1149ab17a2..406d65a142 100644
--- a/activerecord/test/fixtures/price_estimates.yml
+++ b/activerecord/test/fixtures/price_estimates.yml
@@ -1,7 +1,16 @@
-saphire_1:
+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