
    ؄_@                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lm	Z	 dd
lm
Z
 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ej        rddlmZ neZ G d de          Z G d de          Z G d de          ZeeeehZeeeeee
hZd Zd Z d  Z!e d!             Z"d" Z#d# Z$d$ Z%d% Z&e d&             Z'e d'             Z(e d(             Z)e d)             Z*d* Z+d+ Z,e dcd-            Z-e dcd.            Z.e dcd/            Z/e dcd0            Z0e ddd2            Z1e ddd3            Z2e d4             Z3e d5             Z4d6 Z5d7 Z6d8 Z7d9 Z8e ded:            Z9e ded;            Z:e ded<            Z;e ded=            Z<e ded>            Z=e ded?            Z>e d@             Z?e dA             Z@dB ZAe dC             ZBe dD             ZCdE ZDdF ZEdG ZFdH ZGdI ZHdJ ZIdK ZJdL ZKdM ZLdN ZMdO ZNdP ZOe	e%e&eefZPdQ ZQeeee
eee
eiZRdR ZSeT                    eEeeg          U                    eeg          ZVeVT                    eeJeKg          ZW	  ejX        dSdTU          ZY ejX        dVdWU          ZZ ejX        dXdYU          Z[i e!dZe"dZe6dZe7dZedZeJdZeKdZed[ed[ed[ed[ed[ed\ed\eEd]eDd]e?d^i e@d^e/d^e0d^e-d^e.d^e3d^e4d^e)d^e*d^ed^ed^e'd^e(d^eBd^eCd^ed^ed^i ed^e
d^e1d^e2d^e5d^e	d^e%d^e&d^ed_edeAd`eFd_eGd_e+dae#d`e$deYdTeZeZe[e[iZ\db Z]d,S )fz*Defines operators used in SQL expressions.    )add)and_)contains)eq)ge)getitem)gt)inv)le)lshift)lt)mod)mul)ne)neg)or_)rshift)sub)truediv   )util)divc                   F    e Zd ZdZdZd Zd Zd Z	 dd	Zdd
Z	d Z
d ZdS )	Operatorsa  Base 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`.

     c                 8    |                      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)

        )operater   selfothers     ]/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/sqlalchemy/sql/operators.py__and__zOperators.__and__;   s    , ||D%(((    c                 8    |                      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)

        )r   r   r   s     r!   __or__zOperators.__or__S   s    , ||C'''r#   c                 6    |                      t                    S )a  Implement 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)

        )r   r
   r   s    r!   
__invert__zOperators.__invert__k   s     ||C   r#   r   FNc                 :     t          ||||           fd}|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 operator: a string which will be output as the infix operator
          between this element and the expression passed to the
          generated function.

        :param precedence: precedence to apply to the operator, when
         parenthesizing expressions.  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.

        :param is_comparison: 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 should be set
         so that ORM relationships can establish that the operator is a
         comparison operator when used in a custom join condition.

         .. versionadded:: 0.9.2 - added the
            :paramref:`.Operators.op.is_comparison` flag.

        :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.

          .. versionadded:: 1.2.0b3 - added the
             :paramref:`.Operators.op.return_type` argument.

        .. seealso::

            :ref:`types_operators`

            :ref:`relationship_custom_operator`

        c                      |           S Nr   )r    operatorr   s    r!   againstzOperators.op.<locals>.against   s    8D%(((r#   )	custom_op)r   opstring
precedenceis_comparisonreturn_typer-   r,   s   `     @r!   opzOperators.op|   s?    t Xz=+NN	) 	) 	) 	) 	) 	) r#   c                 2    |                      ||d          S )a+  Return a custom boolean operator.

        This method is shorthand for calling
        :meth:`.Operators.op` and passing the
        :paramref:`.Operators.op.is_comparison`
        flag with True.

        .. versionadded:: 1.2.0b3

        .. seealso::

            :meth:`.Operators.op`

        T)r0   r1   r3   )r   r/   r0   s      r!   bool_opzOperators.bool_op   s     wwxJdwKKKr#   c                 :    t          t          |                    )a3  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`.


        NotImplementedErrorstrr   r3   r    kwargss       r!   r   zOperators.operate   s    0 "#b''***r#   c                 :    t          t          |                    )zXReverse operate on an argument.

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

        r8   r;   s       r!   reverse_operatezOperators.reverse_operate   s     "#b''***r#   )r   FN)r   )__name__
__module____qualname____doc__	__slots__r"   r%   r(   r3   r6   r   r>   r   r#   r!   r   r   *   s          I) ) )0( ( (0! ! !$ HL? ? ? ?BL L L L"+ + +4+ + + + +r#   r   c                   :    e Zd ZdZd Z 	 	 	 	 	 d	dZd Zd Zd ZdS )
r.   a  Represent 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`

    r   FNc                     || _         || _        || _        || _        || _        |r|                    |          nd | _        d S r+   )r/   r0   r1   natural_self_precedenteager_grouping_to_instancer2   )r   r/   r0   r1   r2   rF   rG   s          r!   __init__zcustom_op.__init__  sS     !$*&<#,5@JK$$[111d 	r#   c                 L    t          |t                    o|j        | j        k    S r+   )
isinstancer.   r/   r   s     r!   __eq__zcustom_op.__eq__  s     %++O$-0OOr#   c                      t          |           S r+   )idr'   s    r!   __hash__zcustom_op.__hash__"  s    $xxr#   c                       |j         | |fi |S r+   )r   )r   leftrightkws       r!   __call__zcustom_op.__call__%  s    t|D%..2...r#   )r   FNFF)r?   r@   rA   rB   rI   rL   rO   rT   r   r#   r!   r.   r.      sz         2 H
 $
 
 
 
$P P P  / / / / /r#   r.   c                   N   e Zd ZdZdZdZ	 d Zd Zej	        Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd4dZd4dZd Zd Zd4dZd4dZd Zd Zd Zd Zd Z d Z!d Z"d Z#d  Z$d! Z%d" Z&d# Z'd$ Z(d% Z)d& Z*d' Z+d5d)Z,d* Z-d+ Z.d, Z/d- Z0d. Z1d/ Z2d0 Z3d1 Z4d2 Z5d3 Z6dS )6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`

    r   Nc                 8    |                      t          |          S )zdImplement the ``<`` operator.

        In a column context, produces the clause ``a < b``.

        )r   r   r   s     r!   __lt__zColumnOperators.__lt__T       ||B&&&r#   c                 8    |                      t          |          S )zfImplement the ``<=`` operator.

        In a column context, produces the clause ``a <= b``.

        )r   r   r   s     r!   __le__zColumnOperators.__le__\  rY   r#   c                 8    |                      t          |          S )zImplement the ``==`` operator.

        In a column context, produces the clause ``a = b``.
        If the target is ``None``, produces ``a IS NULL``.

        )r   r   r   s     r!   rL   zColumnOperators.__eq__f       ||B&&&r#   c                 8    |                      t          |          S )zImplement the ``!=`` operator.

        In a column context, produces the clause ``a != b``.
        If the target is ``None``, produces ``a IS NOT NULL``.

        )r   r   r   s     r!   __ne__zColumnOperators.__ne__o  r]   r#   c                 8    |                      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".

        .. versionadded:: 1.1

        )r   is_distinct_fromr   s     r!   ra   z ColumnOperators.is_distinct_fromx  s     ||,e444r#   c                 8    |                      t          |          S )zImplement 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".

        .. versionadded:: 1.1

        )r   isnot_distinct_fromr   s     r!   rc   z#ColumnOperators.isnot_distinct_from  s     ||/777r#   c                 8    |                      t          |          S )zdImplement the ``>`` operator.

        In a column context, produces the clause ``a > b``.

        )r   r	   r   s     r!   __gt__zColumnOperators.__gt__  rY   r#   c                 8    |                      t          |          S )zfImplement the ``>=`` operator.

        In a column context, produces the clause ``a >= b``.

        )r   r   r   s     r!   __ge__zColumnOperators.__ge__  rY   r#   c                 6    |                      t                    S )zaImplement the ``-`` operator.

        In a column context, produces the clause ``-a``.

        )r   r   r'   s    r!   __neg__zColumnOperators.__neg__  s     ||C   r#   c                 8    |                      t          |          S r+   )r   r   r   s     r!   __contains__zColumnOperators.__contains__  s    ||He,,,r#   c                 8    |                      t          |          S )zImplement the [] operator.

        This can be used by some database-specific types
        such as PostgreSQL ARRAY and HSTORE.

        )r   r   )r   indexs     r!   __getitem__zColumnOperators.__getitem__  s     ||GU+++r#   c                 8    |                      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.
        )r   r   r   s     r!   
__lshift__zColumnOperators.__lshift__       ||FE***r#   c                 8    |                      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.
        )r   r   r   s     r!   
__rshift__zColumnOperators.__rshift__  rq   r#   c                 8    |                      t          |          S )zImplement the 'concat' operator.

        In a column context, produces the clause ``a || b``,
        or uses the ``concat()`` operator on MySQL.

        )r   	concat_opr   s     r!   concatzColumnOperators.concat  s     ||Iu---r#   c                 <    |                      t          ||          S )a  Implement 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`

        escape)r   like_opr   r    ry   s      r!   likezColumnOperators.like  s    . ||GU6|:::r#   c                 <    |                      t          ||          S )a  Implement 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`

        rx   )r   ilike_opr{   s      r!   ilikezColumnOperators.ilike  s    6 ||HeF|;;;r#   c                 8    |                      t          |          S )a  Implement the ``in`` operator.

        In a column context, produces the clause ``column IN <other>``.

        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 a "false" expression,
          e.g.::

            WHERE 1 != 1

          This "false" expression has historically had different behaviors
          in older SQLAlchemy versions, see
          :paramref:`_sa.create_engine.empty_in_strategy`
          for behavioral options.

          .. versionchanged:: 1.2 simplified the behavior of "empty in"
             expressions

        * 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.

        )r   in_opr   s     r!   in_zColumnOperators.in_  s    x ||E5)))r#   c                 8    |                      t          |          S )a  implement 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.2  The :meth:`.ColumnOperators.in_` and
           :meth:`.ColumnOperators.notin_` operators
           now produce a "static" expression for an empty IN sequence
           by default.

        .. seealso::

            :meth:`.ColumnOperators.in_`

        )r   notin_opr   s     r!   notin_zColumnOperators.notin_a  s    , ||He,,,r#   c                 <    |                      t          ||          S )zimplement the ``NOT LIKE`` operator.

        This is equivalent to using negation with
        :meth:`.ColumnOperators.like`, i.e. ``~x.like(y)``.

        .. seealso::

            :meth:`.ColumnOperators.like`

        rx   )r   
notlike_opr{   s      r!   notlikezColumnOperators.notlikey  s     ||Jf|===r#   c                 <    |                      t          ||          S )zimplement the ``NOT ILIKE`` operator.

        This is equivalent to using negation with
        :meth:`.ColumnOperators.ilike`, i.e. ``~x.ilike(y)``.

        .. seealso::

            :meth:`.ColumnOperators.ilike`

        rx   )r   notilike_opr{   s      r!   notilikezColumnOperators.notilike  s     ||Kv|>>>r#   c                 8    |                      t          |          S )aV  Implement 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.isnot`

        )r   is_r   s     r!   r   zColumnOperators.is_  s     ||C'''r#   c                 8    |                      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.

        .. seealso:: :meth:`.ColumnOperators.is_`

        )r   isnotr   s     r!   r   zColumnOperators.isnot  s     ||E5)))r#   c                 *     | j         t          |fi |S )a  Implement the ``startswith`` operator.

        Produces a LIKE expression that tests against a match for the start
        of a string value::

            column LIKE <other> || '%'

        E.g.::

            stmt = select([sometable]).\
                where(sometable.c.column.startswith("foobar"))

        Since the operator uses ``LIKE``, wildcard characters
        ``"%"`` and ``"_"`` that are present inside the <other> 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"``.

          .. versionadded:: 1.2

          .. versionchanged:: 1.2.0 The
            :paramref:`.ColumnOperators.startswith.autoescape` parameter is
             now a simple boolean rather than a character; the escape
             character itself is also escaped, and defaults to a forwards
             slash, which itself can be customized using the
             :paramref:`.ColumnOperators.startswith.escape` parameter.

        :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`

        )r   startswith_opr   r    r<   s      r!   
startswithzColumnOperators.startswith  s!    l t|M5;;F;;;r#   c                 *     | j         t          |fi |S )a  Implement the 'endswith' operator.

        Produces a LIKE expression that tests against a match for the end
        of a string value::

            column LIKE '%' || <other>

        E.g.::

            stmt = select([sometable]).\
                where(sometable.c.column.endswith("foobar"))

        Since the operator uses ``LIKE``, wildcard characters
        ``"%"`` and ``"_"`` that are present inside the <other> 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"``.

          .. versionadded:: 1.2

          .. versionchanged:: 1.2.0 The
            :paramref:`.ColumnOperators.endswith.autoescape` parameter is
             now a simple boolean rather than a character; the escape
             character itself is also escaped, and defaults to a forwards
             slash, which itself can be customized using the
             :paramref:`.ColumnOperators.endswith.escape` parameter.

        :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   endswith_opr   s      r!   endswithzColumnOperators.endswith  s!    l t|K99&999r#   c                 *     | j         t          |fi |S )a   Implement the 'contains' operator.

        Produces a LIKE expression that tests against a match for the middle
        of a string value::

            column LIKE '%' || <other> || '%'

        E.g.::

            stmt = select([sometable]).\
                where(sometable.c.column.contains("foobar"))

        Since the operator uses ``LIKE``, wildcard characters
        ``"%"`` and ``"_"`` that are present inside the <other> 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"``.

          .. versionadded:: 1.2

          .. versionchanged:: 1.2.0 The
            :paramref:`.ColumnOperators.contains.autoescape` parameter is
             now a simple boolean rather than a character; the escape
             character itself is also escaped, and defaults to a forwards
             slash, which itself can be customized using the
             :paramref:`.ColumnOperators.contains.escape` parameter.

        :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`


        )r   contains_opr   s      r!   r   zColumnOperators.contains]  s!    n t|K99&999r#   c                 *     | j         t          |fi |S )aY  Implements a database-specific 'match' operator.

        :meth:`~.ColumnOperators.match` attempts to resolve to
        a MATCH-like function or operator provided by the backend.
        Examples include:

        * PostgreSQL - renders ``x @@ to_tsquery(y)``
        * MySQL - renders ``MATCH (x) AGAINST (y IN BOOLEAN MODE)``
        * 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.

        )r   match_opr   s      r!   matchzColumnOperators.match  s       t|He66v666r#   c                 6    |                      t                    S )zLProduce a :func:`_expression.desc` clause against the
        parent object.)r   desc_opr'   s    r!   desczColumnOperators.desc  s     ||G$$$r#   c                 6    |                      t                    S )zKProduce a :func:`_expression.asc` clause against the
        parent object.)r   asc_opr'   s    r!   asczColumnOperators.asc  s     ||F###r#   c                 6    |                      t                    S )zRProduce a :func:`_expression.nullsfirst` clause against the
        parent object.)r   nullsfirst_opr'   s    r!   
nullsfirstzColumnOperators.nullsfirst  s     ||M***r#   c                 6    |                      t                    S )zQProduce a :func:`_expression.nullslast` clause against the
        parent object.)r   nullslast_opr'   s    r!   	nullslastzColumnOperators.nullslast  s     ||L)))r#   c                 8    |                      t          |          S )zProduce a :func:`_expression.collate` clause against
        the parent object, given the collation string.

        .. seealso::

            :func:`_expression.collate`

        )r   collate)r   	collations     r!   r   zColumnOperators.collate  s     ||GY///r#   c                 8    |                      t          |          S )zaImplement the ``+`` operator in reverse.

        See :meth:`.ColumnOperators.__add__`.

        )r>   r   r   s     r!   __radd__zColumnOperators.__radd__       ##C///r#   c                 8    |                      t          |          S )zaImplement the ``-`` operator in reverse.

        See :meth:`.ColumnOperators.__sub__`.

        )r>   r   r   s     r!   __rsub__zColumnOperators.__rsub__  r   r#   c                 8    |                      t          |          S )zaImplement the ``*`` operator in reverse.

        See :meth:`.ColumnOperators.__mul__`.

        )r>   r   r   s     r!   __rmul__zColumnOperators.__rmul__  r   r#   c                 8    |                      t          |          S )zaImplement the ``/`` operator in reverse.

        See :meth:`.ColumnOperators.__div__`.

        )r>   r   r   s     r!   __rdiv__zColumnOperators.__rdiv__  r   r#   c                 8    |                      t          |          S )zaImplement the ``%`` operator in reverse.

        See :meth:`.ColumnOperators.__mod__`.

        )r>   r   r   s     r!   __rmod__zColumnOperators.__rmod__  r   r#   Fc                 >    |                      t          |||          S )zzProduce a :func:`_expression.between` clause against
        the parent object, given the lower and upper range.

        	symmetric)r   
between_op)r   cleftcrightr   s       r!   betweenzColumnOperators.between  s    
 ||Jv|KKKr#   c                 6    |                      t                    S )zZProduce a :func:`_expression.distinct` clause against the
        parent object.

        )r   distinct_opr'   s    r!   distinctzColumnOperators.distinct  s    
 ||K(((r#   c                 6    |                      t                    S )a  Produce a :func:`_expression.any_` clause against the
        parent object.

        This operator is only appropriate against a scalar subquery
        object, or for some backends an column expression that is
        against the ARRAY type, e.g.::

            # postgresql '5 = ANY (somearray)'
            expr = 5 == mytable.c.somearray.any_()

            # mysql '5 = ANY (SELECT value FROM table)'
            expr = 5 == select([table.c.value]).as_scalar().any_()

        .. seealso::

            :func:`_expression.any_` - standalone version

            :func:`_expression.all_` - ALL operator

        .. versionadded:: 1.1

        )r   any_opr'   s    r!   any_zColumnOperators.any_      . ||F###r#   c                 6    |                      t                    S )a  Produce a :func:`_expression.all_` clause against the
        parent object.

        This operator is only appropriate against a scalar subquery
        object, or for some backends an column expression that is
        against the ARRAY type, e.g.::

            # postgresql '5 = ALL (somearray)'
            expr = 5 == mytable.c.somearray.all_()

            # mysql '5 = ALL (SELECT value FROM table)'
            expr = 5 == select([table.c.value]).as_scalar().all_()

        .. seealso::

            :func:`_expression.all_` - standalone version

            :func:`_expression.any_` - ANY operator

        .. versionadded:: 1.1

        )r   all_opr'   s    r!   all_zColumnOperators.all_6  r   r#   c                 8    |                      t          |          S )a4  Implement 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`.

        )r   r   r   s     r!   __add__zColumnOperators.__add__O  s     ||C'''r#   c                 8    |                      t          |          S )zdImplement the ``-`` operator.

        In a column context, produces the clause ``a - b``.

        )r   r   r   s     r!   __sub__zColumnOperators.__sub__[       ||C'''r#   c                 8    |                      t          |          S )zdImplement the ``*`` operator.

        In a column context, produces the clause ``a * b``.

        )r   r   r   s     r!   __mul__zColumnOperators.__mul__c  r   r#   c                 8    |                      t          |          S )zdImplement the ``/`` operator.

        In a column context, produces the clause ``a / b``.

        )r   r   r   s     r!   __div__zColumnOperators.__div__k  r   r#   c                 8    |                      t          |          S )zdImplement the ``%`` operator.

        In a column context, produces the clause ``a % b``.

        )r   r   r   s     r!   __mod__zColumnOperators.__mod__s  r   r#   c                 8    |                      t          |          S )zeImplement the ``//`` operator.

        In a column context, produces the clause ``a / b``.

        )r   r   r   s     r!   __truediv__zColumnOperators.__truediv__{  s     ||GU+++r#   c                 8    |                      t          |          S )zfImplement the ``//`` operator in reverse.

        See :meth:`.ColumnOperators.__truediv__`.

        )r>   r   r   s     r!   __rtruediv__zColumnOperators.__rtruediv__  s     ##GU333r#   r+   F)7r?   r@   rA   rB   rC   	timetuplerX   r[   r   rO   rL   r_   ra   rc   re   rg   ri   rk   rn   rp   rs   rv   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r#   r!   rV   rV   )  s&       # #J IIB' ' '' ' ' !H' ' '' ' '	5 	5 	5	8 	8 	8' ' '' ' '! ! !- - -, , ,+ + ++ + +. . .; ; ; ;2< < < <:\* \* \*|- - -0> > > >? ? ? ?( ( (* * *V< V< V<pV: V: V:pW: W: W:r7 7 7$% % %
$ $ $
+ + +
* * *
	0 	0 	00 0 00 0 00 0 00 0 00 0 0L L L L) ) )$ $ $2$ $ $2
( 
( 
(( ( (( ( (( ( (( ( (, , ,4 4 4 4 4r#   rV   c                 :    t                               |            | S r+   )_commutativer   fns    r!   commutative_opr     s    RIr#   c                 :    t                               |            | S r+   )_comparisonr   r   s    r!   comparison_opr     s    OOBIr#   c                      t                      r+   r9   r   r#   r!   from_r         


r#   c                      t                      r+   r   r   r#   r!   function_as_comparison_opr         


r#   c                      t                      r+   r   r   r#   r!   as_r     r   r#   c                      t                      r+   r   r   r#   r!   existsr     r   r#   c                     t                      r+   r   as    r!   istruer     r   r#   c                     t                      r+   r   r   s    r!   isfalser     r   r#   c                 ,    |                      |          S r+   )ra   r   bs     r!   ra   ra     s    a   r#   c                 ,    |                      |          S r+   )rc   r   s     r!   rc   rc     s      ###r#   c                 ,    |                      |          S r+   )r   r   s     r!   r   r         5588Or#   c                 ,    |                      |          S r+   )r   r   s     r!   r   r     s    771::r#   c                 ,    |                      |          S r+   )r   r   s     r!   r   r     s    99Q<<r#   c                 >     |                      |          |          S r+   r5   )r   r/   r   s      r!   r3   r3     s    144>>!r#   Nc                 0    |                      ||          S Nrx   )r|   r   r   ry   s      r!   rz   rz     s    66!F6###r#   c                 0    |                      ||          S r   )r   r   s      r!   r   r     s    99Qv9&&&r#   c                 0    |                      ||          S r   )r   r   s      r!   r~   r~     s    771V7$$$r#   c                 0    |                      ||          S r   )r   r   s      r!   r   r     s    ::a:'''r#   Fc                 2    |                      |||          S Nr   )r   r   r   cr   s       r!   r   r     s    99QY9///r#   c                 2    |                      |||          S r  )
notbetweenr  s       r!   notbetween_opr    s    <<1	<222r#   c                 ,    |                      |          S r+   )r   r   s     r!   r   r     r   r#   c                 ,    |                      |          S r+   )r   r   s     r!   r   r     s    88A;;r#   c                 *    |                                  S r+   )r   r   s    r!   r   r     s    ::<<r#   c                 *    |                                  S r+   )r   r   s    r!   r   r         6688Or#   c                 *    |                                  S r+   )r   r   s    r!   r   r     r  r#   c                 N   |r|durt          j        d           |d}t          |t           j        j                  st          d          |dvr|                    |||z             }|                    d|dz                                 d|dz             } | ||          S )	NTz;The autoescape parameter is now a simple boolean True/False/z*String value expected when autoescape=True)%_r  r  rx   )r   warnrK   compatstring_types	TypeErrorreplace)r   r    ry   
autoescapes       r!   _escaped_like_implr    s     LT!!IM   >F%!9:: 	JHIII##MM&&6/::Ec6C<0088fslKK2eF####r#   c                 0    t          | j        |||          S r+   r  r   r   r   ry   r  s       r!   r   r     s    alAvzBBBr#   c                 2    t          | j        |||           S r+   r  r  s       r!   notstartswith_opr    s    q|Q
CCCCr#   c                 0    t          | j        |||          S r+   r  r   r  s       r!   r   r   !      aj!VZ@@@r#   c                 2    t          | j        |||           S r+   r  r  s       r!   notendswith_opr!  &      qz1fjAAAAr#   c                 0    t          | j        |||          S r+   r  r   r  s       r!   r   r   +  r  r#   c                 2    t          | j        |||           S r+   r$  r  s       r!   notcontains_opr&  0  r"  r#   c                      | j         |fi |S r+   )r   r   r   rS   s      r!   r   r   5  s    171r#   c                      | j         |fi |S r+   )notmatchr(  s      r!   notmatch_opr+  :  s    1:a2r#   c                     t                      r+   r   r   s     r!   comma_opr-  ?  r   r#   c                     t                      r+   r   r   s     r!   empty_in_opr/  C  r   r#   c                     t                      r+   r   r   s     r!   empty_notin_opr1  H  r   r#   c                     t                      r+   r   r   s     r!   	filter_opr3  M  r   r#   c                 ,    |                      |          S r+   )rv   r   s     r!   ru   ru   Q  s    88A;;r#   c                 *    |                                  S r+   )r   r   s    r!   r   r   U  r  r#   c                 *    |                                  S r+   )r   r   s    r!   r   r   Y  s    5577Nr#   c                 *    |                                  S r+   )r   r   s    r!   r   r   ]  s    <<>>r#   c                 *    |                                  S r+   )r   r   s    r!   r   r   a  s    ;;==r#   c                     t                      r+   r   r   s     r!   json_getitem_opr:  e  r   r#   c                     t                      r+   r   r   s     r!   json_path_getitem_opr<  i  r   r#   c                 L    | t           v pt          | t                    o| j        S r+   )r   rK   r.   r1   r5   s    r!   r1   r1   m  s$    N
2y 9 9 Nb>NNr#   c                     | t           v S r+   )r   r5   s    r!   is_commutativer?  q  s    r#   c                 :    | t           t          t          t          fv S r+   )r   r   r   r   r5   s    r!   is_ordering_modifierrA  u  s    &'=,???r#   c                 L    | t           v pt          | t                    o| j        S r+   )_natural_self_precedentrK   r.   rF   r5   s    r!   is_natural_self_precedentrD  y  s-    
%% 	&b)$$ &%r#   c                 2    t          |           p| t          v S r+   )r1   	_booleansr5   s    r!   
is_booleanrG    s    /i/r#   c                 8    t                               | |           S )z[rotate a comparison operator 180 degrees.

    Note this is not the same as negation.

    )_mirrorgetr5   s    r!   mirrorrK    s     ;;r2r#   _asbooli)	canonical	_smallesti_largestd                        c           	          | |u rt          |           rdS t                              | t          | dt                              t                              |t          |dt
                              k    S )NFr0   )rD  _PRECEDENCErJ  getattrrN  rO  )r,   r-   s     r!   is_precedentr\    sk    78BBughi@@
 
__Wgg|X&N&NOOP 	Pr#   r+   r   )NF)^rB   r,   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r    r   py2kr   objectr   r.   rV   r   r   r   r   r   r   r   r   r   r   ra   rc   r   r   r   r3   rz   r   r~   r   r   r  r   r   r   r   r   r  r   r  r   r!  r   r&  r   r+  r-  r/  r1  r3  ru   r   r   r   r   r:  r<  r1   r?  rA  rD  rF  rG  rI  rK  union
difference_associativerC  symbolrL  rN  rO  rZ  r\  r   r#   r!   <module>rd     sU
   1 0                                                                                                                         9 
CD+ D+ D+ D+ D+ D+ D+ D+N5/ 5/ 5/ 5/ 5/ 5/ 5/ 5/p`4 `4 `4 `4 `4i `4 `4 `4F BS!2r2r2&  
  
                                ! ! ! $ $ $           $ $ $ $ ' ' ' ' % % % % ( ( ( ( 0 0 0 0 3 3 3 3            $ $ $( C C C C D D D D A A A A B B B B A A A A B B B B                                                O O O  @ @ @   &'4-	0 0 0 r2r2r2r
*   !!9dC"899DDb"XNN&,,o34   $+i3
/
/
/DKt444	4;zS1116	26r6 B6 B	6
 R6 R6 "6 6 Q6 6 6 6 6 6 q6  q!6" a#6 6$ %6& a'6( )6* Q+6, -6. 
1/60 a162 364 
1566 768 96: a;6< =6> ?6@ AA6B C6D E6 6 6F G6H I6J K6L 1M6N O6P Q6R AS6T QU6V 	!W6X Y6Z b[6\ Q]6^ A_6` Qa6b c6d Ae6f Sg6 6h yhk6 6rP P P P Pr#   