Skip to content
  • Philippe Huibonhoa's avatar
    359adaed
    Fixed `where` for polymorphic associations when passed an array containing different types. · 359adaed
    Philippe Huibonhoa authored
    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))
    359adaed
    Fixed `where` for polymorphic associations when passed an array containing different types.
    Philippe Huibonhoa authored
    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))
Loading