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