'Implement the ``!=`` operator.
In a many-to-one context, such as::
MyClass.some_prop != <some object>
This will typically produce a clause such as::
mytable.related_id != <some id>
Where ``<some id>`` is the primary key of the
given object.
The ``!=`` operator provides partial functionality for non-
many-to-one comparisons:
* Comparisons against collections are not supported.
Use
:meth:`~.RelationshipProperty.Comparator.contains`
in conjunction with :func:`~.expression.not_`.
* Compared to a scalar one-to-many, will produce a
clause that compares the target columns in the parent to
the given target.
* Compared to a scalar many-to-many, an alias
of the association table will be rendered as
well, forming a natural join that is part of the
main body of the query. This will not work for
queries that go beyond simple AND conjunctions of
comparisons, such as those which use OR. Use
explicit joins, outerjoins, or
:meth:`~.RelationshipProperty.Comparator.has` in
conjunction with :func:`~.expression.not_` for
more comprehensive non-many-to-one scalar
membership tests.
* Comparisons against ``None`` given in a one-to-many
or many-to-many context produce an EXISTS clause.'

def __ne__(self, other):

    if isinstance(other, (util.NoneType, expression.Null)):
        if (self.property.direction == MANYTOONE):
            return sql.or_(*[(x != None) for x in self.property._calculated_foreign_keys])
        else:
            return self._criterion_exists()
    elif self.property.uselist:
        raise sa_exc.InvalidRequestError("Can't    compare    a    collection    to    an    object    or    collection;    use    contains()    to    test    for    membership.")
    else:
        return self.__negated_contains_or_equals(other)
