U kfJ)t@sz UdZddlmZddlmZddlmZddlmZ ddlm Z ddlm Z ddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlm Z!ddlm"Z#ddlm$Z%ddlm&Z'ddlm(Z)ddlm*Z+ddlm,Z-ddl.Z.ddl.m/Z/ddl.m0Z0ddl.m1Z1ddl.m2Z2ddl.m3Z3ddl.m4Z4ddl.m5Z5dd l.m6Z6dd!l.m7Z7dd"l.m8Z8dd#l.m9Z9dd$l.m:Z:dd%l.m;Z;d&d'lZ>d&d)l?m@Z@d&d*l?mAZAe.j9rd+d,lBmCZCd+d-lDmEZEd+d.lFmGZGd+d/lHmIZIe:d0e/d1ZJe:d2e0d3e/fd1ZKGd4d5d5eAZLe1eLeZe1eLe Ze1eLe Z e1eLe Z e1eLeZe1eLeZe1eLeZe1eLeZe1eLeZe1eLeZe1eLeZe1eLeZe1eLeZe1eLe!Z e1eLe#Z"e1eLe%Z$e1eLe'Z&e1eLe)Z(e1eLe+Z*e1eLe-Z,Gd6d7d7ZMGd8d9d9eLe3eJZNGd:d;d;eMZOe e"ee hZPd<d?d5d@dAdBZSd2d2d@dCdDZTd2d2d@dEdFZUeSdGdHdIdJZVeSeUdGdHdKdLZWeSdGdHdMdNZXeSdGdHdOdPZYeSdGdGdQdRdSZZe9reSdGdGdQdTdUZ[neZZ[eSdGdGdQdVdWZ\e9rReSdGdGdQdXdYZ]ne\Z]eUeSdGdGdGdZd[d\Z^eUeSdGdGdGdZd]d^Z_e9reSdGdGdGdZd_d`Z`ne_Z`eUeSdGdGdGdZdadbZaeUeSdGdGdGdZdcddZbe9reSdGdGdGdZdedfZcnebZceSdGdGdGdZdgdhZdeSdGdidGdGdjdkdlZeeUeSddGdGdmdGdndodpZfeUeSddGdGdmdGdndqdrZge9reSd dGdGdmdGdndsdtZhnegZheUeSd dGdGdmdGdndudvZieUeSd dGdGdmdGdndwdxZje9reSd dGdGdmdGdndydzZknejZkeUeSd dGdGdGd|dGd}d~dZleUeSddGdGdGd|dGd}ddZme9rjeSddGdGdGd|dGd}ddZnnemZneUeSdGdGdGdZddZoeUeSdGdGdGdZddZpe9reSdGdGdGdZddZqnepZqeSdGdGdQddZreSdGdGdQddZseSdGdGdQddZtd?dGdmd|dGdddZueUeSddGdGdmd|dGdddZveUeSddGdGdmd|dGdddZwe9reSddGdGdmd|dGdddZxnewZxeUeSddGdGdmd|dGdddZyeUeSddGdGdmd|dGdddZzeUeSddGdGdmd|dGdddZ{eUeSddGdGdmd|dGdddZ|e9r2eSddGdGdmd|dGdddZ}ne|Z}eUeSddGdGdmd|dGdddZ~eUeSddGdGdmd|dGdddZeUeSddGdGdmd|dGdddZeUeSddGdGdmd|dGdddZe9reSddGdGdmd|dGdddZneZeUeSddGdGdmd|dGdddZeUeSddGdGdmd|dGdddZeUeSdGdGdGdGdddZeUeSddGdGdmdGdddZeUeSd dGdGdmdGdddZeSd!dGdGdGdmdGdddZeUeSdGdGdGdGdddZe9 reSdGdGdGdGdddZneZeSdGdGdGdZdd„ZeSdGdGdGdZddĄZeSdGdGdGdZddƄZeSdGdGdQddȄZeSdGdGdQddʄZeSdGdGdQdd̄Ze9 reSdGdGdQdd΄ZneZeSdGdGdQddЄZe9 reSdGdGdQdd҄ZneZeSdGdGdGdZddԄZeSdGdGdGdZddքZeSdGdGdGdZdd؄ZeSdGdGdGdZddڄZeSdGdGdGdZdd܄ZeSdGdGdQddބZeSdGdGdGdZddZeSdGdGdGdZddZd5d|dddZd5d|dddZd5d|dddZd5d|dddZeeZe\ee&fZd5d|dddZeeeeeeeeiZd5d5dddZePeee&ge e"gZd5d|dddZdd|dddZeeeehZeeeegZeSdGdGdQddZGdddeZeVdeWdesdetdededede de,dedede$dedede*dededededededededededededeidejdefdegdeodepdeadebde de"de^de_dededededeldemderdedeZde\dede&d&ededededdeXdeYdedi:ZdeQd<d5dd|dddZdS("z*Defines operators used in SQL expressions.) annotations)IntEnum)add)and_)contains)eq)floordiv)ge)getitem)gt)inv)le)lshift)lt)mod)mul)ne)neg)or_)rshift)sub)truedivN)Any)Callable)cast)Dict)Generic)Optional)overload)Set)Tuple)Type) TYPE_CHECKING)TypeVar)Union)exc)util)Literal)Protocol)ColumnExpressionArgument) CacheConst) ColumnElement) TypeEngine_T)bound_FN.c@sneZdZUdZdZded<edddddd d d d Zedd dddd d dd Zdddddd d dd ZdS) OperatorTypezdescribe an op() function.str__name__NColumnExpressionArgument[Any] Optional[Any]rColumnElement[Any]leftrightotherkwargsreturncOsdSNr3selfr:r;r<r=r3r3H/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/sql/operators.py__call__IszOperatorType.__call__ OperatorscOsdSr?r3r@r3r3rBrCRscOsdSr?r3r@r3r3rBrC[s)N)N)N)r5 __module__ __qualname____doc__ __slots____annotations__rrCr3r3r3rBr2Bs  r2c@seZdZdZdZdddddZdddddZdd d d Zd!dddddddddZd"dddddddZ dddddddZ e Z ddddddd Z dS)#rDaBase of comparison and logical operators. Implements base methods :meth:`~sqlalchemy.sql.operators.Operators.operate` and :meth:`~sqlalchemy.sql.operators.Operators.reverse_operate`, as well as :meth:`~sqlalchemy.sql.operators.Operators.__and__`, :meth:`~sqlalchemy.sql.operators.Operators.__or__`, :meth:`~sqlalchemy.sql.operators.Operators.__invert__`. Usually is used via its most common subclass :class:`.ColumnOperators`. r3rr<r>cCs |t|S)a-Implement the ``&`` operator. When used with SQL expressions, results in an AND operation, equivalent to :func:`_expression.and_`, that is:: a & b is equivalent to:: from sqlalchemy import and_ and_(a, b) Care should be taken when using ``&`` regarding operator precedence; the ``&`` operator has the highest precedence. The operands should be enclosed in parenthesis if they contain further sub expressions:: (a == 2) & (b == 4) )operaterrAr<r3r3rB__and__szOperators.__and__cCs |t|S)a)Implement the ``|`` operator. When used with SQL expressions, results in an OR operation, equivalent to :func:`_expression.or_`, that is:: a | b is equivalent to:: from sqlalchemy import or_ or_(a, b) Care should be taken when using ``|`` regarding operator precedence; the ``|`` operator has the highest precedence. The operands should be enclosed in parenthesis if they contain further sub expressions:: (a == 2) | (b == 4) )rKrrLr3r3rB__or__szOperators.__or__r>cCs |tS)aImplement the ``~`` operator. When used with SQL expressions, results in a NOT operation, equivalent to :func:`_expression.not_`, that is:: ~a is equivalent to:: from sqlalchemy import not_ not_(a) )rKr rAr3r3rB __invert__szOperators.__invert__rFNr4intboolz7Optional[Union[Type[TypeEngine[Any]], TypeEngine[Any]]]Optional[Callable[..., Any]]zCallable[[Any], Operators])opstring precedence is_comparison return_type python_implr>cs,t|||||ddddfdd }|S)a Produce a generic operator function. e.g.:: somecolumn.op("*")(5) produces:: somecolumn * 5 This function can also be used to make bitwise operators explicit. For example:: somecolumn.op('&')(0xff) is a bitwise AND of the value in ``somecolumn``. :param opstring: a string which will be output as the infix operator between this element and the expression passed to the generated function. :param precedence: precedence which the database is expected to apply to the operator in SQL expressions. This integer value acts as a hint for the SQL compiler to know when explicit parenthesis should be rendered around a particular operation. A lower number will cause the expression to be parenthesized when applied against another operator with higher precedence. The default value of ``0`` is lower than all operators except for the comma (``,``) and ``AS`` operators. A value of 100 will be higher or equal to all operators, and -100 will be lower than or equal to all operators. .. seealso:: :ref:`faq_sql_expression_op_parenthesis` - detailed description of how the SQLAlchemy SQL compiler renders parenthesis :param is_comparison: legacy; if True, the operator will be considered as a "comparison" operator, that is which evaluates to a boolean true/false value, like ``==``, ``>``, etc. This flag is provided so that ORM relationships can establish that the operator is a comparison operator when used in a custom join condition. Using the ``is_comparison`` parameter is superseded by using the :meth:`.Operators.bool_op` method instead; this more succinct operator sets this parameter automatically, but also provides correct :pep:`484` typing support as the returned object will express a "boolean" datatype, i.e. ``BinaryExpression[bool]``. :param return_type: a :class:`.TypeEngine` class or object that will force the return type of an expression produced by this operator to be of that type. By default, operators that specify :paramref:`.Operators.op.is_comparison` will resolve to :class:`.Boolean`, and those that do not will be of the same type as the left-hand operand. :param python_impl: an optional Python function that can evaluate two Python values in the same way as this operator works when run on the database server. Useful for in-Python SQL expression evaluation functions, such as for ORM hybrid attributes, and the ORM "evaluator" used to match objects in a session after a multi-row update or delete. e.g.:: >>> expr = column('x').op('+', python_impl=lambda a, b: a + b)('y') The operator for the above expression will also work for non-SQL left and right objects:: >>> expr.operator(5, 10) 15 .. versionadded:: 2.0 .. seealso:: :meth:`.Operators.bool_op` :ref:`types_operators` :ref:`relationship_custom_operator` )rYrrDrJcs |Sr?r3)r<operatorrAr3rBagainst2szOperators.op..against) custom_op)rArUrVrWrXrYr\r3rZrBops^z Operators.op)rUrVrYr>cCs|j||d|dS)aReturn a custom boolean operator. This method is shorthand for calling :meth:`.Operators.op` and passing the :paramref:`.Operators.op.is_comparison` flag with True. A key advantage to using :meth:`.Operators.bool_op` is that when using column constructs, the "boolean" nature of the returned expression will be present for :pep:`484` purposes. .. seealso:: :meth:`.Operators.op` T)rVrWrYr^)rArUrVrYr3r3rBbool_op7s zOperators.bool_opr2r^r<r=r>cOstt|dS)aGOperate 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, **kwargs): return op(func.lower(self), func.lower(other), **kwargs) :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`. NNotImplementedErrorr4rAr^r<r=r3r3rBrKRszOperators.operatecKstt|dS)zXReverse operate on an argument. Usage is the same as :meth:`operate`. Nrbrdr3r3rBreverse_operatepszOperators.reverse_operate)rFNN)rN) r5rErFrGrHrMrNrQr^r`rK__sa_operate__rer3r3r3rBrDzs nrDc @seZdZdZdZdZd!dddd ddd d d d ZdddddZddddZddddZe d"ddddddddZ e d#ddddddddZ d$ddddddd dZ dS)%r]aRepresent a 'custom' operator. :class:`.custom_op` is normally instantiated when the :meth:`.Operators.op` or :meth:`.Operators.bool_op` methods are used to create a custom operator callable. The class can also be used directly when programmatically constructing expressions. E.g. to represent the "factorial" operation:: from sqlalchemy.sql import UnaryExpression from sqlalchemy.sql import operators from sqlalchemy import Numeric unary = UnaryExpression(table.c.somecolumn, modifier=operators.custom_op("!"), type_=Numeric) .. seealso:: :meth:`.Operators.op` :meth:`.Operators.bool_op` )rUrVrWnatural_self_precedenteager_groupingrXrYrFNr4rRrSz5Optional[Union[Type[TypeEngine[_T]], TypeEngine[_T]]]rT)rUrVrWrXrgrhrYcCs<||_||_||_||_||_|r,||nd|_||_dSr?)rUrVrWrgrhZ _to_instancerXrY)rArUrVrWrXrgrhrYr3r3rB__init__s zcustom_op.__init__rrJcCst|to||kSr?) isinstancer] _hash_keyrLr3r3rB__eq__s zcustom_op.__eq__rOcCs t|Sr?)hashrkrPr3r3rB__hash__szcustom_op.__hash__z"Union[CacheConst, Tuple[Any, ...]]cCs,|j|j|j|j|j|j|jr&|jjndfSr?) __class__rUrVrWrgrhrXZ_static_cache_keyrPr3r3rBrkszcustom_op._hash_keyr6r7r8r9cOsdSr?r3r@r3r3rBrCszcustom_op.__call__rDcOsdSr?r3r@r3r3rBrCscOsPt|dr|j||f||S|jr8|j||f||Std|jddS)NrfzCustom operator zX can't be used with plain Python objects unless it includes the 'python_impl' parameter.)hasattrrKrYr&ZInvalidRequestErrorrUr@r3r3rBrCs  )rFNFFN)N)N)N) r5rErFrGrHrirlrnrkrrCr3r3r3rBr]{s*   r]c@s eZdZUdZdZdZded<ejrLdddddd d Z dddddd d Z ddd ddZ ddd ddZ erddddZ nej Z ddd ddZddd ddZddd ddZddd ddZerddd ddZneZddd d d!Zddd d"d#Zddd$d%Zddd d&d'Zddd(d)d*Zddd d+d,Zddd d-d.Zddd d/d0Zddd d1d2Zddd3dd4d5d6Zddd3dd4d7d8Zddd d9d:Zddd d;d<Z ddd d=d>Z!ddd?d@Z"ddd dAdBZ#ddd dCdDZ$ddd dEdFZ%ddd dGdHZ&er,ddd dIdJZ'ne&Z'ddd3dd4dKdLZ(er`ddd3dd4dMdNZ)ne(Z)ddd3dd4dOdPZ*erddd3dd4dQdRZ+ne*Z+ddd dSdTZ,ddd dUdVZ-erddd dWdXZ.ne-Z.ddd3dZdd[d\d]Z/ddd3dZdd[d^d_Z0ddd3dZdd[d`daZ1ddd3dZdd[dbdcZ2ddddddedfZ3ddddddgdhZ4ddddidjdkZ5ddd3ddldmdnZ6dddd3ddodpdqZ7dddrdsZ8dddtduZ9dddvdwZ:erdddxdyZ;ne:Z;dddzd{Zddd ddZ?ddd ddZ@ddd ddZAddd ddZBddddZddddZCddddZDddddZEddddZFddd ddZGddd ddZHddd ddZIddd ddZJddd ddZKddd ddZLddd ddZMddd ddZNdS)ColumnOperatorsa"Defines boolean, comparison, and other operators for :class:`_expression.ColumnElement` expressions. By default, all methods call down to :meth:`.operate` or :meth:`.reverse_operate`, passing in the appropriate operator function from the Python builtin ``operator`` module or a SQLAlchemy-specific operator function from :mod:`sqlalchemy.expression.operators`. For example the ``__eq__`` function:: def __eq__(self, other): return self.operate(operators.eq, other) Where ``operators.eq`` is essentially:: def eq(a, b): return a == b The core column expression unit :class:`_expression.ColumnElement` overrides :meth:`.Operators.operate` and others to return further :class:`_expression.ColumnElement` constructs, so that the ``==`` operation above is replaced by a clause construct. .. seealso:: :ref:`types_operators` :attr:`.TypeEngine.comparator_factory` :class:`.ColumnOperators` :class:`.PropComparator` r3Nz Literal[None] timetupler2rracOsdSr?r3rdr3r3rBrKszColumnOperators.operatecKsdSr?r3rdr3r3rBre!szColumnOperators.reverse_operaterJcCs |t|S)zdImplement the ``<`` operator. In a column context, produces the clause ``a < b``. )rKrrLr3r3rB__lt__%szColumnOperators.__lt__cCs |t|S)zfImplement the ``<=`` operator. In a column context, produces the clause ``a <= b``. )rKr rLr3r3rB__le__-szColumnOperators.__le__rRrOcCsdSr?r3rPr3r3rBrn:zColumnOperators.__hash__cCs |t|S)zImplement the ``==`` operator. In a column context, produces the clause ``a = b``. If the target is ``None``, produces ``a IS NULL``. )rKrrLr3r3rBrl?szColumnOperators.__eq__cCs |t|S)zImplement the ``!=`` operator. In a column context, produces the clause ``a != b``. If the target is ``None``, produces ``a IS NOT NULL``. )rKrrLr3r3rB__ne__HszColumnOperators.__ne__cCs |t|S)zImplement the ``IS DISTINCT FROM`` operator. Renders "a IS DISTINCT FROM b" on most platforms; on some such as SQLite may render "a IS NOT b". )rKis_distinct_fromrLr3r3rBrwQsz ColumnOperators.is_distinct_fromcCs |t|S)aImplement the ``IS NOT DISTINCT FROM`` operator. Renders "a IS NOT DISTINCT FROM b" on most platforms; on some such as SQLite may render "a IS b". .. versionchanged:: 1.4 The ``is_not_distinct_from()`` operator is renamed from ``isnot_distinct_from()`` in previous releases. The previous name remains available for backwards compatibility. )rKis_not_distinct_fromrLr3r3rBrxZs z$ColumnOperators.is_not_distinct_fromcCsdSr?r3rLr3r3rBisnot_distinct_fromjruz#ColumnOperators.isnot_distinct_fromcCs |t|S)zdImplement the ``>`` operator. In a column context, produces the clause ``a > b``. )rKr rLr3r3rB__gt__oszColumnOperators.__gt__cCs |t|S)zfImplement the ``>=`` operator. In a column context, produces the clause ``a >= b``. )rKr rLr3r3rB__ge__wszColumnOperators.__ge__cCs |tS)zaImplement the ``-`` operator. In a column context, produces the clause ``-a``. )rKrrPr3r3rB__neg__szColumnOperators.__neg__cCs |t|Sr?)rKrrLr3r3rB __contains__szColumnOperators.__contains__)indexr>cCs |t|S)zImplement the [] operator. This can be used by some database-specific types such as PostgreSQL ARRAY and HSTORE. )rKr )rAr~r3r3rB __getitem__szColumnOperators.__getitem__cCs |t|S)zimplement the << operator. Not used by SQLAlchemy core, this is provided for custom operator systems which want to use << as an extension point. )rKrrLr3r3rB __lshift__szColumnOperators.__lshift__cCs |t|S)zimplement the >> operator. Not used by SQLAlchemy core, this is provided for custom operator systems which want to use >> as an extension point. )rKrrLr3r3rB __rshift__szColumnOperators.__rshift__cCs |t|S)zImplement the 'concat' operator. In a column context, produces the clause ``a || b``, or uses the ``concat()`` operator on MySQL. )rK concat_oprLr3r3rBconcatszColumnOperators.concatcCs |t|S)z|Implement an 'rconcat' operator. this is for internal use at the moment .. versionadded:: 1.4.40 )rerrLr3r3rB_rconcatszColumnOperators._rconcat Optional[str])r<escaper>cCs|jt||dS)aImplement the ``like`` operator. In a column context, produces the expression:: a LIKE other E.g.:: stmt = select(sometable).\ where(sometable.c.column.like("%foobar%")) :param other: expression to be compared :param escape: optional escape character, renders the ``ESCAPE`` keyword, e.g.:: somecolumn.like("foo/%bar", escape="/") .. seealso:: :meth:`.ColumnOperators.ilike` r)rKlike_oprAr<rr3r3rBlikeszColumnOperators.likecCs|jt||dS)aImplement the ``ilike`` operator, e.g. case insensitive LIKE. In a column context, produces an expression either of the form:: lower(a) LIKE lower(other) Or on backends that support the ILIKE operator:: a ILIKE other E.g.:: stmt = select(sometable).\ where(sometable.c.column.ilike("%foobar%")) :param other: expression to be compared :param escape: optional escape character, renders the ``ESCAPE`` keyword, e.g.:: somecolumn.ilike("foo/%bar", escape="/") .. seealso:: :meth:`.ColumnOperators.like` r)rKilike_oprr3r3rBilikeszColumnOperators.ilikecCs |t|S)zProduce a bitwise XOR operation, typically via the ``^`` operator, or ``#`` for PostgreSQL. .. versionadded:: 2.0.2 .. seealso:: :ref:`operators_bitwise` )rKbitwise_xor_oprLr3r3rB bitwise_xors zColumnOperators.bitwise_xorcCs |t|S)zProduce a bitwise OR operation, typically via the ``|`` operator. .. versionadded:: 2.0.2 .. seealso:: :ref:`operators_bitwise` )rK bitwise_or_oprLr3r3rB bitwise_ors zColumnOperators.bitwise_orcCs |t|S)zProduce a bitwise AND operation, typically via the ``&`` operator. .. versionadded:: 2.0.2 .. seealso:: :ref:`operators_bitwise` )rKbitwise_and_oprLr3r3rB bitwise_ands zColumnOperators.bitwise_andcCs |tS)zProduce a bitwise NOT operation, typically via the ``~`` operator. .. versionadded:: 2.0.2 .. seealso:: :ref:`operators_bitwise` )rKbitwise_not_oprPr3r3rB bitwise_nots zColumnOperators.bitwise_notcCs |t|S)zProduce a bitwise LSHIFT operation, typically via the ``<<`` operator. .. versionadded:: 2.0.2 .. seealso:: :ref:`operators_bitwise` )rKbitwise_lshift_oprLr3r3rBbitwise_lshift*s zColumnOperators.bitwise_lshiftcCs |t|S)zProduce a bitwise RSHIFT operation, typically via the ``>>`` operator. .. versionadded:: 2.0.2 .. seealso:: :ref:`operators_bitwise` )rKbitwise_rshift_oprLr3r3rBbitwise_rshift8s zColumnOperators.bitwise_rshiftcCs |t|S)a Implement the ``in`` operator. In a column context, produces the clause ``column IN ``. The given parameter ``other`` may be: * A list of literal values, e.g.:: stmt.where(column.in_([1, 2, 3])) In this calling form, the list of items is converted to a set of bound parameters the same length as the list given:: WHERE COL IN (?, ?, ?) * A list of tuples may be provided if the comparison is against a :func:`.tuple_` containing multiple expressions:: from sqlalchemy import tuple_ stmt.where(tuple_(col1, col2).in_([(1, 10), (2, 20), (3, 30)])) * An empty list, e.g.:: stmt.where(column.in_([])) In this calling form, the expression renders an "empty set" expression. These expressions are tailored to individual backends and are generally trying to get an empty SELECT statement as a subquery. Such as on SQLite, the expression is:: WHERE col IN (SELECT 1 FROM (SELECT 1) WHERE 1!=1) .. versionchanged:: 1.4 empty IN expressions now use an execution-time generated SELECT subquery in all cases. * A bound parameter, e.g. :func:`.bindparam`, may be used if it includes the :paramref:`.bindparam.expanding` flag:: stmt.where(column.in_(bindparam('value', expanding=True))) In this calling form, the expression renders a special non-SQL placeholder expression that looks like:: WHERE COL IN ([EXPANDING_value]) This placeholder expression is intercepted at statement execution time to be converted into the variable number of bound parameter form illustrated earlier. If the statement were executed as:: connection.execute(stmt, {"value": [1, 2, 3]}) The database would be passed a bound parameter for each value:: WHERE COL IN (?, ?, ?) .. versionadded:: 1.2 added "expanding" bound parameters If an empty list is passed, a special "empty list" expression, which is specific to the database in use, is rendered. On SQLite this would be:: WHERE COL IN (SELECT 1 FROM (SELECT 1) WHERE 1!=1) .. versionadded:: 1.3 "expanding" bound parameters now support empty lists * a :func:`_expression.select` construct, which is usually a correlated scalar select:: stmt.where( column.in_( select(othertable.c.y). where(table.c.x == othertable.c.x) ) ) In this calling form, :meth:`.ColumnOperators.in_` renders as given:: WHERE COL IN (SELECT othertable.y FROM othertable WHERE othertable.x = table.x) :param other: a list of literals, a :func:`_expression.select` construct, or a :func:`.bindparam` construct that includes the :paramref:`.bindparam.expanding` flag set to True. )rKin_oprLr3r3rBin_FsWzColumnOperators.in_cCs |t|S)aimplement the ``NOT IN`` operator. This is equivalent to using negation with :meth:`.ColumnOperators.in_`, i.e. ``~x.in_(y)``. In the case that ``other`` is an empty sequence, the compiler produces an "empty not in" expression. This defaults to the expression "1 = 1" to produce true in all cases. The :paramref:`_sa.create_engine.empty_in_strategy` may be used to alter this behavior. .. versionchanged:: 1.4 The ``not_in()`` operator is renamed from ``notin_()`` in previous releases. The previous name remains available for backwards compatibility. .. versionchanged:: 1.2 The :meth:`.ColumnOperators.in_` and :meth:`.ColumnOperators.not_in` operators now produce a "static" expression for an empty IN sequence by default. .. seealso:: :meth:`.ColumnOperators.in_` )rK not_in_oprLr3r3rBnot_inszColumnOperators.not_incCsdSr?r3rLr3r3rBnotin_ruzColumnOperators.notin_cCs|jt||dS)aimplement the ``NOT LIKE`` operator. This is equivalent to using negation with :meth:`.ColumnOperators.like`, i.e. ``~x.like(y)``. .. versionchanged:: 1.4 The ``not_like()`` operator is renamed from ``notlike()`` in previous releases. The previous name remains available for backwards compatibility. .. seealso:: :meth:`.ColumnOperators.like` r)rK not_like_oprr3r3rBnot_likeszColumnOperators.not_likecCsdSr?r3rr3r3rBnotlikeszColumnOperators.notlikecCs|jt||dS)aimplement the ``NOT ILIKE`` operator. This is equivalent to using negation with :meth:`.ColumnOperators.ilike`, i.e. ``~x.ilike(y)``. .. versionchanged:: 1.4 The ``not_ilike()`` operator is renamed from ``notilike()`` in previous releases. The previous name remains available for backwards compatibility. .. seealso:: :meth:`.ColumnOperators.ilike` r)rK not_ilike_oprr3r3rB not_ilikeszColumnOperators.not_ilikecCsdSr?r3rr3r3rBnotilikeszColumnOperators.notilikecCs |t|S)aWImplement the ``IS`` operator. Normally, ``IS`` is generated automatically when comparing to a value of ``None``, which resolves to ``NULL``. However, explicit usage of ``IS`` may be desirable if comparing to boolean values on certain platforms. .. seealso:: :meth:`.ColumnOperators.is_not` )rKis_rLr3r3rBrs zColumnOperators.is_cCs |t|S)a%Implement the ``IS NOT`` operator. Normally, ``IS NOT`` is generated automatically when comparing to a value of ``None``, which resolves to ``NULL``. However, explicit usage of ``IS NOT`` may be desirable if comparing to boolean values on certain platforms. .. versionchanged:: 1.4 The ``is_not()`` operator is renamed from ``isnot()`` in previous releases. The previous name remains available for backwards compatibility. .. seealso:: :meth:`.ColumnOperators.is_` )rKis_notrLr3r3rBr szColumnOperators.is_notcCsdSr?r3rLr3r3rBisnotruzColumnOperators.isnotFrS)r<r autoescaper>cCs|jt|||dS)aS Implement the ``startswith`` operator. Produces a LIKE expression that tests against a match for the start of a string value:: column LIKE || '%' E.g.:: stmt = select(sometable).\ where(sometable.c.column.startswith("foobar")) Since the operator uses ``LIKE``, wildcard characters ``"%"`` and ``"_"`` that are present inside the expression will behave like wildcards as well. For literal string values, the :paramref:`.ColumnOperators.startswith.autoescape` flag 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.startswith.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 wildcard characters ``%`` and ``_`` are not escaped by default unless the :paramref:`.ColumnOperators.startswith.autoescape` flag is set to True. :param autoescape: boolean; when True, establishes an escape character within the LIKE expression, then applies it to all occurrences of ``"%"``, ``"_"`` and the escape character itself within the comparison value, which is assumed to be a literal string and not a SQL expression. An expression such as:: somecolumn.startswith("foo%bar", autoescape=True) Will render as:: somecolumn LIKE :param || '%' ESCAPE '/' With the value of ``:param`` as ``"foo/%bar"``. :param escape: a character which when given will render with the ``ESCAPE`` keyword to establish that character as the escape character. This character can then be placed preceding occurrences of ``%`` and ``_`` to allow them to act as themselves and not wildcard characters. An expression such as:: somecolumn.startswith("foo/%bar", escape="^") Will render as:: somecolumn LIKE :param || '%' ESCAPE '^' The parameter may also be combined with :paramref:`.ColumnOperators.startswith.autoescape`:: somecolumn.startswith("foo%bar^bat", escape="^", autoescape=True) Where above, the given literal parameter will be converted to ``"foo^%bar^^bat"`` before being passed to the database. .. seealso:: :meth:`.ColumnOperators.endswith` :meth:`.ColumnOperators.contains` :meth:`.ColumnOperators.like` rr)rK startswith_oprAr<rrr3r3rB startswith#s RzColumnOperators.startswithcCs|jt|||dS)a 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:: lower(column) LIKE lower() || '%' E.g.:: stmt = select(sometable).\ where(sometable.c.column.istartswith("foobar")) Since the operator uses ``LIKE``, wildcard characters ``"%"`` and ``"_"`` that are present inside the expression will behave like wildcards as well. For literal string values, the :paramref:`.ColumnOperators.istartswith.autoescape` flag 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. :param other: expression to be compared. This is usually a plain string value, but can also be an arbitrary SQL expression. LIKE wildcard characters ``%`` and ``_`` are not escaped by default unless the :paramref:`.ColumnOperators.istartswith.autoescape` flag is set to True. :param autoescape: boolean; when True, establishes an escape character within the LIKE expression, then applies it to all occurrences of ``"%"``, ``"_"`` and the escape character itself within the comparison value, which is assumed to be a literal string and not a SQL expression. An expression such as:: somecolumn.istartswith("foo%bar", autoescape=True) Will render as:: lower(somecolumn) LIKE lower(:param) || '%' ESCAPE '/' With the value of ``:param`` as ``"foo/%bar"``. :param escape: a character which when given will render with the ``ESCAPE`` keyword to establish that character as the escape character. This character can then be placed preceding occurrences of ``%`` and ``_`` to allow them to act as themselves and not wildcard characters. An expression such as:: somecolumn.istartswith("foo/%bar", escape="^") Will render as:: lower(somecolumn) LIKE lower(:param) || '%' ESCAPE '^' The parameter may also be combined with :paramref:`.ColumnOperators.istartswith.autoescape`:: somecolumn.istartswith("foo%bar^bat", escape="^", autoescape=True) Where above, the given literal parameter will be converted to ``"foo^%bar^^bat"`` before being passed to the database. .. seealso:: :meth:`.ColumnOperators.startswith` r)rKistartswith_oprr3r3rB istartswithys NzColumnOperators.istartswithcCs|jt|||dS)a? Implement the 'endswith' operator. Produces a LIKE expression that tests against a match for the end of a string value:: column LIKE '%' || E.g.:: stmt = select(sometable).\ where(sometable.c.column.endswith("foobar")) Since the operator uses ``LIKE``, wildcard characters ``"%"`` and ``"_"`` that are present inside the expression will behave like wildcards as well. For literal string values, the :paramref:`.ColumnOperators.endswith.autoescape` flag 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.endswith.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 wildcard characters ``%`` and ``_`` are not escaped by default unless the :paramref:`.ColumnOperators.endswith.autoescape` flag is set to True. :param autoescape: boolean; when True, establishes an escape character within the LIKE expression, then applies it to all occurrences of ``"%"``, ``"_"`` and the escape character itself within the comparison value, which is assumed to be a literal string and not a SQL expression. An expression such as:: somecolumn.endswith("foo%bar", autoescape=True) Will render as:: somecolumn LIKE '%' || :param ESCAPE '/' With the value of ``:param`` as ``"foo/%bar"``. :param escape: a character which when given will render with the ``ESCAPE`` keyword to establish that character as the escape character. This character can then be placed preceding occurrences of ``%`` and ``_`` to allow them to act as themselves and not wildcard characters. An expression such as:: somecolumn.endswith("foo/%bar", escape="^") Will render as:: somecolumn LIKE '%' || :param ESCAPE '^' The parameter may also be combined with :paramref:`.ColumnOperators.endswith.autoescape`:: somecolumn.endswith("foo%bar^bat", escape="^", autoescape=True) Where above, the given literal parameter will be converted to ``"foo^%bar^^bat"`` before being passed to the database. .. seealso:: :meth:`.ColumnOperators.startswith` :meth:`.ColumnOperators.contains` :meth:`.ColumnOperators.like` r)rK endswith_oprr3r3rBendswiths RzColumnOperators.endswithcCs|jt|||dS)ao 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:: lower(column) LIKE '%' || lower() E.g.:: stmt = select(sometable).\ where(sometable.c.column.iendswith("foobar")) Since the operator uses ``LIKE``, wildcard characters ``"%"`` and ``"_"`` that are present inside the expression will behave like wildcards as well. For literal string values, the :paramref:`.ColumnOperators.iendswith.autoescape` flag 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.iendswith.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 wildcard characters ``%`` and ``_`` are not escaped by default unless the :paramref:`.ColumnOperators.iendswith.autoescape` flag is set to True. :param autoescape: boolean; when True, establishes an escape character within the LIKE expression, then applies it to all occurrences of ``"%"``, ``"_"`` and the escape character itself within the comparison value, which is assumed to be a literal string and not a SQL expression. An expression such as:: somecolumn.iendswith("foo%bar", autoescape=True) Will render as:: lower(somecolumn) LIKE '%' || lower(:param) ESCAPE '/' With the value of ``:param`` as ``"foo/%bar"``. :param escape: a character which when given will render with the ``ESCAPE`` keyword to establish that character as the escape character. This character can then be placed preceding occurrences of ``%`` and ``_`` to allow them to act as themselves and not wildcard characters. An expression such as:: somecolumn.iendswith("foo/%bar", escape="^") Will render as:: lower(somecolumn) LIKE '%' || lower(:param) ESCAPE '^' The parameter may also be combined with :paramref:`.ColumnOperators.iendswith.autoescape`:: somecolumn.endswith("foo%bar^bat", escape="^", autoescape=True) Where above, the given literal parameter will be converted to ``"foo^%bar^^bat"`` before being passed to the database. .. seealso:: :meth:`.ColumnOperators.endswith` r)rK iendswith_oprr3r3rB iendswith!s NzColumnOperators.iendswith)r<kwr>cKs|jt|f|S)aX Implement the 'contains' operator. Produces a LIKE expression that tests against a match for the middle of a string value:: column LIKE '%' || || '%' E.g.:: stmt = select(sometable).\ where(sometable.c.column.contains("foobar")) Since the operator uses ``LIKE``, wildcard characters ``"%"`` and ``"_"`` that are present inside the expression will behave like wildcards as well. For literal string values, the :paramref:`.ColumnOperators.contains.autoescape` flag 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.contains.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 wildcard characters ``%`` and ``_`` are not escaped by default unless the :paramref:`.ColumnOperators.contains.autoescape` flag is set to True. :param autoescape: boolean; when True, establishes an escape character within the LIKE expression, then applies it to all occurrences of ``"%"``, ``"_"`` and the escape character itself within the comparison value, which is assumed to be a literal string and not a SQL expression. An expression such as:: somecolumn.contains("foo%bar", autoescape=True) Will render as:: somecolumn LIKE '%' || :param || '%' ESCAPE '/' With the value of ``:param`` as ``"foo/%bar"``. :param escape: a character which when given will render with the ``ESCAPE`` keyword to establish that character as the escape character. This character can then be placed preceding occurrences of ``%`` and ``_`` to allow them to act as themselves and not wildcard characters. An expression such as:: somecolumn.contains("foo/%bar", escape="^") Will render as:: somecolumn LIKE '%' || :param || '%' ESCAPE '^' The parameter may also be combined with :paramref:`.ColumnOperators.contains.autoescape`:: somecolumn.contains("foo%bar^bat", escape="^", autoescape=True) Where above, the given literal parameter will be converted to ``"foo^%bar^^bat"`` before being passed to the database. .. seealso:: :meth:`.ColumnOperators.startswith` :meth:`.ColumnOperators.endswith` :meth:`.ColumnOperators.like` )rK contains_oprAr<rr3r3rBrssNzColumnOperators.containscKs|jt|f|S)a 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:: lower(column) LIKE '%' || lower() || '%' E.g.:: stmt = select(sometable).\ where(sometable.c.column.icontains("foobar")) Since the operator uses ``LIKE``, wildcard characters ``"%"`` and ``"_"`` that are present inside the expression will behave like wildcards as well. For literal string values, the :paramref:`.ColumnOperators.icontains.autoescape` flag 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.icontains.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 wildcard characters ``%`` and ``_`` are not escaped by default unless the :paramref:`.ColumnOperators.icontains.autoescape` flag is set to True. :param autoescape: boolean; when True, establishes an escape character within the LIKE expression, then applies it to all occurrences of ``"%"``, ``"_"`` and the escape character itself within the comparison value, which is assumed to be a literal string and not a SQL expression. An expression such as:: somecolumn.icontains("foo%bar", autoescape=True) Will render as:: lower(somecolumn) LIKE '%' || lower(:param) || '%' ESCAPE '/' With the value of ``:param`` as ``"foo/%bar"``. :param escape: a character which when given will render with the ``ESCAPE`` keyword to establish that character as the escape character. This character can then be placed preceding occurrences of ``%`` and ``_`` to allow them to act as themselves and not wildcard characters. An expression such as:: somecolumn.icontains("foo/%bar", escape="^") Will render as:: lower(somecolumn) LIKE '%' || lower(:param) || '%' ESCAPE '^' The parameter may also be combined with :paramref:`.ColumnOperators.contains.autoescape`:: somecolumn.icontains("foo%bar^bat", escape="^", autoescape=True) Where above, the given literal parameter will be converted to ``"foo^%bar^^bat"`` before being passed to the database. .. seealso:: :meth:`.ColumnOperators.contains` )rK icontains_oprr3r3rB icontainssJzColumnOperators.icontains)r<r=r>cKs|jt|f|S)aImplements a database-specific 'match' operator. :meth:`_sql.ColumnOperators.match` attempts to resolve to a MATCH-like function or operator provided by the backend. Examples include: * PostgreSQL - renders ``x @@ plainto_tsquery(y)`` .. versionchanged:: 2.0 ``plainto_tsquery()`` is used instead of ``to_tsquery()`` for PostgreSQL now; for compatibility with other forms, see :ref:`postgresql_match`. * MySQL - renders ``MATCH (x) AGAINST (y IN BOOLEAN MODE)`` .. seealso:: :class:`_mysql.match` - MySQL specific construct with additional features. * Oracle - renders ``CONTAINS(x, y)`` * other backends may provide special implementations. * Backends without any special implementation will emit the operator as "MATCH". This is compatible with SQLite, for example. )rKmatch_op)rAr<r=r3r3rBmatchszColumnOperators.match)patternflagsr>cCs|jt||dS)aImplements a database-specific 'regexp match' operator. E.g.:: stmt = select(table.c.some_column).where( table.c.some_column.regexp_match('^(b|c)') ) :meth:`_sql.ColumnOperators.regexp_match` attempts to resolve to a REGEXP-like function or operator provided by the backend, however the specific regular expression syntax and flags available are **not backend agnostic**. Examples include: * PostgreSQL - renders ``x ~ y`` or ``x !~ y`` when negated. * Oracle - renders ``REGEXP_LIKE(x, y)`` * SQLite - uses SQLite's ``REGEXP`` placeholder operator and calls into the Python ``re.match()`` builtin. * other backends may provide special implementations. * Backends without any special implementation will emit the operator as "REGEXP" or "NOT REGEXP". This is compatible with SQLite and MySQL, for example. Regular expression support is currently implemented for Oracle, PostgreSQL, MySQL and MariaDB. Partial support is available for SQLite. Support among third-party dialects may vary. :param pattern: The regular expression pattern string or column clause. :param flags: Any regular expression string flags to apply, passed as plain Python string only. These flags are backend specific. Some backends, like PostgreSQL and MariaDB, may alternatively specify the flags as part of the pattern. When using the ignore case flag 'i' in PostgreSQL, the ignore case regexp match operator ``~*`` or ``!~*`` will be used. .. versionadded:: 1.4 .. versionchanged:: 1.4.48, 2.0.18 Note that due to an implementation error, the "flags" parameter previously accepted SQL expression objects such as column expressions in addition to plain Python strings. This implementation did not work correctly with caching and was removed; strings only should be passed for the "flags" parameter, as these flags are rendered as literal inline values within SQL expressions. .. seealso:: :meth:`_sql.ColumnOperators.regexp_replace` r)rKregexp_match_op)rArrr3r3rB regexp_match-s8zColumnOperators.regexp_match)r replacementrr>cCs|jt|||dS)aImplements a database-specific 'regexp replace' operator. E.g.:: stmt = select( table.c.some_column.regexp_replace( 'b(..)', 'XY', flags='g' ) ) :meth:`_sql.ColumnOperators.regexp_replace` attempts to resolve to a REGEXP_REPLACE-like function provided by the backend, that usually emit the function ``REGEXP_REPLACE()``. However, the specific regular expression syntax and flags available are **not backend agnostic**. Regular expression replacement support is currently implemented for Oracle, PostgreSQL, MySQL 8 or greater and MariaDB. Support among third-party dialects may vary. :param pattern: The regular expression pattern string or column clause. :param pattern: The replacement string or column clause. :param flags: Any regular expression string flags to apply, passed as plain Python string only. These flags are backend specific. Some backends, like PostgreSQL and MariaDB, may alternatively specify the flags as part of the pattern. .. versionadded:: 1.4 .. versionchanged:: 1.4.48, 2.0.18 Note that due to an implementation error, the "flags" parameter previously accepted SQL expression objects such as column expressions in addition to plain Python strings. This implementation did not work correctly with caching and was removed; strings only should be passed for the "flags" parameter, as these flags are rendered as literal inline values within SQL expressions. .. seealso:: :meth:`_sql.ColumnOperators.regexp_match` rr)rKregexp_replace_op)rArrrr3r3rBregexp_replacegs 1zColumnOperators.regexp_replacecCs |tS)zLProduce a :func:`_expression.desc` clause against the parent object.)rKdesc_oprPr3r3rBdescszColumnOperators.desccCs |tS)zKProduce a :func:`_expression.asc` clause against the parent object.)rKasc_oprPr3r3rBascszColumnOperators.asccCs |tS)a*Produce a :func:`_expression.nulls_first` clause against the parent object. .. versionchanged:: 1.4 The ``nulls_first()`` operator is renamed from ``nullsfirst()`` in previous releases. The previous name remains available for backwards compatibility. )rKnulls_first_oprPr3r3rB nulls_firstszColumnOperators.nulls_firstcCsdSr?r3rPr3r3rB nullsfirstruzColumnOperators.nullsfirstcCs |tS)a'Produce a :func:`_expression.nulls_last` clause against the parent object. .. versionchanged:: 1.4 The ``nulls_last()`` operator is renamed from ``nullslast()`` in previous releases. The previous name remains available for backwards compatibility. )rK nulls_last_oprPr3r3rB nulls_lastszColumnOperators.nulls_lastcCsdSr?r3rPr3r3rB nullslastruzColumnOperators.nullslastr4) collationr>cCs |t|S)zProduce a :func:`_expression.collate` clause against the parent object, given the collation string. .. seealso:: :func:`_expression.collate` )rKcollate)rArr3r3rBrs zColumnOperators.collatecCs |t|S)zaImplement the ``+`` operator in reverse. See :meth:`.ColumnOperators.__add__`. )rerrLr3r3rB__radd__szColumnOperators.__radd__cCs |t|S)zaImplement the ``-`` operator in reverse. See :meth:`.ColumnOperators.__sub__`. )rerrLr3r3rB__rsub__szColumnOperators.__rsub__cCs |t|S)zaImplement the ``*`` operator in reverse. See :meth:`.ColumnOperators.__mul__`. )rerrLr3r3rB__rmul__szColumnOperators.__rmul__cCs |t|S)zaImplement the ``%`` operator in reverse. See :meth:`.ColumnOperators.__mod__`. )rerrLr3r3rB__rmod__szColumnOperators.__rmod__)cleftcright symmetricr>cCs|jt|||dS)zzProduce a :func:`_expression.between` clause against the parent object, given the lower and upper range. r)rK between_op)rArrrr3r3rBbetweenszColumnOperators.betweencCs |tS)zZProduce a :func:`_expression.distinct` clause against the parent object. )rK distinct_oprPr3r3rBdistinctszColumnOperators.distinctcCs |tS)aProduce an :func:`_expression.any_` clause against the parent object. See the documentation for :func:`_sql.any_` for examples. .. note:: be sure to not confuse the newer :meth:`_sql.ColumnOperators.any_` method with the **legacy** version of this method, the :meth:`_types.ARRAY.Comparator.any` method that's specific to :class:`_types.ARRAY`, which uses a different calling style. )rKany_oprPr3r3rBany_s zColumnOperators.any_cCs |tS)aProduce an :func:`_expression.all_` clause against the parent object. See the documentation for :func:`_sql.all_` for examples. .. note:: be sure to not confuse the newer :meth:`_sql.ColumnOperators.all_` method with the **legacy** version of this method, the :meth:`_types.ARRAY.Comparator.all` method that's specific to :class:`_types.ARRAY`, which uses a different calling style. )rKall_oprPr3r3rBall_s zColumnOperators.all_cCs |t|S)a4Implement the ``+`` operator. In a column context, produces the clause ``a + b`` if the parent object has non-string affinity. If the parent object has a string affinity, produces the concatenation operator, ``a || b`` - see :meth:`.ColumnOperators.concat`. )rKrrLr3r3rB__add__&s zColumnOperators.__add__cCs |t|S)zdImplement the ``-`` operator. In a column context, produces the clause ``a - b``. )rKrrLr3r3rB__sub__2szColumnOperators.__sub__cCs |t|S)zdImplement the ``*`` operator. In a column context, produces the clause ``a * b``. )rKrrLr3r3rB__mul__:szColumnOperators.__mul__cCs |t|S)zdImplement the ``%`` operator. In a column context, produces the clause ``a % b``. )rKrrLr3r3rB__mod__BszColumnOperators.__mod__cCs |t|S)aSImplement the ``/`` operator. In a column context, produces the clause ``a / b``, and considers the result type to be numeric. .. versionchanged:: 2.0 The truediv operator against two integers is now considered to return a numeric value. Behavior on specific backends may vary. )rKrrLr3r3rB __truediv__Js zColumnOperators.__truediv__cCs |t|S)zeImplement the ``/`` operator in reverse. See :meth:`.ColumnOperators.__truediv__`. )rerrLr3r3rB __rtruediv__WszColumnOperators.__rtruediv__cCs |t|S)zImplement the ``//`` operator. In a column context, produces the clause ``a / b``, which is the same as "truediv", but considers the result type to be integer. .. versionadded:: 2.0 )rKrrLr3r3rB __floordiv___s zColumnOperators.__floordiv__cCs |t|S)zgImplement the ``//`` operator in reverse. See :meth:`.ColumnOperators.__floordiv__`. )rerrLr3r3rB __rfloordiv__kszColumnOperators.__rfloordiv__)N)N)N)N)N)N)NF)NF)NF)NF)N)N)F)Or5rErFrGrHrrrItypingr"rKrersrtrnrDrlrvrwrxryrzr{r|r}rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr3r3r3rBrqs %          Y YUYRPL;8        rqzSet[Any] _commutative _comparisonzCallable[..., Any])fnr>cCs tt|Sr?)rr2rr3r3rB _operator_fnxsrcCst||Sr?)rrrr3r3rBcommutative_op|s rcCst||Sr?)rrrr3r3rB comparison_ops rrrOcCs tdSr?rcr3r3r3rBfrom_srcCs tdSr?rr3r3r3rBfunction_as_comparison_opsrcCs tdSr?rr3r3r3rBas_srcCs tdSr?rr3r3r3rBexistssr)ar>cCs tdSr?rrr3r3rBis_truesrcCsdSr?r3rr3r3rBistruesrcCs tdSr?rrr3r3rBis_falsesrcCsdSr?r3rr3r3rBisfalsesr)rbr>cCs ||Sr?)rwrrr3r3rBrwsrwcCs ||Sr?)rxrr3r3rBrxsrxcCsdSr?r3rr3r3rBrysrycCs ||Sr?)rrr3r3rBrsrcCs ||Sr?)rrr3r3rBrsrcCsdSr?r3rr3r3rBrsrcCs ||Sr?)rrr3r3rBrsrr4)rrUrr>cCs|||Sr?r_)rrUrr3r3rBr^sr^r)rrrr>cCs|j||dSNr)rrrrr3r3rBrsrcCs|j||dSr)rrr3r3rBrsrcCsdSr?r3rr3r3rB notlike_opsrcCs|j||dSr)rrr3r3rBrsrcCs|j||dSr)rrr3r3rBr srcCsdSr?r3rr3r3rB notilike_opsrFrS)rrcrr>cCs|j|||dSNrrrrrrr3r3rBrsrcCs|j|||dSrrrr3r3rBnot_between_op!srcCsdSr?r3rr3r3rB notbetween_op*srcCs ||Sr?)rrr3r3rBr3srcCs ||Sr?)rrr3r3rBr9srcCsdSr?r3rr3r3rBnotin_opBsrcCs|Sr?)rrr3r3rBrIsrcCs|Sr?)rrr3r3rBrNsrcCs|Sr?)rrr3r3rBrSsr)rr<rrr>cCst|rh|dk rtd|dkr"d}t|ts4td|dkrL||||}|d|dd|d}|||dS) NTz;The autoescape parameter is now a simple boolean True/False/z*String value expected when autoescape=True)%_rrr)r'warnrjr4 TypeErrorreplace)rr<rrr3r3rB_escaped_like_implXs r )rrrrr>cCst|j|||Sr?r rrrrrr3r3rBrnsrcCst|j|||Sr?r rr3r3rBnot_startswith_opvsrcCsdSr?r3rr3r3rBnotstartswith_opsrcCst|j|||Sr?r rrr3r3rBrsrcCst|j|||Sr?rrr3r3rBnot_istartswith_opsrcCst|j|||Sr?r rrr3r3rBrsrcCst|j|||Sr?rrr3r3rBnot_endswith_opsrcCsdSr?r3rr3r3rBnotendswith_opsrcCst|j|||Sr?r rrr3r3rBrsrcCst|j|||Sr?rrr3r3rBnot_iendswith_opsrcCst|j|||Sr?r rrr3r3rBrsrcCst|j|||Sr?rrr3r3rBnot_contains_opsrcCsdSr?r3rr3r3rBnotcontains_opsrcCst|j|||Sr?r rrr3r3rBrsrcCst|j|||Sr?rrr3r3rBnot_icontains_opsr)rrrr>cKs|j|f|Sr?rrrrr3r3rBrsr)rrrr>cCs|j||dSNrrrrrr3r3rBrsrcCs|j||dSrr r!r3r3rBnot_regexp_match_opsr")rrrrr>cCs|j|||dS)Nr)r)rrrrr3r3rBr srcKs|j|f|Sr?rrr3r3rB not_match_op sr#cKsdSr?r3rr3r3rB notmatch_op sr$cCs tdSr?rrr3r3rBcomma_op sr%cCs tdSr?rrr3r3rB filter_op sr&cCs6z |j}Wntk r(||YSX||SdSr?)rAttributeErrorr)rrrr3r3rBr% s  rcCs|Sr?)rrr3r3rBr/ srcCs|Sr?)rrr3r3rBr4 srcCs|Sr?)rrr3r3rBr9 srcCsdSr?r3rr3r3rB nullsfirst_opA sr(cCs|Sr?)rrr3r3rBrH srcCsdSr?r3rr3r3rB nullslast_opP sr)cCs tdSr?rrr3r3rBjson_getitem_opW sr*cCs tdSr?rrr3r3rBjson_path_getitem_op\ sr+cCs ||Sr?)rrr3r3rBra srcCs ||Sr?)rrr3r3rBrf srcCs ||Sr?)rrr3r3rBrk srcCs|Sr?)rrr3r3rBrp srcCs ||Sr?)rrr3r3rBru srcCs ||Sr?)rrr3r3rBrz sr)r^r>cCs|tkpt|to|jSr?)rrjr]rWr_r3r3rBrW srWcCs|tkSr?)rr_r3r3rBis_commutative sr,cCs|ttttfkSr?)rrrrr_r3r3rBis_ordering_modifier sr-cCs|tkpt|to|jSr?)_natural_self_precedentrjr]rgr_r3r3rBis_natural_self_precedent s r/cCst|p|tkSr?)rW _booleansr_r3r3rB is_boolean sr1cCs t||S)z[rotate a comparison operator 180 degrees. Note this is not the same as negation. )_mirrorgetr_r3r3rBmirror sr4cCs|tkSr?) _associativer_r3r3rBis_associative sr6zOptional[OperatorType]cCs|tkSr?)_order_by_modifierr_r3r3rBis_order_by_modifier sr8cCs tdSr?rrr3r3rB_asbool sr9c@seZdZdZdZdS)_OpLimitidN)r5rErF _smallest_largestr3r3r3rBr: sr:izDict[OperatorType, int] _PRECEDENCE)r[r\r>c CsT||krt|rdS|dkr dStt|t|dtjt|t|dtjkSdS)NFTrV)r/rSrFr3getattrr:r<r=)r[r\r3r3rB is_precedent s  rH)N)N)N)N)N)N)F)F)F)NF)NF)NF)NF)NF)NF)NF)NF)NF)NF)NF)NF)NF)NF)NF)N)N)N)rG __future__renumrr[rZ _uncast_addrZ _uncast_and_rZ_uncast_containsrZ _uncast_eqrZ_uncast_floordivr Z _uncast_ger Z_uncast_getitemr Z _uncast_gtr Z _uncast_invr Z _uncast_lerZ_uncast_lshiftrZ _uncast_ltrZ _uncast_modrZ _uncast_mulrZ _uncast_nerZ _uncast_negrZ _uncast_or_rZ_uncast_rshiftrZ _uncast_subrZ_uncast_truedivrrrrrrrrrr r!r"r#r$r&r'Z util.typingr(r)Z_typingr+ cache_keyr,elementsr-Ztype_apir.r/r1r2rDr]rqrrIrrrrrrrrrrrrrwrxryrrrrr^rrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrr"rr#r$r%r&rrrrr(rr)r*r+rrrrrrrWr,r-r/r0r1r2r4union differencer5r6r8r7r.r9r:rFrHr3r3r3rB s                                            "                    u    >