Correctly handle relations as values in where() for polymorphic associations.