o
    [h@                     @   s2  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rddlmZ neZG dd deZG dd deZG dd deZeeeehZeeeeee
hZdd Zd d! Z d"d# Z!e d$d% Z"d&d' Z#d(d) Z$d*d+ Z%d,d- Z&e d.d/ Z'e d0d1 Z(e d2d3 Z)e d4d5 Z*d6d7 Z+d8d9 Z,e dd;d<Z-e dd=d>Z.e dd?d@Z/e ddAdBZ0e ddDdEZ1e ddFdGZ2e dHdI Z3e dJdK Z4dLdM Z5dNdO Z6dPdQ Z7dRdS Z8e ddTdUZ9e ddVdWZ:e ddXdYZ;e ddZd[Z<e dd\d]Z=e dd^d_Z>e d`da Z?e dbdc Z@ddde ZAe dfdg ZBe dhdi ZCdjdk ZDdldm ZEdndo ZFdpdq ZGdrds ZHdtdu ZIdvdw ZJdxdy ZKdzd{ ZLd|d} ZMd~d ZNdd ZOe	e%e&eefZPdd ZQeeee
eee
eiZRdd ZSeTeEeegUeegZVeVTeeJeKgZW	 ejXdddZYejXdddZZejXdddZ[i e!de"de6de7dedeJdeKd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+de#de$deYdeZeZe[e[iZ\dd Z]d:S )z*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                   @   sR   e Zd ZdZdZdd Zdd Zdd Z	dddZdddZ	dd Z
d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                 C      |  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otherr   r   /home/ubuntu/experiments/live_experiments/Pythonexperiments/Otree/venv/lib/python3.10/site-packages/sqlalchemy/sql/operators.py__and__;      zOperators.__and__c                 C   r   )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   r   r   r   __or__S   r!   zOperators.__or__c                 C   
   |  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   r   r   r   
__invert__k   s   
zOperators.__invert__r   FNc                    s    t ||||  fd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
    | S Nr   )r   operatorr   r   r   against      
zOperators.op.<locals>.against)	custom_op)r   opstring
precedenceis_comparisonreturn_typer)   r   r'   r   op|   s   :zOperators.opc                 C   s   | j ||d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)r-   r.   r0   )r   r,   r-   r   r   r   bool_op   s   zOperators.bool_opc                 O      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   r0   r   kwargsr   r   r   r      s   zOperators.operatec                 K   r3   )zXReverse operate on an argument.

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

        r4   r7   r   r   r   reverse_operate      zOperators.reverse_operate)r   FN)r   )__name__
__module____qualname____doc__	__slots__r    r"   r%   r0   r2   r   r9   r   r   r   r   r   *   s    

Ar   c                   @   s@   e Zd ZdZd Z 					dddZdd Zd	d
 Zd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                 C   s<   || _ || _|| _|| _|| _|r||| _d S d | _d S r&   )r,   r-   r.   natural_self_precedenteager_groupingZ_to_instancer/   )r   r,   r-   r.   r/   r@   rA   r   r   r   __init__  s   	zcustom_op.__init__c                 C   s   t |to
|j| jkS r&   )
isinstancer+   r,   r   r   r   r   __eq__  s   zcustom_op.__eq__c                 C   s   t | S r&   )idr$   r   r   r   __hash__"     zcustom_op.__hash__c                 K   s   |j | |fi |S r&   )r   )r   leftrightkwr   r   r   __call__%  s   zcustom_op.__call__)r   FNFF)r;   r<   r=   r>   rB   rD   rF   rK   r   r   r   r   r+      s    
r+   c                   @   s  e Zd ZdZdZdZ	 dd Zdd Zej	Z	dd	 Z
d
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdcd d!Zdcd"d#Zd$d% Zd&d' Zdcd(d)Zdcd*d+Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Z d6d7 Z!d8d9 Z"d:d; Z#d<d= Z$d>d? Z%d@dA Z&dBdC Z'dDdE Z(dFdG Z)dHdI Z*dJdK Z+dddMdNZ,dOdP Z-dQdR Z.dSdT Z/dUdV Z0dWdX Z1dYdZ Z2d[d\ Z3d]d^ Z4d_d` Z5dadb Z6dS )e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                 C   r   )zdImplement the ``<`` operator.

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

        )r   r   r   r   r   r   __lt__T  r:   zColumnOperators.__lt__c                 C   r   )zfImplement the ``<=`` operator.

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

        )r   r
   r   r   r   r   __le__\  r:   zColumnOperators.__le__c                 C   r   )zImplement the ``==`` operator.

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

        )r   r   r   r   r   r   rD   f     zColumnOperators.__eq__c                 C   r   )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   r   r   r   __ne__o  rO   zColumnOperators.__ne__c                 C   r   )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   r   r   r   rQ   x     	z ColumnOperators.is_distinct_fromc                 C   r   )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   r   r   r   rS     rR   z#ColumnOperators.isnot_distinct_fromc                 C   r   )zdImplement the ``>`` operator.

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

        )r   r   r   r   r   r   __gt__  r:   zColumnOperators.__gt__c                 C   r   )zfImplement the ``>=`` operator.

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

        )r   r   r   r   r   r   __ge__  r:   zColumnOperators.__ge__c                 C   r#   )zaImplement the ``-`` operator.

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

        )r   r   r$   r   r   r   __neg__  s   
zColumnOperators.__neg__c                 C   r   r&   )r   r   r   r   r   r   __contains__  s   zColumnOperators.__contains__c                 C   r   )zImplement the [] operator.

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

        )r   r   )r   indexr   r   r   __getitem__  rO   zColumnOperators.__getitem__c                 C   r   )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   r   r   r   
__lshift__  rO   zColumnOperators.__lshift__c                 C   r   )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   r   r   r   
__rshift__  rO   zColumnOperators.__rshift__c                 C   r   )zImplement the 'concat' operator.

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

        )r   	concat_opr   r   r   r   concat  rO   zColumnOperators.concatc                 C      | j t||d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   r`   r   r   r   like  s   zColumnOperators.likec                 C   r^   )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`

        r_   )r   ilike_oprb   r   r   r   ilike  s   zColumnOperators.ilikec                 C   r   )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   r   r   r   in_  s   \zColumnOperators.in_c                 C   r   )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   r   r   r   notin_a  r!   zColumnOperators.notin_c                 C   r^   )zimplement the ``NOT LIKE`` operator.

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

        .. seealso::

            :meth:`.ColumnOperators.like`

        r_   )r   
notlike_oprb   r   r   r   notlikey     zColumnOperators.notlikec                 C   r^   )zimplement the ``NOT ILIKE`` operator.

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

        .. seealso::

            :meth:`.ColumnOperators.ilike`

        r_   )r   notilike_oprb   r   r   r   notilike  rl   zColumnOperators.notilikec                 C   r   )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   r   r   r   ro        zColumnOperators.is_c                 C   r   )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   r   r   r   rq     rp   zColumnOperators.isnotc                 K      | 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   r8   r   r   r   
startswith     VzColumnOperators.startswithc                 K   rr   )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_oprt   r   r   r   endswith  rv   zColumnOperators.endswithc                 K   rr   )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_oprt   r   r   r   r   ]  s   WzColumnOperators.containsc                 K   rr   )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_oprt   r   r   r   match  s   zColumnOperators.matchc                 C   r#   )zLProduce a :func:`_expression.desc` clause against the
        parent object.)r   desc_opr$   r   r   r   desc     
zColumnOperators.descc                 C   r#   )zKProduce a :func:`_expression.asc` clause against the
        parent object.)r   asc_opr$   r   r   r   asc  r~   zColumnOperators.ascc                 C   r#   )zRProduce a :func:`_expression.nullsfirst` clause against the
        parent object.)r   nullsfirst_opr$   r   r   r   
nullsfirst  r~   zColumnOperators.nullsfirstc                 C   r#   )zQProduce a :func:`_expression.nullslast` clause against the
        parent object.)r   nullslast_opr$   r   r   r   	nullslast  r~   zColumnOperators.nullslastc                 C   r   )zProduce a :func:`_expression.collate` clause against
        the parent object, given the collation string.

        .. seealso::

            :func:`_expression.collate`

        )r   collate)r   Z	collationr   r   r   r     rR   zColumnOperators.collatec                 C   r   )zaImplement the ``+`` operator in reverse.

        See :meth:`.ColumnOperators.__add__`.

        )r9   r   r   r   r   r   __radd__  r:   zColumnOperators.__radd__c                 C   r   )zaImplement the ``-`` operator in reverse.

        See :meth:`.ColumnOperators.__sub__`.

        )r9   r   r   r   r   r   __rsub__  r:   zColumnOperators.__rsub__c                 C   r   )zaImplement the ``*`` operator in reverse.

        See :meth:`.ColumnOperators.__mul__`.

        )r9   r   r   r   r   r   __rmul__  r:   zColumnOperators.__rmul__c                 C   r   )zaImplement the ``/`` operator in reverse.

        See :meth:`.ColumnOperators.__div__`.

        )r9   r   r   r   r   r   __rdiv__  r:   zColumnOperators.__rdiv__c                 C   r   )zaImplement the ``%`` operator in reverse.

        See :meth:`.ColumnOperators.__mod__`.

        )r9   r   r   r   r   r   __rmod__  r:   zColumnOperators.__rmod__Fc                 C   s   | j t|||dS )zzProduce a :func:`_expression.between` clause against
        the parent object, given the lower and upper range.

        	symmetric)r   
between_op)r   ZcleftZcrightr   r   r   r   between  s   zColumnOperators.betweenc                 C   r#   )zZProduce a :func:`_expression.distinct` clause against the
        parent object.

        )r   distinct_opr$   r   r   r   distinct  s   
zColumnOperators.distinctc                 C   r#   )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$   r   r   r   any_     
zColumnOperators.any_c                 C   r#   )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$   r   r   r   all_6  r   zColumnOperators.all_c                 C   r   )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   r   r   r   __add__O  s   
zColumnOperators.__add__c                 C   r   )zdImplement the ``-`` operator.

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

        )r   r   r   r   r   r   __sub__[  r:   zColumnOperators.__sub__c                 C   r   )zdImplement the ``*`` operator.

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

        )r   r   r   r   r   r   __mul__c  r:   zColumnOperators.__mul__c                 C   r   )zdImplement the ``/`` operator.

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

        )r   r   r   r   r   r   __div__k  r:   zColumnOperators.__div__c                 C   r   )zdImplement the ``%`` operator.

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

        )r   r   r   r   r   r   __mod__s  r:   zColumnOperators.__mod__c                 C   r   )zeImplement the ``//`` operator.

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

        )r   r   r   r   r   r   __truediv__{  r:   zColumnOperators.__truediv__c                 C   r   )zfImplement the ``//`` operator in reverse.

        See :meth:`.ColumnOperators.__truediv__`.

        )r9   r   r   r   r   r   __rtruediv__  r:   zColumnOperators.__rtruediv__r&   F)7r;   r<   r=   r>   r?   	timetuplerM   rN   r   rF   rD   rP   rQ   rS   rT   rU   rV   rW   rY   rZ   r[   r]   rc   re   rg   ri   rk   rn   ro   rq   ru   rx   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   rL   )  sj    %					
	
^

XXY
rL   c                 C      t |  | S r&   )_commutativer   fnr   r   r   commutative_op     
r   c                 C   r   r&   )_comparisonr   r   r   r   r   comparison_op  r   r   c                   C      t  r&   r5   r   r   r   r   from_     r   c                   C   r   r&   r   r   r   r   r   function_as_comparison_op     r   c                   C   r   r&   r   r   r   r   r   as_  r   r   c                   C   r   r&   r   r   r   r   r   exists  r   r   c                 C   r   r&   r   ar   r   r   istrue  r   r   c                 C   r   r&   r   r   r   r   r   isfalse  r   r   c                 C   
   |  |S r&   )rQ   r   br   r   r   rQ        
rQ   c                 C   r   r&   )rS   r   r   r   r   rS     r   rS   c                 C   r   r&   )ro   r   r   r   r   ro     r   ro   c                 C   r   r&   )rq   r   r   r   r   rq     r   rq   c                 C   r   r&   )r   r   r   r   r   r     r*   r   c                 C   s   |  ||S r&   r1   )r   r,   r   r   r   r   r0     s   r0   Nc                 C      | j ||dS Nr_   )rc   r   r   r`   r   r   r   ra        ra   c                 C   r   r   )rk   r   r   r   r   rj     r   rj   c                 C   r   r   )re   r   r   r   r   rd     r   rd   c                 C   r   r   )rn   r   r   r   r   rm     r   rm   Fc                 C      | j |||dS Nr   )r   r   r   cr   r   r   r   r        r   c                 C   r   r   )Z
notbetweenr   r   r   r   notbetween_op  r   r   c                 C   r   r&   )rg   r   r   r   r   rf     r   rf   c                 C   r   r&   )ri   r   r   r   r   rh     r   rh   c                 C      |   S r&   )r   r   r   r   r   r     rG   r   c                 C   r   r&   )r   r   r   r   r   r     rG   r   c                 C   r   r&   )r   r   r   r   r   r     rG   r   c                 C   sx   |r6|durt d |d u rd}t|t jjstd|dvr(|||| }|d|d d|d }| ||dS )	NTz;The autoescape parameter is now a simple boolean True/False/z*String value expected when autoescape=True)%_r   r   r_   )r   warnrC   compatstring_types	TypeErrorreplace)r   r   r`   
autoescaper   r   r   _escaped_like_impl  s   r   c                 C      t | j|||S r&   r   ru   r   r   r`   r   r   r   r   rs     r   rs   c                 C      t | j||| S r&   r   r   r   r   r   notstartswith_op     r   c                 C   r   r&   r   rx   r   r   r   r   rw   !  r   rw   c                 C   r   r&   r   r   r   r   r   notendswith_op&  r   r   c                 C   r   r&   r   r   r   r   r   r   ry   +  r   ry   c                 C   r   r&   r   r   r   r   r   notcontains_op0  r   r   c                 K      | j |fi |S r&   )r{   r   r   rJ   r   r   r   rz   5  r   rz   c                 K   r   r&   )Znotmatchr   r   r   r   notmatch_op:  r   r   c                 C   r   r&   r   r   r   r   r   comma_op?  r   r   c                 C   r   r&   r   r   r   r   r   empty_in_opC  r   r   c                 C   r   r&   r   r   r   r   r   empty_notin_opH  r   r   c                 C   r   r&   r   r   r   r   r   	filter_opM  r   r   c                 C   r   r&   )r]   r   r   r   r   r\   Q  r*   r\   c                 C   r   r&   )r}   r   r   r   r   r|   U  rG   r|   c                 C   r   r&   )r   r   r   r   r   r   Y  rG   r   c                 C   r   r&   )r   r   r   r   r   r   ]  rG   r   c                 C   r   r&   )r   r   r   r   r   r   a  rG   r   c                 C   r   r&   r   r   r   r   r   json_getitem_ope  r   r   c                 C   r   r&   r   r   r   r   r   json_path_getitem_opi  r   r   c                 C      | t v pt| to| jS r&   )r   rC   r+   r.   r1   r   r   r   r.   m  s   r.   c                 C   s   | t v S r&   )r   r1   r   r   r   is_commutativeq  rG   r   c                 C   s   | t tttfv S r&   )r   r|   r   r   r1   r   r   r   is_ordering_modifieru     r   c                 C   r   r&   )_natural_self_precedentrC   r+   r@   r1   r   r   r   is_natural_self_precedenty  s   
r   c                 C   s   t | p| tv S r&   )r.   	_booleansr1   r   r   r   
is_boolean  r   r   c                 C   s   t | | S )z[rotate a comparison operator 180 degrees.

    Note this is not the same as negation.

    )_mirrorgetr1   r   r   r   mirror  r:   r   _asbooli)	canonical	_smallesti_largestd                        c                 C   s<   | |u r
t | r
dS t| t| dtt|t|dtkS )NFr-   )r   _PRECEDENCEr   getattrr   r   )r(   r)   r   r   r   is_precedent  s   r   r&   r   )NF)^r>   r(   r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r    r   Zpy2kr   objectr   r+   rL   r   r   r   r   r   r   r   r   r   r   rQ   rS   ro   rq   r   r0   ra   rj   rd   rm   r   r   rf   rh   r   r   r   r   rs   r   rw   r   ry   r   rz   r   r   r   r   r   r\   r|   r   r   r   r   r   r.   r   r   r   r   r   r   r   union
differenceZ_associativer   symbolr   r   r   r   r   r   r   r   r   <module>   s  
 H8      i










		
 !"#$%&'()*+,-./012349