__name__: str
def __call__(
- self,
- left: "Operators",
- right: Optional[Any] = None,
- *other: Any,
- **kwargs: Any,
+ self,
+ left: "Operators",
+ right: Optional[Any] = None,
+ *other: Any,
+ **kwargs: Any,
) -> "Operators":
...
return self.operate(inv)
def op(
- self,
- opstring: str,
- precedence: int = 0,
- is_comparison: bool = False,
- return_type: Optional[
- Union[Type["TypeEngine[Any]"], "TypeEngine[Any]"]
- ] = None,
- python_impl: Optional[Callable[..., Any]] = None,
+ self,
+ opstring: str,
+ precedence: int = 0,
+ is_comparison: bool = False,
+ return_type: Optional[
+ Union[Type["TypeEngine[Any]"], "TypeEngine[Any]"]
+ ] = None,
+ python_impl: Optional[Callable[..., Any]] = None,
) -> Callable[[Any], Operators]:
"""Produce a generic operator function.
return against
def bool_op(
- self,
- opstring: str,
- precedence: int = 0,
- python_impl: Optional[Callable[..., Any]] = None,
+ self,
+ opstring: str,
+ precedence: int = 0,
+ python_impl: Optional[Callable[..., Any]] = None,
) -> Callable[[Any], Operators]:
"""Return a custom boolean operator.
)
def operate(
- self, op: OperatorType, *other: Any, **kwargs: Any
+ self, op: OperatorType, *other: Any, **kwargs: Any
) -> Operators:
r"""Operate on an argument.
__sa_operate__ = operate
def reverse_operate(
- self, op: OperatorType, other: Any, **kwargs: Any
+ self, op: OperatorType, other: Any, **kwargs: Any
) -> Operators:
"""Reverse operate on an argument.
)
def __init__(
- self,
- opstring: str,
- precedence: int = 0,
- is_comparison: bool = False,
- return_type: Optional[
- Union[Type["TypeEngine[_T]"], "TypeEngine[_T]"]
- ] = None,
- natural_self_precedent: bool = False,
- eager_grouping: bool = False,
- python_impl: Optional[Callable[..., Any]] = None,
+ self,
+ opstring: str,
+ precedence: int = 0,
+ is_comparison: bool = False,
+ return_type: Optional[
+ Union[Type["TypeEngine[_T]"], "TypeEngine[_T]"]
+ ] = None,
+ natural_self_precedent: bool = False,
+ eager_grouping: bool = False,
+ python_impl: Optional[Callable[..., Any]] = None,
):
self.opstring = opstring
self.precedence = precedence
return id(self)
def __call__(
- self,
- left: Operators,
- right: Optional[Any] = None,
- *other: Any,
- **kwargs: Any,
+ self,
+ left: Operators,
+ right: Optional[Any] = None,
+ *other: Any,
+ **kwargs: Any,
) -> Operators:
if hasattr(left, "__sa_operate__"):
return left.operate(self, right, *other, **kwargs)
"""Hack, allows datetime objects to be compared on the LHS."""
if typing.TYPE_CHECKING:
+
def operate(
- self, op: OperatorType, *other: Any, **kwargs: Any
+ self, op: OperatorType, *other: Any, **kwargs: Any
) -> ColumnOperators:
...
def reverse_operate(
- self, op: OperatorType, other: Any, **kwargs: Any
+ self, op: OperatorType, other: Any, **kwargs: Any
) -> ColumnOperators:
...
return self.reverse_operate(concat_op, other)
def like(
- self, other: Any, escape: Optional[str] = None
+ self, other: Any, escape: Optional[str] = None
) -> ColumnOperators:
r"""Implement the ``like`` operator.
return self.operate(like_op, other, escape=escape)
def ilike(
- self, other: Any, escape: Optional[str] = None
+ self, other: Any, escape: Optional[str] = None
) -> ColumnOperators:
r"""Implement the ``ilike`` operator, e.g. case insensitive LIKE.
notin_ = not_in
def not_like(
- self, other: Any, escape: Optional[str] = None
+ self, other: Any, escape: Optional[str] = None
) -> ColumnOperators:
"""implement the ``NOT LIKE`` operator.
notlike = not_like
def not_ilike(
- self, other: Any, escape: Optional[str] = None
+ self, other: Any, escape: Optional[str] = None
) -> ColumnOperators:
"""implement the ``NOT ILIKE`` operator.
isnot = is_not
def startswith(
- self,
- other: Any,
- escape: Optional[str] = None,
- autoescape: bool = False,
+ self,
+ other: Any,
+ escape: Optional[str] = None,
+ autoescape: bool = False,
) -> ColumnOperators:
r"""Implement the ``startswith`` operator.
r"""Implement the ``istartswith`` operator, e.g. case insensitive
version of :meth:`.ColumnOperators.startswith`.
- Produces a LIKE expression that tests against an insensitive match for the start
- of a string value::
+ Produces a LIKE expression that tests against an insensitive
+ match for the start of a string value::
lower(column) LIKE lower(<other>) || '%'
may be set to ``True`` to apply escaping to occurrences of these
characters within the string value so that they match as themselves
and not as wildcard characters. Alternatively, the
- :paramref:`.ColumnOperators.istartswith.escape` parameter will establish
- a given character as an escape character which can be of use when
- the target expression is not a literal string.
+ :paramref:`.ColumnOperators.istartswith.escape` parameter will
+ establish a given character as an escape character which can be of
+ use when the target expression is not a literal string.
:param other: expression to be compared. This is usually a plain
string value, but can also be an arbitrary SQL expression. LIKE
)
def endswith(
- self,
- other: Any,
- escape: Optional[str] = None,
- autoescape: bool = False,
+ self,
+ other: Any,
+ escape: Optional[str] = None,
+ autoescape: bool = False,
) -> ColumnOperators:
r"""Implement the 'endswith' operator.
r"""Implement the ``iendswith`` operator, e.g. case insensitive
version of :meth:`.ColumnOperators.endswith`.
- Produces a LIKE expression that tests against an insensitive match for the end
- of a string value::
+ Produces a LIKE expression that tests against an insensitive match
+ for the end of a string value::
lower(column) LIKE '%' || lower(<other>)
r"""Implement the ``icontains`` operator, e.g. case insensitive
version of :meth:`.ColumnOperators.contains`.
- Produces a LIKE expression that tests against an insensitive match for the middle
- of a string value::
+ Produces a LIKE expression that tests against an insensitive match
+ for the middle of a string value::
lower(column) LIKE '%' || lower(<other>) || '%'
return self.operate(match_op, other, **kwargs)
def regexp_match(
- self, pattern: Any, flags: Optional[str] = None
+ self, pattern: Any, flags: Optional[str] = None
) -> ColumnOperators:
"""Implements a database-specific 'regexp match' operator.
return self.operate(regexp_match_op, pattern, flags=flags)
def regexp_replace(
- self, pattern: Any, replacement: Any, flags: Optional[str] = None
+ self, pattern: Any, replacement: Any, flags: Optional[str] = None
) -> ColumnOperators:
"""Implements a database-specific 'regexp replace' operator.
return self.reverse_operate(mod, other)
def between(
- self, cleft: Any, cright: Any, symmetric: bool = False
+ self, cleft: Any, cright: Any, symmetric: bool = False
) -> ColumnOperators:
"""Produce a :func:`_expression.between` clause against
the parent object, given the lower and upper range.
def _escaped_like_impl(
- fn: Callable[..., Any], other: Any, escape: Optional[str], autoescape: bool
+ fn: Callable[..., Any], other: Any, escape: Optional[str], autoescape: bool
) -> Any:
if autoescape:
if autoescape is not True:
@comparison_op
@_operator_fn
def startswith_op(
- a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
+ a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
) -> Any:
return _escaped_like_impl(a.startswith, b, escape, autoescape)
@comparison_op
@_operator_fn
def not_startswith_op(
- a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
+ a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
) -> Any:
return ~_escaped_like_impl(a.startswith, b, escape, autoescape)
@comparison_op
@_operator_fn
def endswith_op(
- a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
+ a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
) -> Any:
return _escaped_like_impl(a.endswith, b, escape, autoescape)
@comparison_op
@_operator_fn
def not_endswith_op(
- a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
+ a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
) -> Any:
return ~_escaped_like_impl(a.endswith, b, escape, autoescape)
@comparison_op
@_operator_fn
def contains_op(
- a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
+ a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
) -> Any:
return _escaped_like_impl(a.contains, b, escape, autoescape)
@comparison_op
@_operator_fn
def not_contains_op(
- a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
+ a: Any, b: Any, escape: Optional[str] = None, autoescape: bool = False
) -> Any:
return ~_escaped_like_impl(a.contains, b, escape, autoescape)
@_operator_fn
def regexp_replace_op(
- a: Any, b: Any, replacement: Any, flags: Optional[str] = None
+ a: Any, b: Any, replacement: Any, flags: Optional[str] = None
) -> Any:
return a.regexp_replace(b, replacement=replacement, flags=flags)
def is_natural_self_precedent(op: OperatorType) -> bool:
return (
- op in _natural_self_precedent
- or isinstance(op, custom_op)
- and op.natural_self_precedent
+ op in _natural_self_precedent
+ or isinstance(op, custom_op)
+ and op.natural_self_precedent
)
<= _PRECEDENCE.get(
against, getattr(against, "precedence", _OpLimit._largest)
)
- )
+ )
\ No newline at end of file