mate_query.string module

Module implementing an enhanced string column type for SQLAlchemy with a support for regular expression operators in Postgres and SQLite.

class mate_query.string.StringComparator(expression)

Bases: sqlalchemy.ext.hybrid.Comparator

A custom comparator for strings supporting a re_match operation.

operate(op: Any, other: Any, **_kwargs: Any) Any

Operate on an argument.

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

Overriding this on a subclass can allow common behavior to be applied to all operations. For example, overriding 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))
  • op – Operator callable.

  • *other – the ‘other’ side of the operation. Will be a single scalar for most operations.

  • **kwargs – modifiers. These may be passed by special operators such as ColumnOperators.contains().

  • op (Any) –

  • other (Any) –

  • _kwargs (Any) –

Return type


re_match(other: re.Pattern) mate_query.string._RegexMatchExpression

other (re.Pattern) –

Return type