'Produce a proxied \'contains\' expression using EXISTS.
This expression will be a composed product
using the :meth:`.RelationshipProperty.Comparator.any`
, :meth:`.RelationshipProperty.Comparator.has`,
and/or :meth:`.RelationshipProperty.Comparator.contains`
operators of the underlying proxied attributes.'

def contains(self, obj):

    if (self.scalar and (not self._value_is_scalar)):
        return self._comparator.has(getattr(self.target_class, self.value_attr).contains(obj))
    else:
        return self._comparator.any(**{self.value_attr: obj})
