'Produce an expression that tests a scalar reference against
particular criterion, using EXISTS.
An expression like::
session.query(MyClass).filter(
MyClass.somereference.has(SomeRelated.x==2)
Will produce a query like::
SELECT * FROM my_table WHERE
EXISTS (SELECT 1 FROM related WHERE
related.id==my_table.related_id AND related.x=2)
Because :meth:`~.RelationshipProperty.Comparator.has` uses
a correlated subquery, its performance is not nearly as
good when compared against large target tables as that of
using a join.
:meth:`~.RelationshipProperty.Comparator.has` is only
valid for scalar references, i.e. a :func:`.relationship`
that has ``uselist=False``.  For collection references,
use :meth:`~.RelationshipProperty.Comparator.any`.'

def has(self, criterion=None, **kwargs):

    if self.property.uselist:
        raise sa_exc.InvalidRequestError("'has()'    not    implemented    for    collections.        Use    any().")
    return self._criterion_exists(criterion, **kwargs)
