sqlalchemy :: sql :: type_api :: TypeDecorator :: Comparator :: Class Comparator
[hide private]
[frames] | no frames]

Class Comparator


Base class for custom comparison operations defined at the type level. See :attr:`.TypeEngine.comparator_factory`.

Instance Methods [hide private]
 
operate(self, op, *other, **kwargs)
Operate on an argument.
 
reverse_operate(self, op, other, **kwargs)
Reverse operate on an argument.

Inherited from TypeEngine.Comparator: __init__, __reduce__

Inherited from TypeEngine.Comparator (private): _adapt_expression

Inherited from operators.ColumnOperators: __add__, __contains__, __div__, __eq__, __ge__, __getitem__, __gt__, __hash__, __le__, __lshift__, __lt__, __mod__, __mul__, __ne__, __neg__, __radd__, __rdiv__, __rmod__, __rmul__, __rshift__, __rsub__, __rtruediv__, __sub__, __truediv__, asc, between, collate, concat, contains, desc, distinct, endswith, ilike, in_, is_, isnot, like, match, notilike, notin_, notlike, nullsfirst, nullslast, startswith

Inherited from operators.Operators: __and__, __invert__, __or__, op

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from TypeEngine.Comparator: BOOLEANTYPE, default_comparator

Inherited from operators.ColumnOperators: timetuple

Properties [hide private]

Inherited from TypeEngine.Comparator: expr, type

Inherited from object: __class__

Method Details [hide private]

operate(self, op, *other, **kwargs)

 
Operate on an argument.

This is the lowest level of operation, raises
:class:`NotImplementedError` by default.

Overriding this on a subclass can allow common
behavior to be applied to all operations.
For example, overriding :class:`.ColumnOperators`
to apply ``func.lower()`` to the left and right
side::

    class MyComparator(ColumnOperators):
        def operate(self, op, other):
            return op(func.lower(self), func.lower(other))

:param op:  Operator callable.
:param \*other: the 'other' side of the operation. Will
 be a single scalar for most operations.
:param \**kwargs: modifiers.  These may be passed by special
 operators such as :meth:`ColumnOperators.contains`.

Overrides: operators.Operators.operate
(inherited documentation)

reverse_operate(self, op, other, **kwargs)

 

Reverse operate on an argument.

Usage is the same as :meth:`operate`.

Overrides: operators.Operators.reverse_operate
(inherited documentation)