Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/sql/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/sql/__pycache__/elements.cpython-311.pyc

�

�܋f�s��:�dZddlmZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
dd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZd�Zd�Zd�Zd�d�Zd�d�Zd�d�Zd�Zej Gd�de����Z!Gd�dej"e!��Z#Gd �d!e#��Z$Gd"�d#e!��Z%Gd$�d%ee!��Z&Gd&�d'e#��Z'Gd(�d)e#��Z(Gd*�d+e#��Z)Gd,�d-e!��Z*Gd.�d/e*e#��Z+e+j,Z,e+j-Z-Gd0�d1e*e#��Z.Gd2�d3e#��Z/d�d4�Z0Gd5�d6e#��Z1Gd7�d8e#��Z2Gd9�d:e#��Z3Gd;�d<e#��Z4Gd=�d>e#��Z5Gd?�d@e#��Z6GdA�dBe6��Z7GdC�dDe6��Z8GdE�dFe#��Z9GdG�dHe#��Z:GdI�dJe9��Z;GdK�dLe#��Z<ej=dM��Z>ej=dN��Z?GdO�dPe#��Z@GdQ�dRe#��ZAGdS�dTe#��ZBGdU�dVe#��ZCGdW�dXee#��ZDGdY�dZe#��ZEGd[�d\ee!��ZFGd]�d^eF��ZGGd_�d`eF��ZHGda�dbeF��ZIGdc�ddejJejK��ZLGde�dfeL��ZMGdg�dheM��ZNej=di��ZO	eMZPGdj�dkeM��ZQdl�ZRdm�ZSdn�ZTdo�ZUdp�ZVdq�ZWejXdr��ds���ZYdt�ZZdu�Z[dv�Z\dw�Z]dx�Z^dy�Z_dz�Z`d{�Zad�d|�Zbd}�Zcd~�Zdejeddfd�Zfd��Zgd��Zhd��Zid��Zjd�d��Zkejld�ejm��Znd��Zod��Zpd��Zqd�d��ZrGd��d�e��ZsdS)�z�Core SQL expression elements, including :class:`_expression.ClauseElement`,
:class:`_expression.ColumnElement`, and derived classes.

�)�unicode_literalsN�)�	operators)�type_api��	Annotated)�_generative)�
Executable)�	Immutable)�NO_ARG)�PARSE_AUTOCOMMIT)�cloned_traverse)�traverse)�	Visitable�)�exc)�
inspection)�utilc�*�|���S�N��_clone)�element�kws  �N/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/sql/elements.pyrr$s���>�>����c�:�tj|d|�d|�d���S)Nz.. warning:: The z
 argument to z� can be passed as a Python string argument, which will be treated as **trusted SQL text** and rendered as given.  **DO NOT PASS UNTRUSTED INPUT TO THIS PARAMETER**.)r�add_parameter_text)�	paramname�meth_rst�	param_rsts   r�_document_text_coercionr"(s0���"��	��9�9�h�h�h�	 �
�
�
rc�~�t|��}t|t|��tj|j���S)a�Return the clause ``expression COLLATE collation``.

    e.g.::

        collate(mycolumn, 'utf8_bin')

    produces::

        mycolumn COLLATE utf8_bin

    The collation expression is also quoted if it is a case sensitive
    identifier, e.g. contains uppercase characters.

    .. versionchanged:: 1.2 quoting is automatically applied to COLLATE
       expressions if they are case sensitive.

    ��type_)�_literal_as_binds�BinaryExpression�CollationClauser�collate�type)�
expression�	collation�exprs   rr)r)6s>��&�Z�(�(�D���o�i�(�(�)�*;�4�9����rFc�P�t|��}|�|||���S)axProduce a ``BETWEEN`` predicate clause.

    E.g.::

        from sqlalchemy import between
        stmt = select([users_table]).where(between(users_table.c.id, 5, 7))

    Would produce SQL resembling::

        SELECT id, name FROM user WHERE id BETWEEN :id_1 AND :id_2

    The :func:`.between` function is a standalone version of the
    :meth:`_expression.ColumnElement.between` method available on all
    SQL expressions, as in::

        stmt = select([users_table]).where(users_table.c.id.between(5, 7))

    All arguments passed to :func:`.between`, including the left side
    column expression, are coerced from Python scalar values if a
    the value is not a :class:`_expression.ColumnElement` subclass.
    For example,
    three fixed values can be compared as in::

        print(between(5, 3, 7))

    Which would produce::

        :param_1 BETWEEN :param_2 AND :param_3

    :param expr: a column expression, typically a
     :class:`_expression.ColumnElement`
     instance or alternatively a Python scalar expression to be coerced
     into a column expression, serving as the left side of the ``BETWEEN``
     expression.

    :param lower_bound: a column or Python scalar expression serving as the
     lower bound of the right side of the ``BETWEEN`` expression.

    :param upper_bound: a column or Python scalar expression serving as the
     upper bound of the right side of the ``BETWEEN`` expression.

    :param symmetric: if True, will render " BETWEEN SYMMETRIC ". Note
     that not all databases support this syntax.

     .. versionadded:: 0.9.5

    .. seealso::

        :meth:`_expression.ColumnElement.between`

    )�	symmetric)r&�between)r-�lower_bound�upper_boundr/s    rr0r0Os*��h�T�"�"�D��<�<��[�I�<�F�F�Frc�(�td||d���S)aReturn a literal clause, bound to a bind parameter.

    Literal clauses are created automatically when non-
    :class:`_expression.ClauseElement` objects (such as strings, ints, dates,
    etc.) are
    used in a comparison operation with a :class:`_expression.ColumnElement`
    subclass,
    such as a :class:`~sqlalchemy.schema.Column` object.  Use this function
    to force the generation of a literal clause, which will be created as a
    :class:`BindParameter` with a bound value.

    :param value: the value to be bound. Can be any Python object supported by
        the underlying DB-API, or is translatable via the given type argument.

    :param type\_: an optional :class:`~sqlalchemy.types.TypeEngine` which
        will provide bind-parameter translation for this literal.

    NT�r%�unique��
BindParameter)�valuer%s  r�literalr9�s��&��u�E�$�?�?�?�?rc�*�t|d|dd���S)awCreate an 'OUT' parameter for usage in functions (stored procedures),
    for databases which support them.

    The ``outparam`` can be used like a regular function parameter.
    The "output" value will be available from the
    :class:`~sqlalchemy.engine.ResultProxy` object via its ``out_parameters``
    attribute, which returns a dictionary containing the values.

    NFT)r%r5�
isoutparamr6)�keyr%s  r�outparamr=�s����d�%��$�O�O�O�Orc�D�tjt|����S)z�Return a negation of the given clause, i.e. ``NOT(clause)``.

    The ``~`` operator is also overloaded on all
    :class:`_expression.ColumnElement` subclasses to produce the
    same result.

    )r�invr&��clauses r�not_rB�s���=�*�6�2�2�3�3�3rc��eZdZdZdZiZdZgZdZdZ	dZ
dZdZdZ
dZd�Zed���Zejd���Zd	�Zd
�Zd�Zd"d�Zd
�Zd�Zd�Zd�Zd�Zefd�Zd�Zd#d�Z ej!d��d$d���Z"d�Z#d�Z$ej%dd��d���Z&ej%dd��d���Z'd�Z(d�Z)d �Z*e*Z+d!�Z,dS)%�
ClauseElementzSBase class for elements of a programmatically constructed SQL
    expression.

    rAFNTc�
�|j�|j��}|j���|_tj�|��tj�|��||_	|S)z�Create a shallow copy of this ClauseElement.

        This method may be used by a generative API.  Its also used as
        part of the "deep" copy afforded by a traversal that combines
        the _copy_internals() method.

        )
�	__class__�__new__�__dict__�copyrD�_cloned_set�_reset�
ColumnElement�
comparator�_is_clone_of��self�cs  rrzClauseElement._clone�sl��
�N�"�"�4�>�2�2���]�'�'�)�)��
��!�(�(��+�+�+�� �'�'��*�*�*�����rc��|jS)a.return the 'constructor' for this ClauseElement.

        This is for the purposes for creating a new object of
        this type.   Usually, its just the element's __class__.
        However, the "Annotated" version of the object overrides
        to return the class of its proxied element.

        �rF�rPs r�_constructorzClauseElement._constructor�s���~�rc�p�tj��}|}|�|�|��|j}|�|S)aReturn the set consisting all cloned ancestors of this
        ClauseElement.

        Includes this ClauseElement.  This accessor tends to be used for
        FromClause objects to identify 'equivalent' FROM clauses, regardless
        of transformative operations.

        )r�
column_set�addrN)rP�s�fs   rrJzClauseElement._cloned_set�sA��
�O�������m�
�E�E�!�H�H�H���A��m��rc�d�|j���}|�dd��|S)NrN)rHrI�pop)rP�ds  r�__getstate__zClauseElement.__getstate__s.���M��� � ��	���n�d�#�#�#��rc�"�t||��S)zgReturn a copy of this ClauseElement with annotations
        updated by the given dictionary.

        r�rP�valuess  r�	_annotatezClauseElement._annotate���
��v�&�&�&rc�"�t||��S)zhReturn a copy of this ClauseElement with annotations
        replaced by the given dictionary.

        rr`s  r�_with_annotationszClauseElement._with_annotationsrcrc�2�|r|���S|S)z�Return a copy of this :class:`_expression.ClauseElement`
        with annotations
        removed.

        :param values: optional tuple of individual values
         to remove.

        r)rPra�clones   r�_deannotatezClauseElement._deannotates#���	��;�;�=�=� ��Krc�f�|jr|�|||��Stj|���r)�supports_execution�_execute_clauseelementr�ObjectNotExecutableError)rP�
connection�multiparams�paramss    r�_execute_on_connectionz$ClauseElement._execute_on_connection(s6���"�	5��4�4�T�;��O�O�O��.�t�4�4�4rc�0�|�d||��S)aReturn a copy with :func:`_expression.bindparam` elements
        replaced.

        Same functionality as :meth:`_expression.ClauseElement.params`,
        except adds `unique=True`
        to affected bind parameters so that multiple statements can be
        used.

        T��_params�rP�optionaldict�kwargss   r�
unique_paramszClauseElement.unique_params.s���|�|�D�,��7�7�7rc�0�|�d||��S)a�Return a copy with :func:`_expression.bindparam` elements
        replaced.

        Returns a copy of this ClauseElement with
        :func:`_expression.bindparam`
        elements replaced with values taken from the given dictionary::

          >>> clause = column('x') + bindparam('foo')
          >>> print(clause.compile().params)
          {'foo':None}
          >>> print(clause.params({'foo':7}).compile().params)
          {'foo':7}

        Frrrts   rrozClauseElement.params:s���|�|�E�<��8�8�8rc�����t|��dkr��|d��n't|��dkrtjd�����fd�}t	|id|i��S)Nrrz9params() takes zero or one positional dictionary argumentc�|��|j�vr�|j|_d|_�r|���dSdS�NF)r<r8�required�_convert_to_unique)�bindrvr5s ��r�visit_bindparamz.ClauseElement._params.<locals>.visit_bindparamSsO����x�6�!�!�#�D�H�-��
� %��
��
*��'�'�)�)�)�)�)�
*�
*r�	bindparam)�len�updater�
ArgumentErrorr)rPr5rurvrs ` ` rrszClauseElement._paramsKs������|����!�!��M�M�,�q�/�*�*�*�*�
��
�
��
"�
"��#�K���
�	*�	*�	*�	*�	*�	*��t�R�+��)G�H�H�Hrc�
�||uS)a�Compare this :class:`_expression.ClauseElement` to
        the given :class:`_expression.ClauseElement`.

        Subclasses should override the default behavior, which is a
        straight identity comparison.

        \**kw are arguments consumed by subclass ``compare()`` methods and
        may be used to modify the criteria for comparison
        (see :class:`_expression.ColumnElement`).

        ��rP�otherrs   r�comparezClauseElement.compare\s���u�}�rc��dS)atReassign internal elements to be clones of themselves.

        Called during a copy-and-traverse operation on newly
        shallow-copied elements to create a deep copy.

        The given clone function should be used, which may be applying
        additional transformations to the element (i.e. replacement
        traversal, cloned traversal, annotations).

        Nr��rPrgrs   r�_copy_internalszClauseElement._copy_internalsjs	��	
�rc��gS)a�Return immediate child elements of this
        :class:`_expression.ClauseElement`.

        This is used for visit traversal.

        \**kwargs may contain flags that change the collection that is
        returned, for example to return a subset of items in order to
        cut down on larger traversals, or to return child items from a
        different context (such as schema-level collections instead of
        clause-level).

        r��rPrvs  r�get_childrenzClauseElement.get_childrenws	���	rc��|S)a�Apply a 'grouping' to this :class:`_expression.ClauseElement`.

        This method is overridden by subclasses to return a "grouping"
        construct, i.e. parenthesis.   In particular it's used by "binary"
        expressions to provide a grouping around themselves when placed into a
        larger expression, as well as by :func:`_expression.select`
        constructs when placed into the FROM clause of another
        :func:`_expression.select`.  (Note that subqueries should be
        normally created using the :meth:`_expression.Select.alias` method,
        as many
        platforms require nested SELECT statements to be named).

        As expressions are composed together, the application of
        :meth:`self_group` is automatic - end-user code should never
        need to use this method directly.  Note that SQLAlchemy's
        clause constructs take operator precedence into account -
        so parenthesis might not be needed, for example, in
        an expression like ``x OR (y AND z)`` - AND takes precedence
        over OR.

        The base :meth:`self_group` method of
        :class:`_expression.ClauseElement`
        just returns self.
        r��rP�againsts  r�
self_groupzClauseElement.self_group�s	��2�rzsqlalchemy.engine.defaultc��|s9|r|j}n/|jr|jj}|j}n|���}|j|fd|i|��S)a+	Compile this SQL expression.

        The return value is a :class:`~.Compiled` object.
        Calling ``str()`` or ``unicode()`` on the returned value will yield a
        string representation of the result. The
        :class:`~.Compiled` object also can return a
        dictionary of bind parameter names and values
        using the ``params`` accessor.

        :param bind: An ``Engine`` or ``Connection`` from which a
            ``Compiled`` will be acquired. This argument takes precedence over
            this :class:`_expression.ClauseElement`'s bound engine, if any.

        :param column_keys: Used for INSERT and UPDATE statements, a list of
            column names which should be present in the VALUES clause of the
            compiled statement. If ``None``, all columns from the target table
            object are rendered.

        :param dialect: A ``Dialect`` instance from which a ``Compiled``
            will be acquired. This argument takes precedence over the `bind`
            argument as well as this :class:`_expression.ClauseElement`
            's bound engine,
            if any.

        :param inline: Used for INSERT statements, for a dialect which does
            not support inline retrieval of newly generated primary key
            columns, will force the expression used to create the new primary
            key value to be rendered inline within the INSERT statement's
            VALUES clause. This typically refers to Sequence execution but may
            also refer to any server-side default generation function
            associated with a primary key `Column`.

        :param compile_kwargs: optional dictionary of additional parameters
            that will be passed through to the compiler within all "visit"
            methods.  This allows any custom flag to be passed through to
            a custom compilation construct, for example.  It is also used
            for the case of passing the ``literal_binds`` flag through::

                from sqlalchemy.sql import table, column, select

                t = table('t', column('x'))

                s = select([t]).where(t.c.x == 5)

                print(s.compile(compile_kwargs={"literal_binds": True}))

            .. versionadded:: 0.9.0

        .. seealso::

            :ref:`faq_sql_expression_string`

        r~)�dialectr~�StrCompileDialect�	_compiler)rP�defaultr~r�rs     r�compilezClauseElement.compile�sk��p�	6��
6��,�����
6��)�+���y���!�3�3�5�5���t�~�g�7�7�D�7�B�7�7�7rc� �|j||fi|��S)zNReturn a compiler appropriate for this ClauseElement, given a
        Dialect.)�statement_compiler)rPr�rs   rr�zClauseElement._compiler�s!��*�w�)�'�4�>�>�2�>�>�>rc���tjr!t|�����St	|������dd��S�N�ascii�backslashreplace)r�py3k�strr��unicode�encoderTs r�__str__zClauseElement.__str__�sP���9�	��t�|�|�~�~�&�&�&��4�<�<�>�>�*�*�1�1��+���
r�0.9z�The :meth:`_expression.ClauseElement.__and__` method is deprecated and will be removed in a future release.   Conjunctions should only be used from a :class:`_expression.ColumnElement` subclass, e.g. :meth:`_expression.ColumnElement.__and__`.c�"�t||��S)z!'and' at the ClauseElement level.��and_�rPr�s  r�__and__zClauseElement.__and__�s���D�%� � � rz�The :meth:`_expression.ClauseElement.__or__` method is deprecated and will be removed in a future release.   Conjunctions should only be used from a :class:`_expression.ColumnElement` subclass, e.g. :meth:`_expression.ColumnElement.__or__`.c�"�t||��S)z 'or' at the ClauseElement level.)�or_r�s  r�__or__zClauseElement.__or__�s���4����rc�X�t|d��r|jS|���S)N�negation_clause)�hasattrr��_negaterTs r�
__invert__zClauseElement.__invert__	s,���4�*�+�+�	"��'�'��<�<�>�>�!rc�v�t|�tj���tjd���S)N�r�)�operator�negate)�UnaryExpressionr�rr?rTs rr�zClauseElement._negates4����O�O�I�M�O�2�2��]��
�
�
�	
rc� �td���)N�+Boolean value of this clause is not defined)�	TypeErrorrTs r�__bool__zClauseElement.__bool__s���E�F�F�Frc��|j}|�t�|��Sd|j|jjt
|��|fzS)Nz<%s.%s at 0x%x; %s>)�description�object�__repr__�
__module__rF�__name__�id)rP�friendlys  rr�zClauseElement.__repr__sM���#�����?�?�4�(�(�(�(�����'��4����	,��
rr{r�NN)-r�r��__qualname__�__doc__�__visit_name__�_annotationsrj�
_from_objectsr~rN�
is_selectable�is_clause_elementr��_order_by_label_element�_is_from_containerr�propertyrUr�memoized_propertyrJr^rbrerhrprwrorsr�r�r�r��dependenciesr�r�r��
deprecatedr�r�r�r�r��__nonzero__r�r�rrrDrD�sk��������
�N��L����M��D��L��M����K�"�������,�	�	��X�	�
�������,���
'�'�'�'�'�'�����$5�5�5�
8�
8�
8�9�9�9�"I�I�I�"���%+�
�
�
�
�
�
�
�����6�T��2�3�3�?8�?8�?8�4�3�?8�B?�?�?�����T�_�
�	5���!�!���!��T�_�
�	4��� � ��� �"�"�"�
�
�
�G�G�G��K�
�
�
�
�
rrDc�|��eZdZdZdZdZgZdZdZ	dZ		dZ
	dZ	dZ	dZ
	dZdZdd�Z�fd�Zejd	���Zejd
���Zd�Zd�Zd
�Zdd�Zed���Zed���Zejd���Zejd���Zd�Zd�Z d�Z!	dd�Z"dd�Z#d�Z$d�Z%ejd���Z&�xZ'S)rLa+Represent a column-oriented SQL expression suitable for usage in the
    "columns" clause, WHERE clause etc. of a statement.

    While the most familiar kind of :class:`_expression.ColumnElement` is the
    :class:`_schema.Column` object, :class:`_expression.ColumnElement`
    serves as the basis
    for any unit that may be present in a SQL expression, including
    the expressions themselves, SQL functions, bound parameters,
    literal expressions, keywords such as ``NULL``, etc.
    :class:`_expression.ColumnElement`
    is the ultimate base class for all such elements.

    A wide variety of SQLAlchemy Core functions work at the SQL expression
    level, and are intended to accept instances of
    :class:`_expression.ColumnElement` as
    arguments.  These functions will typically document that they accept a
    "SQL expression" as an argument.  What this means in terms of SQLAlchemy
    usually refers to an input which is either already in the form of a
    :class:`_expression.ColumnElement` object,
    or a value which can be **coerced** into
    one.  The coercion rules followed by most, but not all, SQLAlchemy Core
    functions with regards to SQL expressions are as follows:

        * a literal Python value, such as a string, integer or floating
          point value, boolean, datetime, ``Decimal`` object, or virtually
          any other Python object, will be coerced into a "literal bound
          value".  This generally means that a :func:`.bindparam` will be
          produced featuring the given value embedded into the construct; the
          resulting :class:`.BindParameter` object is an instance of
          :class:`_expression.ColumnElement`.
          The Python value will ultimately be sent
          to the DBAPI at execution time as a parameterized argument to the
          ``execute()`` or ``executemany()`` methods, after SQLAlchemy
          type-specific converters (e.g. those provided by any associated
          :class:`.TypeEngine` objects) are applied to the value.

        * any special object value, typically ORM-level constructs, which
          feature a method called ``__clause_element__()``.  The Core
          expression system looks for this method when an object of otherwise
          unknown type is passed to a function that is looking to coerce the
          argument into a :class:`_expression.ColumnElement` expression.  The
          ``__clause_element__()`` method, if present, should return a
          :class:`_expression.ColumnElement` instance.  The primary use of
          ``__clause_element__()`` within SQLAlchemy is that of class-bound
          attributes on ORM-mapped classes; a ``User`` class which contains a
          mapped attribute named ``.name`` will have a method
          ``User.name.__clause_element__()`` which when invoked returns the
          :class:`_schema.Column`
          called ``name`` associated with the mapped table.

        * The Python ``None`` value is typically interpreted as ``NULL``,
          which in SQLAlchemy Core produces an instance of :func:`.null`.

    A :class:`_expression.ColumnElement` provides the ability to generate new
    :class:`_expression.ColumnElement`
    objects using Python expressions.  This means that Python operators
    such as ``==``, ``!=`` and ``<`` are overloaded to mimic SQL operations,
    and allow the instantiation of further :class:`_expression.ColumnElement`
    instances
    which are composed from other, more fundamental
    :class:`_expression.ColumnElement`
    objects.  For example, two :class:`.ColumnClause` objects can be added
    together with the addition operator ``+`` to produce
    a :class:`.BinaryExpression`.
    Both :class:`.ColumnClause` and :class:`.BinaryExpression` are subclasses
    of :class:`_expression.ColumnElement`::

        >>> from sqlalchemy.sql import column
        >>> column('a') + column('b')
        <sqlalchemy.sql.expression.BinaryExpression object at 0x101029dd0>
        >>> print(column('a') + column('b'))
        a + b

    .. seealso::

        :class:`_schema.Column`

        :func:`_expression.column`

    �column_elementFr�NTc�&�|tjtjtjfvrB|jjtjjur%t|tj	tj
��S|tjtjfvrt|��S|Sr)rr�r��_asboolr*�_type_affinityr�BOOLEANTYPE�	AsBoolean�istrue�isfalse�any_op�all_op�Groupingr�s  rr�zColumnElement.self_group�sp���	��	�
�y�7H�I�I�I��	�(�H�,@�,O�O�O��T�9�#3�Y�5F�G�G�G�
��)�9�+;�<�
<�
<��D�>�>�!��Krc����|jjtjjur%t	|t
jt
j��Stt|���
��Sr)r*r�rr�r�rr�r��superrLr��rPrFs �rr�zColumnElement._negate�sM����9�#�x�';�'J�J�J��T�9�#4�i�6F�G�G�G����-�-�5�5�7�7�7rc��tjSr�r�NULLTYPErTs rr*zColumnElement.type����� � rc��	|jj}||��S#t$r6}tjtd|jz��|���Yd}~dSd}~wwxYw)NzOObject %r associated with '.type' attribute is not a TypeEngine class or object��replace_context)r*�comparator_factory�AttributeErrorr�raise_r�)rPr��errs   rrMzColumnElement.comparator�s���	,�!%��!=��&�%�d�+�+�+���	�	�	��K��:�<@�I�F���!$�
�
�
�
�
�
�
�
�
�
�����	���s��
A�+A�Ac��	t|j|��S#t$r`}tjtdt|��j�dt|j��j�d|����|���Yd}~dSd}~wwxYw)NzNeither z object nor z object has an attribute r�)�getattrrMr�rr�r*r�)rPr<r�s   r�__getattr__zColumnElement.__getattr__�s���
	��4�?�C�0�0�0���	�	�	��K����T�
�
�+�+�+��T�_�-�-�6�6�6���	���!$�

�

�

�

�

�

�

�

�

�

�����	���s��
B�AA<�<Bc�$�||jg|�Ri|��Sr�rM�rP�opr�rvs    r�operatezColumnElement.operate�s$���r�$�/�4�E�4�4�4�V�4�4�4rc� �|||jfi|��Srr�r�s    r�reverse_operatezColumnElement.reverse_operate�s���r�%���3�3�F�3�3�3rc�6�td||||jd���S)NT)�_compared_to_operatorr%�_compared_to_typer5)r7r*�rPr��objr%s    r�_bind_paramzColumnElement._bind_param�s-�����"*��"�i��

�
�
�	
rc��|S)z^Return a column expression.

        Part of the inspection interface; returns self.

        r�rTs rr+zColumnElement.expression	s	���rc��|fSrr�rTs r�_select_iterablezColumnElement._select_iterable�	���w�rc�H�tjd�|jD����S)Nc3�(K�|]
}|j�	|V��dSr)�_proxies��.0rQs  r�	<genexpr>z-ColumnElement.base_columns.<locals>.<genexpr>s)����K�K�Q��
�K�q�K�K�K�K�K�Kr)rrW�	proxy_setrTs r�base_columnszColumnElement.base_columnss#����K�K�$�.�K�K�K�K�K�Krc�x�tj|g��}|jD]}|�|j���|Sr)rrWrr�r�rPrYrQs   rrzColumnElement.proxy_sets@���O�T�F�#�#����	"�	"�A�
�H�H�Q�[�!�!�!�!��rc��tj|g��}|jD])}|�|������*|S)z�An 'uncached' version of proxy set.

        This is so that we can read annotations from the list of columns
        without breaking the caching of the above proxy_set.

        )rrWrr��_uncached_proxy_setr	s   rrz!ColumnElement._uncached_proxy_set!sL��
�O�T�F�#�#����	.�	.�A�
�H�H�Q�*�*�,�,�-�-�-�-��rc�Z�t|j�|j����S)z�Return True if the given :class:`_expression.ColumnElement`
        has a common ancestor to this :class:`_expression.ColumnElement`.)�boolr�intersection)rP�othercolumns  r�shares_lineagezColumnElement.shares_lineage-s%���D�N�/�/��0E�F�F�G�G�Grc�b�t|d��ot|d��o|j|jkS)zhReturn True if the given column element compares to this one
        when targeting within a result row.�name)r�rr�s  r�_compare_name_for_resultz&ColumnElement._compare_name_for_result3s9��

�E�6�"�"�
(���f�%�%�
(��
�d�i�'�	
rc�r�|�C|j}|jr|j}n/	t|��}n#tj$r
|j}YnwxYw|}t|rt
|��n|t|dd��|���}|g|_|j	�$|j	j
�|��|_	||j|<|S)z�Create a new :class:`_expression.ColumnElement` representing this
        :class:`_expression.ColumnElement`
        as it appears in the select list of a
        descending selectable.

        Nr*)r%�_selectable)
�
anon_labelr<r�r�UnsupportedCompilationError�ColumnClause�
_as_truncatedr�rrN�columns�get�_columns)rP�
selectabler�name_is_truncatablerr<�cos       r�_make_proxyzColumnElement._make_proxy=s����<��?�D��x�
*��h���*��d�)�)�C�C���6�*�*�*��/�C�C�C�*�����C�
�#6�@�M�$����D��$���-�-�"�
�
�
��
�f����"�.�(�5�=�A�A�#�F�F�B�O�#%�
��C� ��	s�*�A�Ac���|f}|r||vr||�|��}|D]?}|r|�|��rdSt|��t|��krdS�@dS)a�Compare this ColumnElement to another.

        Special arguments understood:

        :param use_proxies: when True, consider two columns that
          share a common base column as equivalent (i.e. shares_lineage())

        :param equivalents: a dictionary of columns as keys mapped to sets
          of columns. If the given "other" column is present in this
          dictionary, if any of the columns in the corresponding set() pass
          the comparison test, the result is True. This is used to expand the
          comparison to other columns that may be known to be equivalent to
          this one via foreign key or other criterion.

        TF)�unionr�hash)rPr��use_proxies�equivalentsr�
to_compare�oths       rr�zColumnElement.compare^s��� �X�
��	>�5�K�/�/�$�U�+�1�1�*�=�=�J��	�	�C��
�t�2�2�3�7�7�
��t�t��c���d�4�j�j�(�(��t�t�)��5rc�"�t||��S)a<Produce a type cast, i.e. ``CAST(<expression> AS <type>)``.

        This is a shortcut to the :func:`_expression.cast` function.

        .. seealso::

            :ref:`coretutorial_casts`

            :func:`_expression.cast`

            :func:`_expression.type_coerce`

        .. versionadded:: 1.0.7

        )�Cast�rPr%s  r�castzColumnElement.castzs�� �D�%� � � rc�.�t|||j��S)z�Produce a column label, i.e. ``<columnname> AS <name>``.

        This is a shortcut to the :func:`_expression.label` function.

        If 'name' is ``None``, an anonymous label name will be generated.

        )�Labelr*)rPrs  r�labelzColumnElement.label�s���T�4���+�+�+rc	��|j�|j}|j�tdt|��t|dd��fz��S)aProvides a constant 'anonymous label' for this ColumnElement.

        This is a label() expression which will be named at compile time.
        The same label() is returned each time ``anon_label`` is called so
        that expressions can reference ``anon_label`` multiple times,
        producing the same label name at compile time.

        The compiler uses this function automatically at compile time
        for expressions that are known to be 'unnamed' like binary
        expressions and function calls.

        N�
%%(%d %s)sr�anon)rN�_anonymous_labelr�r�rTs rrzColumnElement.anon_label�sS����+��$�D���+� ��B�t�H�H�g�d�F�F�&C�&C�D�D�
�
�	
rrr{)FN)(r�r�r�r�r��primary_key�foreign_keysr�_labelr<�
_key_label�_render_label_in_columns_clause�_resolve_label�_allow_label_resolve�_is_implicitly_boolean�
_alt_namesr�r�rr�r*rMr�r�r�r�r�r+r�rrrrrr r�r+r.r�
__classcell__rSs@rrLrL(sU�������O�O�b&�N��K��L��H�
�F���C���J��'+�#���N�
� ���#���J�	�	�	�	�8�8�8�8�8�
��!�!���!�
��,�,���,���� 5�5�5�4�4�4�
�
�
�
�����X������X��
��L�L���L�
�������
�
�
�H�H�H�
�
�
�:?�����B����8!�!�!�$,�,�,�
��
�
���
�
�
�
�
rrLc
��eZdZdZdZdZdZeddeddddddf
d�Zd�Z	d�Z
ed	���Zd
�Z
d�Zd�Zd
�Zd�Zd�ZdS)r7a�Represent a "bound expression".

    :class:`.BindParameter` is invoked explicitly using the
    :func:`.bindparam` function, as in::

        from sqlalchemy import bindparam

        stmt = select([users_table]).\
                    where(users_table.c.name == bindparam('username'))

    Detailed discussion of how :class:`.BindParameter` is used is
    at :func:`.bindparam`.

    .. seealso::

        :func:`.bindparam`

    r�Fr�Nc	��t|t��r|j}|j}|tur
|tuo|du}|turd}|�t||��}|rRt
dt|��|�)tj	dd|���
d��ndfz��|_n&|pt
dt|��z��|_|j|_|pd|_||_
||_||_|	|_||_||_|�:|�|�|
|��|_dSt)j|��|_dSt|t��r|��|_dS||_dS)az$Produce a "bound expression".

        The return value is an instance of :class:`.BindParameter`; this
        is a :class:`_expression.ColumnElement`
        subclass which represents a so-called
        "placeholder" value in a SQL expression, the value of which is
        supplied at the point at which the statement in executed against a
        database connection.

        In SQLAlchemy, the :func:`.bindparam` construct has
        the ability to carry along the actual value that will be ultimately
        used at expression time.  In this way, it serves not just as
        a "placeholder" for eventual population, but also as a means of
        representing so-called "unsafe" values which should not be rendered
        directly in a SQL statement, but rather should be passed along
        to the :term:`DBAPI` as values which need to be correctly escaped
        and potentially handled for type-safety.

        When using :func:`.bindparam` explicitly, the use case is typically
        one of traditional deferment of parameters; the :func:`.bindparam`
        construct accepts a name which can then be referred to at execution
        time::

            from sqlalchemy import bindparam

            stmt = select([users_table]).\
                        where(users_table.c.name == bindparam('username'))

        The above statement, when rendered, will produce SQL similar to::

            SELECT id, name FROM user WHERE name = :username

        In order to populate the value of ``:username`` above, the value
        would typically be applied at execution time to a method
        like :meth:`_engine.Connection.execute`::

            result = connection.execute(stmt, username='wendy')

        Explicit use of :func:`.bindparam` is also common when producing
        UPDATE or DELETE statements that are to be invoked multiple times,
        where the WHERE criterion of the statement is to change on each
        invocation, such as::

            stmt = (users_table.update().
                    where(user_table.c.name == bindparam('username')).
                    values(fullname=bindparam('fullname'))
                    )

            connection.execute(
                stmt, [{"username": "wendy", "fullname": "Wendy Smith"},
                       {"username": "jack", "fullname": "Jack Jones"},
                       ]
            )

        SQLAlchemy's Core expression system makes wide use of
        :func:`.bindparam` in an implicit sense.   It is typical that Python
        literal values passed to virtually all SQL expression functions are
        coerced into fixed :func:`.bindparam` constructs.  For example, given
        a comparison operation such as::

            expr = users_table.c.name == 'Wendy'

        The above expression will produce a :class:`.BinaryExpression`
        construct, where the left side is the :class:`_schema.Column` object
        representing the ``name`` column, and the right side is a
        :class:`.BindParameter` representing the literal value::

            print(repr(expr.right))
            BindParameter('%(4327771088 name)s', 'Wendy', type_=String())

        The expression above will render SQL such as::

            user.name = :name_1

        Where the ``:name_1`` parameter name is an anonymous name.  The
        actual string ``Wendy`` is not in the rendered string, but is carried
        along where it is later used within statement execution.  If we
        invoke a statement like the following::

            stmt = select([users_table]).where(users_table.c.name == 'Wendy')
            result = connection.execute(stmt)

        We would see SQL logging output as::

            SELECT "user".id, "user".name
            FROM "user"
            WHERE "user".name = %(name_1)s
            {'name_1': 'Wendy'}

        Above, we see that ``Wendy`` is passed as a parameter to the database,
        while the placeholder ``:name_1`` is rendered in the appropriate form
        for the target database, in this case the PostgreSQL database.

        Similarly, :func:`.bindparam` is invoked automatically when working
        with :term:`CRUD` statements as far as the "VALUES" portion is
        concerned.   The :func:`_expression.insert` construct produces an
        ``INSERT`` expression which will, at statement execution time, generate
        bound placeholders based on the arguments passed, as in::

            stmt = users_table.insert()
            result = connection.execute(stmt, name='Wendy')

        The above will produce SQL output as::

            INSERT INTO "user" (name) VALUES (%(name)s)
            {'name': 'Wendy'}

        The :class:`_expression.Insert` construct, at
        compilation/execution time, rendered a single :func:`.bindparam`
        mirroring the column name ``name`` as a result of the single ``name``
        parameter we passed to the :meth:`_engine.Connection.execute` method.

        :param key:
          the key (e.g. the name) for this bind param.
          Will be used in the generated
          SQL statement for dialects that use named parameters.  This
          value may be modified when part of a compilation operation,
          if other :class:`BindParameter` objects exist with the same
          key, or if its length is too long and truncation is
          required.

        :param value:
          Initial value for this bind param.  Will be used at statement
          execution time as the value for this parameter passed to the
          DBAPI, if no other value is indicated to the statement execution
          method for this particular parameter name.  Defaults to ``None``.

        :param callable\_:
          A callable function that takes the place of "value".  The function
          will be called at statement execution time to determine the
          ultimate value.   Used for scenarios where the actual bind
          value cannot be determined at the point at which the clause
          construct is created, but embedded bind values are still desirable.

        :param type\_:
          A :class:`.TypeEngine` class or instance representing an optional
          datatype for this :func:`.bindparam`.  If not passed, a type
          may be determined automatically for the bind, based on the given
          value; for example, trivial Python types such as ``str``,
          ``int``, ``bool``
          may result in the :class:`.String`, :class:`.Integer` or
          :class:`.Boolean` types being automatically selected.

          The type of a :func:`.bindparam` is significant especially in that
          the type will apply pre-processing to the value before it is
          passed to the database.  For example, a :func:`.bindparam` which
          refers to a datetime value, and is specified as holding the
          :class:`.DateTime` type, may apply conversion needed to the
          value (such as stringification on SQLite) before passing the value
          to the database.

        :param unique:
          if True, the key name of this :class:`.BindParameter` will be
          modified if another :class:`.BindParameter` of the same name
          already has been located within the containing
          expression.  This flag is used generally by the internals
          when producing so-called "anonymous" bound expressions, it
          isn't generally applicable to explicitly-named :func:`.bindparam`
          constructs.

        :param required:
          If ``True``, a value is required at execution time.  If not passed,
          it defaults to ``True`` if neither :paramref:`.bindparam.value`
          or :paramref:`.bindparam.callable` were passed.  If either of these
          parameters are present, then :paramref:`.bindparam.required`
          defaults to ``False``.

        :param quote:
          True if this parameter name requires quoting and is not
          currently known as a SQLAlchemy reserved word; this currently
          only applies to the Oracle backend, where bound names must
          sometimes be quoted.

        :param isoutparam:
          if True, the parameter should be treated like a stored procedure
          "OUT" parameter.  This applies to backends such as Oracle which
          support OUT parameters.

        :param expanding:
          if True, this parameter will be treated as an "expanding" parameter
          at execution time; the parameter value is expected to be a sequence,
          rather than a scalar value, and the string SQL statement will
          be transformed on a per-execution basis to accommodate the sequence
          with a variable number of parameter slots passed to the DBAPI.
          This is to allow statement caching to be used in conjunction with
          an IN clause.

          .. seealso::

            :meth:`.ColumnOperators.in_`

            :ref:`baked_in` - with baked queries

          .. note:: The "expanding" feature does not support "executemany"-
             style parameter sets.

          .. versionadded:: 1.2

          .. versionchanged:: 1.3 the "expanding" bound parameter feature now
             supports empty lists.


        .. seealso::

            :ref:`coretutorial_bind_param`

            :ref:`coretutorial_insert_expressions`

            :func:`.outparam`

        Nr0z[%\(\) \$]+�_�paramz
%%(%d param)s)�
isinstancerr*r<r�quoted_namer2r��re�sub�strip�_identifying_key�	_orig_keyr5r8�callabler;r|�	expanding�coerce_compared_valuer�_resolve_value_to_type)rPr<r8r%r5r|�quote�	callable_rIr;r�r�s            r�__init__zBindParameter.__init__�s���D�c�<�(�(�	��H�E��'�C��v������<�9��+<�H��F�?�?��E����c�5�)�)�C��	K�'���t�H�H����F�>�3��4�4�:�:�3�?�?�?� �	����D�H�H��J�.���D���/I�J�J�D�H�
!%��������������
�!��
�$��� ��
�"����=� �,�-�C�C�)�5����	�	�	�%�;�E�B�B��	�	�	�
��t�
$�
$�	�����D�I�I�I��D�I�I�Irc�<�|���}||_|S)zrReturn a copy of this :class:`.BindParameter` in
        the context of an expanding IN against a tuple.

        )r�_expanding_in_types)rP�types�cloneds   r�_with_expanding_in_typesz&BindParameter._with_expanding_in_types�s��
������%*��"��
rc��|���}||_d|_d|_|jt
jurtj|��|_|S)zYReturn a copy of this :class:`.BindParameter` with the given value
        set.

        NF)rr8rHr|r*rr�rK)rPr8rRs   r�_with_valuezBindParameter._with_value�sM��
����������������;�(�+�+�+�"�9�%�@�@�F�K��
rc�F�|jr|���S|jS)z�Return the value of this bound parameter,
        taking into account if the ``callable`` parameter
        was set.

        The ``callable`` value will be evaluated
        and returned if present, else ``value``.

        )rHr8rTs r�effective_valuezBindParameter.effective_value�s$���=�	��=�=�?�?�"��:�rc��t�|��}|jr-tdt	|��|jpdfz��|_|S)Nr0r@)rDrr5r2r�rGr<rOs  rrzBindParameter._clonesQ��� � ��&�&���;�	�$���1���q�{�'=�g�>�>���A�E��rc��|js6d|_tdt|��|jpdfz��|_dSdS)NTr0r@)r5r2r�rGr<rTs rr}z BindParameter._convert_to_uniquesL���{�	��D�K�'���4���$�.�*C�G�D�D���D�H�H�H�	�	rc��t|t��o>|j�|j��o|j|jko|j|jkS)zJCompare this :class:`BindParameter` to the given
        clause.

        )rAr7r*�_compare_type_affinityr8rHr�s   rr�zBindParameter.comparesT��
�u�m�,�,�
0��	�0�0���<�<�
0��
�e�k�)�
0��
���/�		
rc��|j���}|j}|jr|���}d|d<||d<|S)z4Execute a deferred value for serialization purposes.NrHr8)rHrIr8rH)rPr]�vs   rr^zBindParameter.__getstate__sL��
�M��� � ���J���=�	!��
�
���A� �A�j�M���'�
��rc���|�dd��r8tdt|��|�dd��fz��|d<|j�|��dS)Nr5Fr0rGr@r<)rr2r�rHr��rP�states  r�__setstate__zBindParameter.__setstate__'sj���9�9�X�u�%�%�	�+���4���%�)�)�K��*I�*I�J�J���E�%�L�	
�
���U�#�#�#�#�#rc�8�d|j�d|j�d|j�d�S)NzBindParameter(z, z, type_=�))r<r8r*rTs rr�zBindParameter.__repr__.s)����H�H�H��J�J�J��I�I�I�
�	
r)r�r�r�r�r��_is_crudrPrrNrSrUr�rWrr}r�r^rar�r�rrr7r7�s���������&!�N��H���
��������"��T�T�T�T�l����������X��������
�
�
�	�	�	�$�$�$�
�
�
�
�
rr7c��eZdZdZdZd�ZdS)�
TypeClausezTHandle a type keyword in a SQL statement.

    Used by the ``Case`` statement.

    �
typeclausec��||_dSr�r*r*s  rrNzTypeClause.__init__?s
����	�	�	rN)r�r�r�r�r�rNr�rrrfrf6s4��������"�N�����rrfc���eZdZdZdZejdej��Ze	j
�dei��Z
dZ
d�Zed���Zed���ZgZd	xZxZZdZdd
�Zeejddd
���eddd��	dd�������Zed���Zejd��d���Z ed���Z!ed���Z"dd�Z#e$fd�Z%d�Z&d�Z'd	S)�
TextClausea�Represent a literal SQL text fragment.

    E.g.::

        from sqlalchemy import text

        t = text("SELECT * FROM users")
        result = connection.execute(t)


    The :class:`_expression.TextClause` construct is produced using the
    :func:`_expression.text`
    function; see that function for full documentation.

    .. seealso::

        :func:`_expression.text`

    �
textclausez(?<![:\w\x5c]):(\w+)(?!:)�
autocommitFc�"�t||��Srr�r�s  rr�zTextClause.__and__`s���D�%� � � rc��|fSrr�rTs rr�zTextClause._select_iterabledr�rc��|Srr�rTs rrzTextClause.selectablehs	���rNc�n��|�_i�_�fd�}�j�||���_dS)Nc���t|�d�����j|�d��<d|�d��zS)Nrz:%s)r7�group�_bindparams)�mrPs �r�replz!TextClause.__init__.<locals>.replzsA���+8�������+D�+D�D��Q�W�W�Q�Z�Z�(��1�7�7�1�:�:�%�%r)�_bindrt�_bind_params_regexrD�text)rPryr~rvs`   rrNzTextClause.__init__vsK�����
����	&�	&�	&�	&�	&��+�/�/��d�;�;��	�	�	r)z0.6aThe :paramref:`_expression.text.autocommit` parameter is deprecated and will be removed in a future release.  Please use the :paramref:`.Connection.execution_options.autocommit` parameter in conjunction with the :meth:`.Executable.execution_options` method.)r�z�The :paramref:`_expression.text.bindparams` parameter is deprecated and will be removed in a future release.  Please refer to the :meth:`_expression.TextClause.bindparams` method.)r�z�The :paramref:`_expression.text.typemap` parameter is deprecated and will be removed in a future release.  Please refer to the :meth:`_expression.TextClause.columns` method.)rm�
bindparams�typemapryz
:func:`.text`z:paramref:`.text.text`c��t||���}|r
|j|�}|r
|jdi|��}|�|�|���}|S)a�Construct a new :class:`_expression.TextClause` clause,
        representing
        a textual SQL string directly.

        E.g.::

            from sqlalchemy import text

            t = text("SELECT * FROM users")
            result = connection.execute(t)

        The advantages :func:`_expression.text`
        provides over a plain string are
        backend-neutral support for bind parameters, per-statement
        execution options, as well as
        bind parameter and result-column typing behavior, allowing
        SQLAlchemy type constructs to play a role when executing
        a statement that is specified literally.  The construct can also
        be provided with a ``.c`` collection of column elements, allowing
        it to be embedded in other SQL expression constructs as a subquery.

        Bind parameters are specified by name, using the format ``:name``.
        E.g.::

            t = text("SELECT * FROM users WHERE id=:user_id")
            result = connection.execute(t, user_id=12)

        For SQL statements where a colon is required verbatim, as within
        an inline string, use a backslash to escape::

            t = text("SELECT * FROM users WHERE name='\:username'")

        The :class:`_expression.TextClause`
        construct includes methods which can
        provide information about the bound parameters as well as the column
        values which would be returned from the textual statement, assuming
        it's an executable SELECT type of statement.  The
        :meth:`_expression.TextClause.bindparams`
        method is used to provide bound
        parameter detail, and :meth:`_expression.TextClause.columns`
        method allows
        specification of return columns including names and types::

            t = text("SELECT * FROM users WHERE id=:user_id").\
                    bindparams(user_id=7).\
                    columns(id=Integer, name=String)

            for id, name in connection.execute(t):
                print(id, name)

        The :func:`_expression.text` construct is used in cases when
        a literal string SQL fragment is specified as part of a larger query,
        such as for the WHERE clause of a SELECT statement::

            s = select([users.c.id, users.c.name]).where(text("id=:user_id"))
            result = connection.execute(s, user_id=12)

        :func:`_expression.text` is also used for the construction
        of a full, standalone statement using plain text.
        As such, SQLAlchemy refers
        to it as an :class:`.Executable` object, and it supports
        the :meth:`Executable.execution_options` method.  For example,
        a :func:`_expression.text`
        construct that should be subject to "autocommit"
        can be set explicitly so using the
        :paramref:`.Connection.execution_options.autocommit` option::

            t = text("EXEC my_procedural_thing()").\
                    execution_options(autocommit=True)

        Note that SQLAlchemy's usual "autocommit" behavior applies to
        :func:`_expression.text` constructs implicitly - that is,
        statements which begin
        with a phrase such as ``INSERT``, ``UPDATE``, ``DELETE``,
        or a variety of other phrases specific to certain backends, will
        be eligible for autocommit if no transaction is in progress.

        :param text:
          the text of the SQL statement to be created.  Use ``:<param>``
          to specify bind parameters; they will be compiled to their
          engine-specific format.

        :param autocommit: whether or not to set the "autocommit" execution
          option for this :class:`_expression.TextClause` object.

        :param bind:
          an optional connection or engine to be used for this text query.

        :param bindparams:
          A list of :func:`.bindparam` instances used to
          provide information about parameters embedded in the statement.

          E.g.::

              stmt = text("SELECT * FROM table WHERE id=:id",
                        bindparams=[bindparam('id', value=5, type_=Integer)])

        :param typemap:
          A dictionary mapping the names of columns represented in the columns
          clause of a ``SELECT`` statement to type objects.

          E.g.::

              stmt = text("SELECT * FROM table",
                            typemap={'id': Integer, 'name': String},
                        )

        .. seealso::

            :ref:`sqlexpression_text` - in the Core tutorial

            :ref:`orm_tutorial_literal_sql` - in the ORM tutorial

        )r~N)rmr�)rkrzr�execution_options)rPryr~rzr{rm�stmts       r�_create_textzTextClause._create_text�sm��\�$�T�*�*�*���	0�"�4�?�J�/�D��	+��4�<�*�*�'�*�*�D��!��)�)�Z�)�@�@�D��rc��|j���x|_}|D]a}	||j}|||j<�#t$r:}t	jt
jd|jz��|���Yd}~�Zd}~wwxYw|���D]h\}}	||}|�	|��||<�'#t$r5}t	jt
jd|z��|���Yd}~�ad}~wwxYwdS)a�Establish the values and/or types of bound parameters within
        this :class:`_expression.TextClause` construct.

        Given a text construct such as::

            from sqlalchemy import text
            stmt = text("SELECT id, name FROM user WHERE name=:name "
                        "AND timestamp=:timestamp")

        the :meth:`_expression.TextClause.bindparams`
        method can be used to establish
        the initial value of ``:name`` and ``:timestamp``,
        using simple keyword arguments::

            stmt = stmt.bindparams(name='jack',
                        timestamp=datetime.datetime(2012, 10, 8, 15, 12, 5))

        Where above, new :class:`.BindParameter` objects
        will be generated with the names ``name`` and ``timestamp``, and
        values of ``jack`` and ``datetime.datetime(2012, 10, 8, 15, 12, 5)``,
        respectively.  The types will be
        inferred from the values given, in this case :class:`.String` and
        :class:`.DateTime`.

        When specific typing behavior is needed, the positional ``*binds``
        argument can be used in which to specify :func:`.bindparam` constructs
        directly.  These constructs must include at least the ``key``
        argument, then an optional value and type::

            from sqlalchemy import bindparam
            stmt = stmt.bindparams(
                            bindparam('name', value='jack', type_=String),
                            bindparam('timestamp', type_=DateTime)
                        )

        Above, we specified the type of :class:`.DateTime` for the
        ``timestamp`` bind, and the type of :class:`.String` for the ``name``
        bind.  In the case of ``name`` we also set the default value of
        ``"jack"``.

        Additional bound parameters can be supplied at statement execution
        time, e.g.::

            result = connection.execute(stmt,
                        timestamp=datetime.datetime(2012, 10, 8, 15, 12, 5))

        The :meth:`_expression.TextClause.bindparams`
        method can be called repeatedly,
        where it will re-use existing :class:`.BindParameter` objects to add
        new information.  For example, we can call
        :meth:`_expression.TextClause.bindparams`
        first with typing information, and a
        second time with value information, and it will be combined::

            stmt = text("SELECT id, name FROM user WHERE name=:name "
                        "AND timestamp=:timestamp")
            stmt = stmt.bindparams(
                bindparam('name', type_=String),
                bindparam('timestamp', type_=DateTime)
            )
            stmt = stmt.bindparams(
                name='jack',
                timestamp=datetime.datetime(2012, 10, 8, 15, 12, 5)
            )

        The :meth:`_expression.TextClause.bindparams`
        method also supports the concept of
        **unique** bound parameters.  These are parameters that are
        "uniquified" on name at statement compilation time, so that  multiple
        :func:`_expression.text`
        constructs may be combined together without the names
        conflicting.  To use this feature, specify the
        :paramref:`.BindParameter.unique` flag on each :func:`.bindparam`
        object::

            stmt1 = text("select id from table where name=:name").bindparams(
                bindparam("name", value='name1', unique=True)
            )
            stmt2 = text("select id from table where name=:name").bindparams(
                bindparam("name", value='name2', unique=True)
            )

            union = union_all(
                stmt1.columns(column("id")),
                stmt2.columns(column("id"))
            )

        The above statement will render as::

            select id from table where name=:name_1
            UNION ALL select id from table where name=:name_2

        .. versionadded:: 1.3.11  Added support for the
           :paramref:`.BindParameter.unique` flag to work with
           :func:`_expression.text`
           constructs.

        z?This text() construct doesn't define a bound parameter named %rr�N)
rtrIrG�KeyErrorrr�rr��itemsrU)	rP�binds�names_to_values�
new_paramsr~�existingr�r<r8s	         rrzzTextClause.bindparamss���H)-�(8�(=�(=�(?�(?�?���:��	6�	6�D�
6�&�d�n�5��26�
�8�-�.�.���
�
�
����%�3�59�^�D���%(��������������
����*�/�/�1�1�	>�	>�J�C��
>�%�c�?��#+�"6�"6�u�"=�"=�
�3�����
�
�
����%�3�58�9���%(��������������
����	>�	>s-�
>�
B�0A=�=B�C�
C?�
+C:�:C?zsqlalchemy.sql.selectablec����fd�|D��}d�����D��}|�|||zt|��o|���S)a�Turn this :class:`_expression.TextClause` object into a
        :class:`.TextAsFrom`
        object that can be embedded into another statement.

        This function essentially bridges the gap between an entirely
        textual SELECT statement and the SQL expression language concept
        of a "selectable"::

            from sqlalchemy.sql import column, text

            stmt = text("SELECT id, name FROM some_table")
            stmt = stmt.columns(column('id'), column('name')).alias('st')

            stmt = select([mytable]).\
                    select_from(
                        mytable.join(stmt, mytable.c.name == stmt.c.name)
                    ).where(stmt.c.id > 5)

        Above, we pass a series of :func:`_expression.column` elements to the
        :meth:`_expression.TextClause.columns` method positionally.  These
        :func:`_expression.column`
        elements now become first class elements upon the :attr:`.TextAsFrom.c`
        column collection, just like any other selectable.

        The column expressions we pass to
        :meth:`_expression.TextClause.columns` may
        also be typed; when we do so, these :class:`.TypeEngine` objects become
        the effective return type of the column, so that SQLAlchemy's
        result-set-processing systems may be used on the return values.
        This is often needed for types such as date or boolean types, as well
        as for unicode processing on some dialect configurations::

            stmt = text("SELECT id, name, timestamp FROM some_table")
            stmt = stmt.columns(
                        column('id', Integer),
                        column('name', Unicode),
                        column('timestamp', DateTime)
                    )

            for id, name, timestamp in connection.execute(stmt):
                print(id, name, timestamp)

        As a shortcut to the above syntax, keyword arguments referring to
        types alone may be used, if only type conversion is needed::

            stmt = text("SELECT id, name, timestamp FROM some_table")
            stmt = stmt.columns(
                        id=Integer,
                        name=Unicode,
                        timestamp=DateTime
                    )

            for id, name, timestamp in connection.execute(stmt):
                print(id, name, timestamp)

        The positional form of :meth:`_expression.TextClause.columns`
        also provides the
        unique feature of **positional column targeting**, which is
        particularly useful when using the ORM with complex textual queries. If
        we specify the columns from our model to
        :meth:`_expression.TextClause.columns`,
        the result set will match to those columns positionally, meaning the
        name or origin of the column in the textual SQL doesn't matter::

            stmt = text("SELECT users.id, addresses.id, users.id, "
                 "users.name, addresses.email_address AS email "
                 "FROM users JOIN addresses ON users.id=addresses.user_id "
                 "WHERE users.id = 1").columns(
                    User.id,
                    Address.id,
                    Address.user_id,
                    User.name,
                    Address.email_address
                 )

            query = session.query(User).from_statement(stmt).options(
                contains_eager(User.addresses))

        .. versionadded:: 1.1 the :meth:`_expression.TextClause.columns`
           method now
           offers positional column targeting in the result set when
           the column expressions are passed purely positionally.

        The :meth:`_expression.TextClause.columns` method provides a direct
        route to calling :meth:`_expression.FromClause.alias` as well as
        :meth:`_expression.SelectBase.cte`
        against a textual SELECT statement::

            stmt = stmt.columns(id=Integer, name=String).cte('st')

            stmt = select([sometable]).where(sometable.c.id == stmt.c.id)

        .. versionadded:: 0.9.0 :func:`_expression.text`
           can now be converted into a
           fully featured "selectable" construct using the
           :meth:`_expression.TextClause.columns` method.


        c���g|]:}|j�vr-t|j��|j����n|��;Sr�)r<rr\)r�colrQs  �r�
<listcomp>z&TextClause.columns.<locals>.<listcomp>sZ���!
�!
�!
���w�%���
���%�)�)�C�G�"4�"4�5�5�5��!
�!
�!
rc�4�g|]\}}t||����Sr��r)rr<r%s   rr�z&TextClause.columns.<locals>.<listcomp>s3��
�
�
�)3��e�L��e�$�$�
�
�
r)�
positional)r��
TextAsFromr
)rPr�colsrQ�positional_input_cols�keyed_input_colss   `  rrzTextClause.columns�s����L!
�!
�!
�!
��	!
�!
�!
��
�
�7<�{�{�}�}�
�
�
���$�$��!�$4�4��1�2�2�K�;K�7K�%�
�
�	
rc��tjSrr�rTs rr*zTextClause.typer�rc�6�|j�|��Sr)r*r�rTs rrMzTextClause.comparators���y�+�+�D�1�1�1rc�@�|tjurt|��S|Sr)r�in_opr�r�s  rr�zTextClause.self_groups ���i�o�%�%��D�>�>�!��Krc�z���t��fd�|j���D����|_dS)Nc3�8�K�|]}|j�|fi���fV��dSr)r<)r�brgrs  ��rrz-TextClause._copy_internals.<locals>.<genexpr>$sI����� 
� 
�()�Q�U�E�E�!�N�N�r�N�N�#� 
� 
� 
� 
� 
� 
r)�dictrtrar�s ``rr�zTextClause._copy_internals#sV����� 
� 
� 
� 
� 
�-1�-=�-D�-D�-F�-F� 
� 
� 
�
�
����rc�N�t|j�����Sr)�listrtrar�s  rr�zTextClause.get_children(s���D�$�+�+�-�-�.�.�.rc�L�t|t��o|j|jkSr)rArkryr�s  rr�zTextClause.compare+s ���%��,�,�H���t�y�1H�Hrr�NNNN)(r�r�r�r�r�rCr��UNICODErxr
�_execution_optionsr"r
r:r�r�r�r�_hide_fromsr<r5r8r9rN�classmethodr�deprecated_paramsr"rr	rzr�rr*rMr�rr�r�r�r�rrrkrkCs&��������("�N�#���$@�"�*�M�M��#�6�<�<�	�'�(����#��!�!�!�����X������X��
�K�%)�(�C�(�&�>� ��
<�
<�
<�
<���T��
�
�
�!���.��V�_�6N�O�O�IM�}�}�}�P�O�/���[�2}�~�B>�B>��[�B>�H�T��2�3�3�s
�s
�4�3�s
�j�!�!��X�!��2�2��X�2�����%+�
�
�
�
�
/�/�/�I�I�I�I�Irrkc�R�eZdZdZdZejd���Zed���Z	d�Z
dS)�Nullz�Represent the NULL keyword in a SQL statement.

    :class:`.Null` is accessed as a constant via the
    :func:`.null` function.

    �nullc��tjSrr�rTs rr*z	Null.type9r�rc��t��S)z+Return a constant :class:`.Null` construct.)r���clss r�	_instancezNull._instance=s
���v�v�
rc�,�t|t��Sr)rAr�r�s  rr�zNull.compareCs���%��&�&�&rN)r�r�r�r�r�rr�r*r�r�r�r�rrr�r�/sl���������N�	��!�!���!�����[��
'�'�'�'�'rr�c�X�eZdZdZdZejd���Zd�Ze	d���Z
d�ZdS)�False_z�Represent the ``false`` keyword, or equivalent, in a SQL statement.

    :class:`.False_` is accessed as a constant via the
    :func:`.false` function.

    �falsec��tjSr�rr�rTs rr*zFalse_.typeQ����#�#rc��t��Sr��True_rTs rr�zFalse_._negateUs���w�w�rc��t��S)aReturn a :class:`.False_` construct.

        E.g.::

            >>> from sqlalchemy import false
            >>> print(select([t.c.x]).where(false()))
            SELECT x FROM t WHERE false

        A backend which does not support true/false constants will render as
        an expression against 1 or 0::

            >>> print(select([t.c.x]).where(false()))
            SELECT x FROM t WHERE 0 = 1

        The :func:`.true` and :func:`.false` constants also feature
        "short circuit" operation within an :func:`.and_` or :func:`.or_`
        conjunction::

            >>> print(select([t.c.x]).where(or_(t.c.x > 5, true())))
            SELECT x FROM t WHERE true

            >>> print(select([t.c.x]).where(and_(t.c.x > 5, false())))
            SELECT x FROM t WHERE false

        .. versionchanged:: 0.9 :func:`.true` and :func:`.false` feature
           better integrated behavior within conjunctions and on dialects
           that don't support true/false constants.

        .. seealso::

            :func:`.true`

        �r�r�s rr�zFalse_._instanceXs��H�x�x�rc�,�t|t��Sr)rAr�r�s  rr�zFalse_.compare~s���%��(�(�(rN)r�r�r�r�r�rr�r*r�r�r�r�r�rrr�r�Gs|���������N�	��$�$���$�����#�#��[�#�J)�)�)�)�)rr�c�n�eZdZdZdZejd���Zd�Ze	d���Z
e	d���Zd�ZdS)	r�z�Represent the ``true`` keyword, or equivalent, in a SQL statement.

    :class:`.True_` is accessed as a constant via the
    :func:`.true` function.

    �truec��tjSrr�rTs rr*z
True_.type�r�rc��t��Srr�rTs rr�z
True_._negate�s���x�x�rc�2�|�|���S|Sr)r�)r�r�s  r�_ifnonez
True_._ifnone�s���=��=�=�?�?�"��Lrc��t��S)aReturn a constant :class:`.True_` construct.

        E.g.::

            >>> from sqlalchemy import true
            >>> print(select([t.c.x]).where(true()))
            SELECT x FROM t WHERE true

        A backend which does not support true/false constants will render as
        an expression against 1 or 0::

            >>> print(select([t.c.x]).where(true()))
            SELECT x FROM t WHERE 1 = 1

        The :func:`.true` and :func:`.false` constants also feature
        "short circuit" operation within an :func:`.and_` or :func:`.or_`
        conjunction::

            >>> print(select([t.c.x]).where(or_(t.c.x > 5, true())))
            SELECT x FROM t WHERE true

            >>> print(select([t.c.x]).where(and_(t.c.x > 5, false())))
            SELECT x FROM t WHERE false

        .. versionchanged:: 0.9 :func:`.true` and :func:`.false` feature
           better integrated behavior within conjunctions and on dialects
           that don't support true/false constants.

        .. seealso::

            :func:`.false`

        r�r�s rr�zTrue_._instance�s��H�w�w�rc�,�t|t��Sr)rAr�r�s  rr�z
True_.compare�s���%��'�'�'rN)
r�r�r�r�r�rr�r*r�r�r�r�r�r�rrr�r��s����������N�	��$�$���$��������[���#�#��[�#�J(�(�(�(�(rr�c�x�eZdZdZdZd�Zd�Zd�Zed���Z	d�Z
efd�Zd	�Z
ed
���Zdd�Zd
�ZdS)�
ClauseListzzDescribe a list of clauses, separated by an operator.

    By default, is comma-separated, such as a column listing.

    �
clauselistc�����|�dtj���_|�dd���_|�dd���_|�dd���_|�dt����jr��fd�|D���_n�fd	�|D���_tj	�j���_
dS)
Nr�rsT�group_contents�
_tuple_valuesF�_literal_as_textc�X��g|]&}�|����j�����'S�r�)r�r�)rrArP�text_converters  ��rr�z'ClauseList.__init__.<locals>.<listcomp>�sF���������v�&�&�1�1�$�-�1�H�H���rc�&��g|]
}�|����Sr�r�)rrAr�s  �rr�z'ClauseList.__init__.<locals>.<listcomp>�s#���I�I�I�v�N�N�6�2�2�I�I�Ir)r\r�comma_opr�rsr�r��_expression_literal_as_text�clauses�
is_booleanr:)rPr�rvr�s`  @rrNzClauseList.__init__�s������
�
�:�y�/A�B�B��
��Z�Z���.�.��
�$�j�j�)9�4�@�@���#�Z�Z���?�?������� ;�
�
����	J������%����D�L�L�
J�I�I�I��I�I�I�D�L�&/�&:�4�=�&I�&I��#�#�#rc�*�t|j��Sr)�iterr�rTs r�__iter__zClauseList.__iter__�s���D�L�!�!�!rc�*�t|j��Sr)r�r�rTs r�__len__zClauseList.__len__�s���4�<� � � rc� �t|��Sr)r�rTs rr�zClauseList._select_iterable�s���D�z�z�rc���|jrB|j�t|���|j�����dS|j�t|����dS�Nr�)r�r��appendr�r�r�)rPrAs  rr�zClauseList.append�sv����	:��L��� ��(�(�3�3�D�M�3�J�J�
�
�
�
�
�
�L��� 0�� 8� 8�9�9�9�9�9rc�<�����fd�|jD��|_dS)Nc�"��g|]}�|fi�����Sr�r�)rrArgrs  ��rr�z.ClauseList._copy_internals.<locals>.<listcomp>�s+���G�G�G����f�+�+��+�+�G�G�Gr�r�r�s ``rr�zClauseList._copy_internals�s(����G�G�G�G�G�$�,�G�G�G����rc��|jSrr�r�s  rr�zClauseList.get_children�s
���|�rc�V�ttjd�|jD�����S)Nc��g|]	}|j��
Sr��r�rs  rr�z,ClauseList._from_objects.<locals>.<listcomp>�s��%L�%L�%L�!�a�o�%L�%L�%Lr)r��	itertools�chainr�rTs rr�zClauseList._from_objects�s(���I�O�%L�%L�t�|�%L�%L�%L�M�N�N�NrNc�f�|jr)tj|j|��rt	|��S|Sr)rsr�is_precedentr�r�r�s  rr�zClauseList.self_group�s3���:�	�)�0����H�H�	��D�>�>�!��Krc�"�t|t��s1t|j��dkr|jdj|fi|��St|t���r2t|j��t|j��k�r|j|jur�|jtjtjfvr�t��}|jD]Q}t|j���
|��D]'}|j|fi|��r|�|��n�(�Rt|��t|j��kStdt|j����D])}|j|j|j|fi|��sdS�*dSdS)z�Compare this :class:`.ClauseList` to the given :class:`.ClauseList`,
        including a comparison of all the clause items.

        rrFT)
rAr�r�r�r�r�rr�r��set�
differencerX�range)rPr�r�	completedrA�other_clause�is       rr�zClauseList.compares���
�%��,�,�	��T�\�1B�1B�a�1G�1G�*�4�<��?�*�5�7�7�B�7�7�7��u�j�)�)�	��D�L�!�!�S���%7�%7�7�7��
���/�/��}����� ?�?�?��E�E�	�"�l�"�"�F�(+�E�M�(:�(:�(E�(E�!�)�)�"�"��*�6�>�,�=�=�"�=�=�"�%�M�M�,�7�7�7�!�E�"���9�~�~��U�]�);�);�;�;��q�#�d�l�"3�"3�4�4� � �A�2�4�<��?�2�5�=��3C�J�J�r�J�J�%�$�u�u�%� �4��5rr)r�r�r�r�r�rNr�r�r�r�r�rr�r�r�r�r�r�rrr�r��s���������"�N�J�J�J�""�"�"�!�!�!�����X��:�:�:�%+�H�H�H�H�����O�O��X�O���������rr�c���eZdZdZdZd�Zed���Zed���Zed���Z	e
d���Zd�fd	�	Zd
�Z
�xZS)�BooleanClauseListr�Fc� �td���)Nz+BooleanClauseList has a private constructor)�NotImplementedError)rP�argrs   rrNzBooleanClauseList.__init__&s��!�9�
�
�	
rc�v��g}d�tj|��D��}|D]Z}t||��r�t||��r"|�tj���cS|�|���[t|��dkr&|d�tj���S|s(|r&|d�tj���S�fd�|D��}|�|��}||_	d|_
�|_d|_tj|_d|_|S)Nc�,�g|]}t|����Sr�)r�)rrAs  rr�z0BooleanClauseList._construct.<locals>.<listcomp>/s0��
�
�
��
(��/�/�
�
�
rr�rrc�<��g|]}|�������Sr�)r�)rrQr�s  �rr�z0BooleanClauseList._construct.<locals>.<listcomp>As4���
�
�
�/0�A�L�L��L�*�*�
�
�
rT)r�coerce_generator_argrAr�rr�r�r�rGr�rsr�r�rr�r*r:)	r�r��continue_on�skip_onr�r�convert_clausesrArPs	 `       r�
_constructzBooleanClauseList._construct+sr�����
�
��3�G�<�<�
�
�
���	+�	+�F��&�+�.�.�
D���F�G�,�,�
D��(�(��1B�(�C�C�C�C�C��"�"�6�*�*�*�*�����1�$�$�"�1�%�0�0��9J�0�K�K�K� �	D�W�	D��1�:�(�(��1B�(�C�C�C�
�
�
�
�4C�
�
�
���{�{�3����&�����
� ��
�"����(��	�&*��#��rc�J�|jtjttg|�R�S)a+Produce a conjunction of expressions joined by ``AND``.

        E.g.::

            from sqlalchemy import and_

            stmt = select([users_table]).where(
                            and_(
                                users_table.c.name == 'wendy',
                                users_table.c.enrolled == True
                            )
                        )

        The :func:`.and_` conjunction is also available using the
        Python ``&`` operator (though note that compound expressions
        need to be parenthesized in order to function with Python
        operator precedence behavior)::

            stmt = select([users_table]).where(
                            (users_table.c.name == 'wendy') &
                            (users_table.c.enrolled == True)
                        )

        The :func:`.and_` operation is also implicit in some cases;
        the :meth:`_expression.Select.where`
        method for example can be invoked multiple
        times against a statement, which will have the effect of each
        clause being combined using :func:`.and_`::

            stmt = select([users_table]).\
                    where(users_table.c.name == 'wendy').\
                    where(users_table.c.enrolled == True)

        .. seealso::

            :func:`.or_`

        )r�rr�r�r��r�r�s  rr�zBooleanClauseList.and_Ns%��P�s�~�i�n�e�V�F�g�F�F�F�Frc�J�|jtjttg|�R�S)adProduce a conjunction of expressions joined by ``OR``.

        E.g.::

            from sqlalchemy import or_

            stmt = select([users_table]).where(
                            or_(
                                users_table.c.name == 'wendy',
                                users_table.c.name == 'jack'
                            )
                        )

        The :func:`.or_` conjunction is also available using the
        Python ``|`` operator (though note that compound expressions
        need to be parenthesized in order to function with Python
        operator precedence behavior)::

            stmt = select([users_table]).where(
                            (users_table.c.name == 'wendy') |
                            (users_table.c.name == 'jack')
                        )

        .. seealso::

            :func:`.and_`

        )r�rr�r�r�r�s  rr�zBooleanClauseList.or_xs$��<�s�~�i�m�V�U�E�W�E�E�E�Erc��|fSrr�rTs rr�z"BooleanClauseList._select_iterable�r�rNc�h��|js|Stt|���|���Sr�)r�r�r�r�)rPr�rFs  �rr�zBooleanClauseList.self_group�s5����|�	N��K��*�D�1�1�<�<�W�<�M�M�Mrc�6�t�|��Sr)r�r�rTs rr�zBooleanClauseList._negate�s���!�!�$�'�'�'rr)r�r�r�r�r�rNr�r�r�r�r�r�r�r�r<rSs@rr�r�!s��������!�N��M�
�
�
�
� � ��[� �D�'G�'G��[�'G�R�F�F��[�F�>����X��N�N�N�N�N�N�(�(�(�(�(�(�(rr�c�@��eZdZdZ�fd�Zed���Zdd�Z�xZS)�TuplezRepresent a SQL tuple.c����d�|D��}d�|D��|_|�d|jr
|jdntj��|_tt|��j|i|��dS)a�Return a :class:`.Tuple`.

        Main usage is to produce a composite IN construct using
        :meth:`.ColumnOperators.in_` ::

            from sqlalchemy import tuple_

            tuple_(table.c.col1, table.c.col2).in_(
                [(1, 2), (5, 12), (10, 19)]
            )

        .. versionchanged:: 1.3.6 Added support for SQLite IN tuples.

        .. warning::

            The composite IN construct is not supported by all backends, and is
            currently known to work on PostgreSQL, MySQL, and SQLite.
            Unsupported backends will raise a subclass of
            :class:`~sqlalchemy.exc.DBAPIError` when such an expression is
            invoked.

        c�,�g|]}t|����Sr�)r&rs  rr�z"Tuple.__init__.<locals>.<listcomp>�s!��9�9�9�A�$�Q�'�'�9�9�9rc��g|]	}|j��
Sr�ri)rr�s  rr�z"Tuple.__init__.<locals>.<listcomp>�s��8�8�8��C�H�8�8�8rr%rN)�_type_tupler\rr�r*r�r�rN)rPr�rrFs   �rrNzTuple.__init__�s����0:�9��9�9�9��8�8��8�8�8����F�F��#'�#3�J�D��Q����9J�
�
��	�
	$��e�T���#�W�3��3�3�3�3�3rc��|fSrr�rTs rr�zTuple._select_iterable�r�rNc�|���t��fd�t||j��D������S)Nc
�@��g|]\}}td|�|d������S)NT)r�r�r5r%r6)r�o�compared_to_typer�r%s   ��rr�z%Tuple._bind_param.<locals>.<listcomp>�sQ���
�
�
�(�A�'����*2�&6���
���
�
�
r)r��ziprr�r�s ` `rr�zTuple._bind_param�sV�����
�
�
�
�
�,/�s�D�4D�+E�+E�
�
�
�
��*�,�,�	rr)	r�r�r�r�rNr�r�r�r<rSs@rr�r��sn������� � �4�4�4�4�4�B����X��
�
�
�
�
�
�
�
rr�c�D�eZdZdZdZdd�Zefd�Zd�Ze	d���Z
dS)	�Casea�Represent a ``CASE`` expression.

    :class:`.Case` is produced using the :func:`.case` factory function,
    as in::

        from sqlalchemy import case

        stmt = select([users_table]).                    where(
                        case(
                            [
                                (users_table.c.name == 'wendy', 'W'),
                                (users_table.c.name == 'jack', 'J')
                            ],
                            else_='E'
                        )
                    )

    Details on :class:`.Case` usage is at :func:`.case`.

    .. seealso::

        :func:`.case`

    �caseNc�h�	tj|��}n#t$rYnwxYw|�
d�|D��}nd�|D��}|r!t|d��dj}nd}|�d|_nt
|��|_||_||_|�t
|��|_dSd|_dS)a�Produce a ``CASE`` expression.

        The ``CASE`` construct in SQL is a conditional object that
        acts somewhat analogously to an "if/then" construct in other
        languages.  It returns an instance of :class:`.Case`.

        :func:`.case` in its usual form is passed a list of "when"
        constructs, that is, a list of conditions and results as tuples::

            from sqlalchemy import case

            stmt = select([users_table]).\
                        where(
                            case(
                                [
                                    (users_table.c.name == 'wendy', 'W'),
                                    (users_table.c.name == 'jack', 'J')
                                ],
                                else_='E'
                            )
                        )

        The above statement will produce SQL resembling::

            SELECT id, name FROM user
            WHERE CASE
                WHEN (name = :name_1) THEN :param_1
                WHEN (name = :name_2) THEN :param_2
                ELSE :param_3
            END

        When simple equality expressions of several values against a single
        parent column are needed, :func:`.case` also has a "shorthand" format
        used via the
        :paramref:`.case.value` parameter, which is passed a column
        expression to be compared.  In this form, the :paramref:`.case.whens`
        parameter is passed as a dictionary containing expressions to be
        compared against keyed to result expressions.  The statement below is
        equivalent to the preceding statement::

            stmt = select([users_table]).\
                        where(
                            case(
                                {"wendy": "W", "jack": "J"},
                                value=users_table.c.name,
                                else_='E'
                            )
                        )

        The values which are accepted as result values in
        :paramref:`.case.whens` as well as with :paramref:`.case.else_` are
        coerced from Python literals into :func:`.bindparam` constructs.
        SQL expressions, e.g. :class:`_expression.ColumnElement` constructs,
        are accepted
        as well.  To coerce a literal string expression into a constant
        expression rendered inline, use the :func:`_expression.literal_column`
        construct,
        as in::

            from sqlalchemy import case, literal_column

            case(
                [
                    (
                        orderline.c.qty > 100,
                        literal_column("'greaterthan100'")
                    ),
                    (
                        orderline.c.qty > 10,
                        literal_column("'greaterthan10'")
                    )
                ],
                else_=literal_column("'lessthan10'")
            )

        The above will render the given constants without using bound
        parameters for the result values (but still for the comparison
        values), as in::

            CASE
                WHEN (orderline.qty > :qty_1) THEN 'greaterthan100'
                WHEN (orderline.qty > :qty_2) THEN 'greaterthan10'
                ELSE 'lessthan10'
            END

        :param whens: The criteria to be compared against,
         :paramref:`.case.whens` accepts two different forms, based on
         whether or not :paramref:`.case.value` is used.

         In the first form, it accepts a list of 2-tuples; each 2-tuple
         consists of ``(<sql expression>, <value>)``, where the SQL
         expression is a boolean expression and "value" is a resulting value,
         e.g.::

            case([
                (users_table.c.name == 'wendy', 'W'),
                (users_table.c.name == 'jack', 'J')
            ])

         In the second form, it accepts a Python dictionary of comparison
         values mapped to a resulting value; this form requires
         :paramref:`.case.value` to be present, and values will be compared
         using the ``==`` operator, e.g.::

            case(
                {"wendy": "W", "jack": "J"},
                value=users_table.c.name
            )

        :param value: An optional SQL expression which will be used as a
          fixed "comparison point" for candidate values within a dictionary
          passed to :paramref:`.case.whens`.

        :param else\_: An optional SQL expression which will be the evaluated
          result of the ``CASE`` construct if all expressions within
          :paramref:`.case.whens` evaluate to false.  When omitted, most
          databases will produce a result of NULL if none of the "when"
          expressions evaluate to true.


        Nc�t�g|]5\}}t|�����t|��f��6Sr�)r&r��rrQ�rs   rr�z!Case.__init__.<locals>.<listcomp>�	sN������Q��#�1�%�%�0�0�2�2�4E�a�4H�4H�I���rc�t�g|]5\}}t|�����t|��f��6Sr�)�_no_literalsr�r&rs   rr�z!Case.__init__.<locals>.<listcomp>�	sL������Q���a���+�+�-�-�/@��/C�/C�D���r���)	r�dictlike_iteritemsr�r�r*r8r&�whens�else_)rPrr8r�whenlistr%s      rrNz
Case.__init__�s���v	��+�E�2�2�E�E���	�	�	��D�	��������#����H�H�
��#����H�
�	���"��&�&�r�*�/�E�E��E��=��D�J�J�*�5�1�1�D�J���	���
���*�5�1�1�D�J�J�J��D�J�J�Js��
$�$c����|j��|jfi���|_��fd�|jD��|_|j��|jfi���|_dSdS)Nc�:��g|]\}}�|fi����|fi���f��Sr�r�)r�x�yrgrs   ��rr�z(Case._copy_internals.<locals>.<listcomp>�	s>���N�N�N�4�1�a�u�u�Q�~�~�"�~�~�u�u�Q�~�~�"�~�~�6�N�N�Nr�r8rrr�s ``rr�zCase._copy_internals�	sv�����:�!���t�z�0�0�R�0�0�D�J�N�N�N�N�N�4�:�N�N�N��
��:�!���t�z�0�0�R�0�0�D�J�J�J�"�!rc+�xK�|j�	|jV�|jD]
\}}|V�|V��|j�|jV�dSdSrr)rPrvrrs    rr�zCase.get_children�	si�����:�!��*�����J�	�	�D�A�q��G�G�G��G�G�G�G��:�!��*������"�!rc�p�ttjd�|���D�����S)Nc��g|]	}|j��
Sr�r��rrs  rr�z&Case._from_objects.<locals>.<listcomp>�	s��K�K�K�!�a�o�K�K�Kr)r�r�r�r�rTs rr�zCase._from_objects�	s9����O�K�K�t�7H�7H�7J�7J�K�K�K�L�
�
�	
rr��r�r�r�r�r�rNrr�r�r�r�r�rrr
r
�s���������4�N�Z�Z�Z�Z�x%+�1�1�1�1�����
�
��X�
�
�
rr
c�&�t||d���S)a�Produce a :class:`.ColumnClause` object that has the
    :paramref:`_expression.column.is_literal` flag set to True.

    :func:`_expression.literal_column` is similar to
    :func:`_expression.column`, except that
    it is more often used as a "standalone" column expression that renders
    exactly as stated; while :func:`_expression.column`
    stores a string name that
    will be assumed to be part of a table and may be quoted as such,
    :func:`_expression.literal_column` can be that,
    or any other arbitrary column-oriented
    expression.

    :param text: the text of the expression; can be any SQL expression.
      Quoting rules will not be applied. To specify a column-name expression
      which should be subject to quoting rules, use the :func:`column`
      function.

    :param type\_: an optional :class:`~sqlalchemy.types.TypeEngine`
      object which will
      provide result-set translation and additional expression semantics for
      this column. If left as ``None`` the type will be :class:`.NullType`.

    .. seealso::

        :func:`_expression.column`

        :func:`_expression.text`

        :ref:`sqlexpression_literal_column`

    T)r%�
is_literalr�)ryr%s  r�literal_columnr#�	s��B��E�d�;�;�;�;rc�B�eZdZdZdZd�Zefd�Zd�Ze	d���Z
dS)r)a`Represent a ``CAST`` expression.

    :class:`.Cast` is produced using the :func:`.cast` factory function,
    as in::

        from sqlalchemy import cast, Numeric

        stmt = select([
                    cast(product_table.c.unit_price, Numeric(10, 4))
                ])

    Details on :class:`.Cast` usage is at :func:`.cast`.

    .. seealso::

        :ref:`coretutorial_casts`

        :func:`.cast`

        :func:`.type_coerce` - an alternative to CAST that coerces the type
        on the Python side only, which is often sufficient to generate the
        correct SQL and data coercion.

    r+c��tj|��|_t||j���|_t|j��|_dS)a(Produce a ``CAST`` expression.

        :func:`.cast` returns an instance of :class:`.Cast`.

        E.g.::

            from sqlalchemy import cast, Numeric

            stmt = select([
                        cast(product_table.c.unit_price, Numeric(10, 4))
                    ])

        The above statement will produce SQL resembling::

            SELECT CAST(unit_price AS NUMERIC(10, 4)) FROM product

        The :func:`.cast` function performs two distinct functions when
        used.  The first is that it renders the ``CAST`` expression within
        the resulting SQL string.  The second is that it associates the given
        type (e.g. :class:`.TypeEngine` class or instance) with the column
        expression on the Python side, which means the expression will take
        on the expression operator behavior associated with that type,
        as well as the bound-value handling and result-row-handling behavior
        of the type.

        .. versionchanged:: 0.9.0 :func:`.cast` now applies the given type
           to the expression such that it takes effect on the bound-value,
           e.g. the Python-to-database direction, in addition to the
           result handling, e.g. database-to-Python, direction.

        An alternative to :func:`.cast` is the :func:`.type_coerce` function.
        This function performs the second task of associating an expression
        with a specific type, but does not render the ``CAST`` expression
        in SQL.

        :param expression: A SQL expression, such as a
         :class:`_expression.ColumnElement`
         expression or a Python string which will be coerced into a bound
         literal value.

        :param type\_: A :class:`.TypeEngine` class or instance indicating
         the type to which the ``CAST`` should apply.

        .. seealso::

            :ref:`coretutorial_casts`

            :func:`.type_coerce` - an alternative to CAST that coerces the type
            on the Python side only, which is often sufficient to generate the
            correct SQL and data coercion.


        r$N)r�to_instancer*r&rArfrg�rPr+r%s   rrNz
Cast.__init__�	sB��l�(��/�/��	�'�
�$�)�D�D�D���$�T�Y�/�/����rc�R�||jfi|��|_||jfi|��|_dSr�rArgr�s   rr�zCast._copy_internals,
s<���e�D�K�.�.�2�.�.����%���6�6�2�6�6����rc��|j|jfSrr)r�s  rr�zCast.get_children0
s���{�D�O�+�+rc��|jjSr�rAr�rTs rr�zCast._from_objects3
�
���{�(�(rNr r�rrr)r)�	sx��������2�N�80�80�80�t%+�7�7�7�7�,�,�,��)�)��X�)�)�)rr)c�j�eZdZdZdZd�Zefd�Zd�Ze	d���Z
ejd���Z
d
d	�ZdS)�
TypeCoercea�Represent a Python-side type-coercion wrapper.

    :class:`.TypeCoerce` supplies the :func:`_expression.type_coerce`
    function; see that function for usage details.

    .. versionchanged:: 1.1 The :func:`.type_coerce` function now produces
       a persistent :class:`.TypeCoerce` wrapper object rather than
       translating the given object in place.

    .. seealso::

        :func:`_expression.type_coerce`

        :func:`.cast`

    �type_coercec�n�tj|��|_t||j���|_dS)a�Associate a SQL expression with a particular type, without rendering
        ``CAST``.

        E.g.::

            from sqlalchemy import type_coerce

            stmt = select([type_coerce(log_table.date_string, StringDateTime())])

        The above construct will produce a :class:`.TypeCoerce` object, which
        does not modify the rendering in any way on the SQL side, with the
        possible exception of a generated label if used in a columns clause
        context::

            SELECT date_string AS anon_1 FROM log

        When result rows are fetched, the ``StringDateTime`` type processor
        will be applied to result rows on behalf of the ``date_string`` column.

        .. note:: the :func:`.type_coerce` construct does not render any
           SQL syntax of its own, including that it does not imply
           parenthesization.   Please use :meth:`.TypeCoerce.self_group`
           if explicit parenthesization is required.

        In order to provide a named label for the expression, use
        :meth:`_expression.ColumnElement.label`::

            stmt = select([
                type_coerce(log_table.date_string, StringDateTime()).label('date')
            ])


        A type that features bound-value handling will also have that behavior
        take effect when literal values or :func:`.bindparam` constructs are
        passed to :func:`.type_coerce` as targets.
        For example, if a type implements the
        :meth:`.TypeEngine.bind_expression`
        method or :meth:`.TypeEngine.bind_processor` method or equivalent,
        these functions will take effect at statement compilation/execution
        time when a literal value is passed, as in::

            # bound-value handling of MyStringType will be applied to the
            # literal value "some string"
            stmt = select([type_coerce("some string", MyStringType)])

        When using :func:`.type_coerce` with composed expressions, note that
        **parenthesis are not applied**.   If :func:`.type_coerce` is being
        used in an operator context where the parenthesis normally present from
        CAST are necessary, use the :meth:`.TypeCoerce.self_group` method::

            >>> some_integer = column("someint", Integer)
            >>> some_string = column("somestr", String)
            >>> expr = type_coerce(some_integer + 5, String) + some_string
            >>> print(expr)
            someint + :someint_1 || somestr
            >>> expr = type_coerce(some_integer + 5, String).self_group() + some_string
            >>> print(expr)
            (someint + :someint_1) || somestr

        :param expression: A SQL expression, such as a
         :class:`_expression.ColumnElement`
         expression or a Python string which will be coerced into a bound
         literal value.

        :param type\_: A :class:`.TypeEngine` class or instance indicating
         the type to which the expression is coerced.

        .. seealso::

            :ref:`coretutorial_casts`

            :func:`.cast`

        r$N)rr&r*r&rAr's   rrNzTypeCoerce.__init__L
s1��V�(��/�/��	�'�
�$�)�D�D�D����rc�b�||jfi|��|_|j�dd��dS)N�typed_expression)rArHr\r�s   rr�zTypeCoerce._copy_internals�
s<���e�D�K�.�.�2�.�.����
���,�d�3�3�3�3�3rc��|jfSrr@r�s  rr�zTypeCoerce.get_children�
s����~�rc��|jjSrr,rTs rr�zTypeCoerce._from_objects�
r-rc��t|jt��r'|j���}|j|_|S|jSr)rArAr7rr*)rP�bps  rr3zTypeCoerce.typed_expression�
s?���d�k�=�1�1�	���#�#�%�%�B��i�B�G��I��;�rNc�x�|j�|���}||jurt||j��S|Sr�)rAr�r/r*)rPr��groupeds   rr�zTypeCoerce.self_group�
s>���+�(�(��(�9�9���$�+�%�%��g�t�y�1�1�1��Krr)r�r�r�r�r�rNrr�r�r�r�rr�r3r�r�rrr/r/8
s���������"#�N�LE�LE�LE�\%+�4�4�4�4�����)�)��X�)�
������������rr/c�B�eZdZdZdZd�Zefd�Zd�Ze	d���Z
dS)�Extractz=Represent a SQL EXTRACT clause, ``extract(field FROM expr)``.�extractc�`�tj|_||_t	|d��|_dS)z�Return a :class:`.Extract` construct.

        This is typically available as :func:`.extract`
        as well as ``func.extract`` from the
        :data:`.func` namespace.

        N)r�INTEGERTYPEr*�fieldr&r-)rPr?r-rvs    rrNzExtract.__init__�
s*���(��	���
�%�d�D�1�1��	�	�	rc�,�||jfi|��|_dSr�r-r�s   rr�zExtract._copy_internals�
s!���E�$�)�*�*�r�*�*��	�	�	rc��|jfSrrAr�s  rr�zExtract.get_children�
s���	�|�rc��|jjSr)r-r�rTs rr�zExtract._from_objects�
s
���y�&�&rNr r�rrr;r;�
sq������G�G��N�
2�
2�
2�%+�+�+�+�+�����'�'��X�'�'�'rr;c�<�eZdZdZdZd�Zefd�Zed���Z	dS)�_label_referencea�Wrap a column expression as it appears in a 'reference' context.

    This expression is any that includes an _order_by_label_element,
    which is a Label, or a DESC / ASC construct wrapping a Label.

    The production of _label_reference() should occur when an expression
    is added to this context; this includes the ORDER BY or GROUP BY of a
    SELECT statement, as well as a few other places, such as the ORDER BY
    within an OVER clause.

    �label_referencec��||_dSr�r�rPrs  rrNz_label_reference.__init__�
�
������rc�,�||jfi|��|_dSrrHr�s   rr�z _label_reference._copy_internals�
�!���u�T�\�0�0�R�0�0����rc��dS)Nr�r�rTs rr�z_label_reference._from_objects�
s���rrN)
r�r�r�r�r�rNrr�r�r�r�rrrErE�
sh������
�
�'�N����%+�1�1�1�1�����X���rrEc�8�eZdZdZd�Zejd���ZdS)�_textual_label_reference�textual_label_referencec��||_dSrrHrIs  rrNz!_textual_label_reference.__init__�
rJrc�@�t�|j��Sr)rkrrrTs r�_text_clausez%_textual_label_reference._text_clause�
s���&�&�t�|�4�4�4rN)r�r�r�r�rNrr�rSr�rrrOrO�
sG������.�N����
��5�5���5�5�5rrOc���eZdZdZdZ					dd�Zed���Zed���Zed���Z	ed	���Z
ed
���Zed���Z
ed���Zefd
�Zd�Zd�Zd�Zdd�ZdS)r�a�Define a 'unary' expression.

    A unary expression has a single column expression
    and an operator.  The operator can be placed on the left
    (where it is called the 'operator') or right (where it is called the
    'modifier') of the column expression.

    :class:`.UnaryExpression` is the basis for several unary operators
    including those used by :func:`.desc`, :func:`.asc`, :func:`.distinct`,
    :func:`.nullsfirst` and :func:`.nullslast`.

    �unaryNFc��||_||_|�|jp|j���|_t	j|��|_||_||_dSr�)	r��modifierr�rrr&r*r��wraps_column_expression)rPrr�rWr%r�rXs       rrNzUnaryExpression.__init__sc��!��
� ��
��)�)��M�2�T�]�*�
�
����(��/�/��	����'>��$�$�$rc�T�tt|��tjd���S)aVProduce the ``NULLS FIRST`` modifier for an ``ORDER BY`` expression.

        :func:`.nullsfirst` is intended to modify the expression produced
        by :func:`.asc` or :func:`.desc`, and indicates how NULL values
        should be handled when they are encountered during ordering::


            from sqlalchemy import desc, nullsfirst

            stmt = select([users_table]).order_by(
                nullsfirst(desc(users_table.c.name)))

        The SQL expression from the above would resemble::

            SELECT id, name FROM user ORDER BY name DESC NULLS FIRST

        Like :func:`.asc` and :func:`.desc`, :func:`.nullsfirst` is typically
        invoked from the column expression itself using
        :meth:`_expression.ColumnElement.nullsfirst`,
        rather than as its standalone
        function version, as in::

            stmt = select([users_table]).order_by(
                users_table.c.name.desc().nullsfirst())

        .. seealso::

            :func:`.asc`

            :func:`.desc`

            :func:`.nullslast`

            :meth:`_expression.Select.order_by`

        F�rWrX)r��_literal_as_label_referencer�
nullsfirst_op�r��columns  r�_create_nullsfirstz"UnaryExpression._create_nullsfirsts0��L�'��/�/��,�$)�
�
�
�	
rc�T�tt|��tjd���S)aOProduce the ``NULLS LAST`` modifier for an ``ORDER BY`` expression.

        :func:`.nullslast` is intended to modify the expression produced
        by :func:`.asc` or :func:`.desc`, and indicates how NULL values
        should be handled when they are encountered during ordering::


            from sqlalchemy import desc, nullslast

            stmt = select([users_table]).order_by(
                nullslast(desc(users_table.c.name)))

        The SQL expression from the above would resemble::

            SELECT id, name FROM user ORDER BY name DESC NULLS LAST

        Like :func:`.asc` and :func:`.desc`, :func:`.nullslast` is typically
        invoked from the column expression itself using
        :meth:`_expression.ColumnElement.nullslast`,
        rather than as its standalone
        function version, as in::

            stmt = select([users_table]).order_by(
                users_table.c.name.desc().nullslast())

        .. seealso::

            :func:`.asc`

            :func:`.desc`

            :func:`.nullsfirst`

            :meth:`_expression.Select.order_by`

        FrZ)r�r[r�nullslast_opr]s  r�_create_nullslastz!UnaryExpression._create_nullslastEs0��L�'��/�/��+�$)�
�
�
�	
rc�T�tt|��tjd���S)aZProduce a descending ``ORDER BY`` clause element.

        e.g.::

            from sqlalchemy import desc

            stmt = select([users_table]).order_by(desc(users_table.c.name))

        will produce SQL as::

            SELECT id, name FROM user ORDER BY name DESC

        The :func:`.desc` function is a standalone version of the
        :meth:`_expression.ColumnElement.desc`
        method available on all SQL expressions,
        e.g.::


            stmt = select([users_table]).order_by(users_table.c.name.desc())

        :param column: A :class:`_expression.ColumnElement` (e.g.
         scalar SQL expression)
         with which to apply the :func:`.desc` operation.

        .. seealso::

            :func:`.asc`

            :func:`.nullsfirst`

            :func:`.nullslast`

            :meth:`_expression.Select.order_by`

        FrZ)r�r[r�desc_opr]s  r�_create_desczUnaryExpression._create_descqs0��J�'��/�/��&�$)�
�
�
�	
rc�T�tt|��tjd���S)aSProduce an ascending ``ORDER BY`` clause element.

        e.g.::

            from sqlalchemy import asc
            stmt = select([users_table]).order_by(asc(users_table.c.name))

        will produce SQL as::

            SELECT id, name FROM user ORDER BY name ASC

        The :func:`.asc` function is a standalone version of the
        :meth:`_expression.ColumnElement.asc`
        method available on all SQL expressions,
        e.g.::


            stmt = select([users_table]).order_by(users_table.c.name.asc())

        :param column: A :class:`_expression.ColumnElement` (e.g.
         scalar SQL expression)
         with which to apply the :func:`.asc` operation.

        .. seealso::

            :func:`.desc`

            :func:`.nullsfirst`

            :func:`.nullslast`

            :meth:`_expression.Select.order_by`

        FrZ)r�r[r�asc_opr]s  r�_create_asczUnaryExpression._create_asc�s0��H�'��/�/��%�$)�
�
�
�	
rc�d�t|��}t|tj|jd���S)a�Produce an column-expression-level unary ``DISTINCT`` clause.

        This applies the ``DISTINCT`` keyword to an individual column
        expression, and is typically contained within an aggregate function,
        as in::

            from sqlalchemy import distinct, func
            stmt = select([func.count(distinct(users_table.c.name))])

        The above would produce an expression resembling::

            SELECT COUNT(DISTINCT name) FROM user

        The :func:`.distinct` function is also available as a column-level
        method, e.g. :meth:`_expression.ColumnElement.distinct`, as in::

            stmt = select([func.count(users_table.c.name.distinct())])

        The :func:`.distinct` operator is different from the
        :meth:`_expression.Select.distinct` method of
        :class:`_expression.Select`,
        which produces a ``SELECT`` statement
        with ``DISTINCT`` applied to the result set as a whole,
        e.g. a ``SELECT DISTINCT`` expression.  See that method for further
        information.

        .. seealso::

            :meth:`_expression.ColumnElement.distinct`

            :meth:`_expression.Select.distinct`

            :data:`.func`

        F�r�r%rX)r&r�r�distinct_opr*�r�r-s  r�_create_distinctz UnaryExpression._create_distinct�s:��J!��&�&�����*��)�$)�	
�
�
�	
rc�\�|jtjtjfvr|jjSdSr)rWrrdrgrr�rTs rr�z'UnaryExpression._order_by_label_element�s*���=�Y�.�	�0@�A�A�A��<�7�7��4rc��|jjSr�rr�rTs rr�zUnaryExpression._from_objects��
���|�)�)rc�,�||jfi|��|_dSrrHr�s   rr�zUnaryExpression._copy_internals�rLrc��|jfSrrHr�s  rr�zUnaryExpression.get_children������rc��t|t��o7|j|jko'|j|jko|jj|jfi|��S)zcCompare this :class:`UnaryExpression` against the given
        :class:`_expression.ClauseElement`.)rAr�r�rWrr�r�s   rr�zUnaryExpression.compares[��

�u�o�.�.�
:��
���/�
:��
���/�
:�%���$�U�]�9�9�b�9�9�		
rc�z�|j�3t|j|j|j|j|j|j���S|jjtj	jurKt|�
tj���tjtj	|jd���St�|��S)N)r�r�rWr%rXr�)r�r%rXr�)r�r�rr�rWr*rXr�rr�r�rr?rDr�rTs rr�zUnaryExpression._negates����;�"�"������}����i�(,�(D�
���
��Y�
%��)=�)L�
L�
L�"����	�
��6�6�"���*�(,�(D�����
�!�(�(��.�.�.rc�f�|jr)tj|j|��rt|��S|Sr)r�rr�r�r�s  rr�zUnaryExpression.self_group$s3���=�	�Y�3�D�M�7�K�K�	��D�>�>�!��Kr)NNNNFr)r�r�r�r�r�rNr�r_rbrerhrmr�r�r�rr�r�r�r�r�r�rrr�r��
sf���������N�
���� %�?�?�?�?�$�)
�)
��[�)
�V�)
�)
��[�)
�V�(
�(
��[�(
�T�'
�'
��[�'
�R�*
�*
��[�*
�X����X���*�*��X�*�%+�1�1�1�1����	
�	
�	
�/�/�/�*�����rr�c�J�eZdZdZed���Zed���Zd�Zd�ZdS)�CollectionAggregateaForms the basis for right-hand collection operator modifiers
    ANY and ALL.

    The ANY and ALL keywords are available in different ways on different
    backends.  On PostgreSQL, they only work for an ARRAY type.  On
    MySQL, they only work for subqueries.

    c���t|��}|jr$t|d��r|���}|���}t|tjtj	d���S)a�Produce an ANY expression.

        This may apply to an array type for some dialects (e.g. postgresql),
        or to a subquery for others (e.g. mysql).  e.g.::

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

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

        .. versionadded:: 1.1

        .. seealso::

            :func:`_expression.all_`

        �	as_scalarFrj)
r&r�r�r{r�ryrr�rr�rls  r�_create_anyzCollectionAggregate._create_any5st��*!��&�&����	$�'�$��"<�"<�	$��>�>�#�#�D���� � ��"���%��#�$)�	
�
�
�	
rc���t|��}|jr$t|d��r|���}|���}t|tjtj	d���S)a�Produce an ALL expression.

        This may apply to an array type for some dialects (e.g. postgresql),
        or to a subquery for others (e.g. mysql).  e.g.::

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

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

        .. versionadded:: 1.1

        .. seealso::

            :func:`_expression.any_`

        r{Frj)
r&r�r�r{r�ryrr�rr�rls  r�_create_allzCollectionAggregate._create_allVst��*!��&�&����	$�'�$��"<�"<�	$��>�>�#�#�D���� � ��"���%��#�$)�	
�
�
�	
rc��tj|��stjd���d|d<|jjtj|��g|�Ri|��S)N�2Only comparison operators may be used with ANY/ALLT�reverse)r�
is_comparisonrr�rMr��mirrorr�s    rr�zCollectionAggregate.operateysi���&�r�*�*�	��#�D���
�!��y��&�t��&�y�'7��';�';�N�e�N�N�N�v�N�N�Nrc�V�tj|��rJ�tjd���)Nr�)rr�rr�r�s    rr�z#CollectionAggregate.reverse_operate�s1���*�2�.�.�.�.�.���@�
�
�	
rN)	r�r�r�r�r�r|r~r�r�r�rrryry+sw���������
�
��[�
�@�
�
��[�
�DO�O�O�
�
�
�
�
rryc�"�eZdZd�Zdd�Zd�ZdS)r�c��||_tj|_||_||_d|_d|_|j|_dS)NT)	rrr�r*r�r�rWrXr:)rPrr�r�s    rrNzAsBoolean.__init__�sA������(��	� ��
������
�'+��$�&-�&D��#�#�#rNc��|Srr�r�s  rr�zAsBoolean.self_group�����rc��t|jttf��r|j���St|j|j|j��Sr)rArr�r�r�r�r�r�rTs rr�zAsBoolean._negate�sG���d�l�U�F�O�4�4�	G��<�'�'�)�)�)��T�\�4�;��
�F�F�Frr)r�r�r�rNr�r�r�rrr�r��sN������E�E�E�����G�G�G�G�Grr�c���eZdZdZdZdZ		dd�Zd�ZeZe	d���Z
e	d���Zefd	�Z
d
�Zd�Zdd�Z�fd
�Z�xZS)r'a�Represent an expression that is ``LEFT <operator> RIGHT``.

    A :class:`.BinaryExpression` is generated automatically
    whenever two column expressions are used in a Python binary expression::

        >>> from sqlalchemy.sql import column
        >>> column('a') + column('b')
        <sqlalchemy.sql.expression.BinaryExpression object at 0x101029dd0>
        >>> print(column('a') + column('b'))
        a + b

    �binaryTNc��t|tj��rtj|��}||f|_|�|���|_|�|���|_||_	tj|��|_||_
tj|��|_|�	i|_dS||_dSr�)rAr�string_typesr�	custom_op�_origr��left�rightr�rr&r*r�r�r:�	modifiers)rPr�r�r�r%r�r�s       rrNzBinaryExpression.__init__�s���
�h�� 1�2�2�	5� �*�8�4�4�H��E�]��
��O�O�H�O�5�5��	��%�%�h�%�7�7��
� ��
��(��/�/��	����&/�&:�8�&D�&D��#����D�N�N�N�&�D�N�N�Nrc���|jtjtjfvrF|�t|jd��t|jd����Std���)Nrrr�)r��eq�ner#r�r�rTs rr�zBinaryExpression.__bool__�sW���=�X�[�(�+�6�6�6��=�=��d�j��m�!4�!4�d�4�:�a�=�6I�6I�J�J�J��I�J�J�Jrc�4�tj|j��Sr)rr�r�rTs rr�zBinaryExpression.is_comparison�s���&�t�}�5�5�5rc�4�|jj|jjzSr)r�r�r�rTs rr�zBinaryExpression._from_objects�s���y�&���)A�A�Arc�R�||jfi|��|_||jfi|��|_dSr�r�r�r�s   rr�z BinaryExpression._copy_internals�s<���E�$�)�*�*�r�*�*��	��U�4�:�,�,��,�,��
�
�
rc��|j|jfSrr�r�s  rr�zBinaryExpression.get_children�s���y�$�*�$�$rc�>�t|t��o�|j|jkox|jj|jfi|��r|jj|jfi|��pHt
j|j��o/|jj|jfi|��o|jj|jfi|��S)z[Compare this :class:`BinaryExpression` against the
        given :class:`BinaryExpression`.)rAr'r�r�r�r�r�is_commutativer�s   rr�zBinaryExpression.compare�s���

�u�.�/�/�

��
���/�

�"��	�!�%�*�3�3��3�3�:�&�D�J�&�u�{�9�9�b�9�9���,�T�]�;�;�=�)��	�)�%�+�<�<��<�<�=�*��
�*�5�:�<�<��<�<�	
rc�X�tj|j|��rt|��S|Sr)rr�r�r�r�s  rr�zBinaryExpression.self_group�s*���!�$�-��9�9�	��D�>�>�!��Krc����|j�3t|j|j|j|j|j|j���Stt|�����S)N)r�r%r�)	r�r'r�r�r�r*r�r�r�r�s �rr�zBinaryExpression._negate�s_����;�"�#��	��
����}��i��.�
���
��)�4�0�0�8�8�:�:�:r)NNNr)r�r�r�r�r�r:rNr�r�r�r�r�rr�r�r�r�r�r<rSs@rr'r'�s
����������N�!���IM�'�'�'�'�(K�K�K��K�
�6�6��X�6��B�B��X�B�%+�-�-�-�-�%�%�%�
�
�
�$����;�;�;�;�;�;�;�;�;rr'c�$�eZdZdZdZd�Zdd�ZdS)�Slicez�Represent SQL for a Python array-slice object.

    This is not a specific SQL construct at this level, but
    may be interpreted by specific dialects, e.g. PostgreSQL.

    �slicec�R�||_||_||_tj|_dSr)�start�stop�steprr�r*)rPr�r�r�s    rrNzSlice.__init__
s%����
���	���	��%��	�	�	rNc�&�|tjusJ�|Sr)r��getitemr�s  rr�zSlice.self_group
s���(�*�*�*�*�*��rr)r�r�r�r�r�rNr�r�rrr�r�
sH���������N�&�&�&������rr�c��eZdZdZdS)�IndexExpressionzJRepresent the class of expressions that are like an "index"
    operation.N)r�r�r�r�r�rrr�r�
s��������	�Drr�c���eZdZdZdZd�Zdd�Zejd���Z	e
d���Ze
d���Ze
fd	�Zd
�Ze
d���Ze
d���Zd
�Zd�Zd�Zd�ZdS)r�z/Represent a grouping within a column expression�groupingc�T�||_t|dtj��|_dS�Nr*)rr�rr�r*rIs  rrNzGrouping.__init__%
s#������G�V�X�->�?�?��	�	�	rNc��|Srr�r�s  rr�zGrouping.self_group)
r�rc��|jjSr�rr:rTs rr:zGrouping._is_implicitly_boolean,
�
���|�2�2rc��|jSr)r5rTs rr6zGrouping._key_label0
s
���{�rc�<�t|jdd��p|jS)Nr5)r�rrrTs rr5zGrouping._label4
s���t�|�X�t�4�4�G���Grc�,�||jfi|��|_dSrrHr�s   rr�zGrouping._copy_internals8
rLrc��|jfSrrHr�s  rr�zGrouping.get_children;
rtrc�J�t|jt��r|jgSgSr)rArrLrTs rrzGrouping._proxies>
s%���d�l�M�2�2�	��L�>�!��Irc��|jjSrrprTs rr�zGrouping._from_objectsE
rqrc�,�t|j|��Sr)r�r)rP�attrs  rr�zGrouping.__getattr__I
s���t�|�T�*�*�*rc� �|j|jd�S)N�rr*r�rTs rr^zGrouping.__getstate__L
s���<���;�;�;rc�:�|d|_|d|_dS)Nrr*r�r_s  rrazGrouping.__setstate__O
s���Y�'����&�M��	�	�	rc�j�t|t��o|j�|j��Sr)rAr�rr�r�s   rr�zGrouping.compareS
s2���%��*�*�
�t�|�/C�/C��M�0
�0
�	
rr)r�r�r�r�r�rNr�rr�r:r�r6r5rr�r�rr�r�r^rar�r�rrr�r� 
s7������9�9��N�@�@�@�����
��3�3���3�����X���H�H��X�H�%+�1�1�1�1��������X���*�*��X�*�+�+�+�<�<�<�"�"�"�
�
�
�
�
rr��RANGE_UNBOUNDED�
RANGE_CURRENTc���eZdZdZdZdZdZdZ		dd�Zd�Z	d�Z
eej
dd��d	�����Zejd
���Zd�Zefd�Zed
���ZdS)�OveraRepresent an OVER clause.

    This is a special operator against a so-called
    "window" function, as well as any aggregate function,
    which produces results relative to the result set
    itself.  It's supported only by certain database
    backends.

    �overNc��||_|�(ttj|��dti�|_|�(ttj|��dti�|_|r9|�|��|_|rtj
d���d|_dS|r#|�|��|_d|_dSdx|_|_dS)aIProduce an :class:`.Over` object against a function.

        Used against aggregate or so-called "window" functions,
        for database backends that support window functions.

        :func:`_expression.over` is usually called using
        the :meth:`.FunctionElement.over` method, e.g.::

            func.row_number().over(order_by=mytable.c.some_column)

        Would produce::

            ROW_NUMBER() OVER(ORDER BY some_column)

        Ranges are also possible using the :paramref:`.expression.over.range_`
        and :paramref:`.expression.over.rows` parameters.  These
        mutually-exclusive parameters each accept a 2-tuple, which contains
        a combination of integers and None::

            func.row_number().over(
                order_by=my_table.c.some_column, range_=(None, 0))

        The above would produce::

            ROW_NUMBER() OVER(ORDER BY some_column
            RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)

        A value of ``None`` indicates "unbounded", a
        value of zero indicates "current row", and negative / positive
        integers indicate "preceding" and "following":

        * RANGE BETWEEN 5 PRECEDING AND 10 FOLLOWING::

            func.row_number().over(order_by='x', range_=(-5, 10))

        * ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW::

            func.row_number().over(order_by='x', rows=(None, 0))

        * RANGE BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING::

            func.row_number().over(order_by='x', range_=(-2, None))

        * RANGE BETWEEN 1 FOLLOWING AND 3 FOLLOWING::

            func.row_number().over(order_by='x', range_=(1, 3))

        .. versionadded:: 1.1 support for RANGE / ROWS within a window


        :param element: a :class:`.FunctionElement`, :class:`.WithinGroup`,
         or other compatible construct.
        :param partition_by: a column element or string, or a list
         of such, that will be used as the PARTITION BY clause
         of the OVER construct.
        :param order_by: a column element or string, or a list
         of such, that will be used as the ORDER BY clause
         of the OVER construct.
        :param range\_: optional range clause for the window.  This is a
         tuple value which can contain integer values or ``None``,
         and will render a RANGE BETWEEN PRECEDING / FOLLOWING clause.

         .. versionadded:: 1.1

        :param rows: optional rows clause for the window.  This is a tuple
         value which can contain integer values or None, and will render
         a ROWS BETWEEN PRECEDING / FOLLOWING clause.

         .. versionadded:: 1.1

        This function is also available from the :data:`~.expression.func`
        construct itself via the :meth:`.FunctionElement.over` method.

        .. seealso::

            :data:`.expression.func`

            :func:`_expression.within_group`

        Nr�z*'range_' and 'rows' are mutually exclusive)rr�r�to_listr[�order_by�partition_by�_interpret_range�range_rr��rows)rPrr�r�r�r�s      rrNz
Over.__init__q
s���f�����&���h�'�'��!<���D�M��#� *���l�+�+�!�!<�!�!�D��
�	+��/�/��7�7�D�K��
!��'�@����!��	�	�	�
�	+��-�-�d�3�3�D�I��D�K�K�K�&*�*�D�I����rc�P�|j|j|j|j|j|jffSr)rFrr�r�r�r�rTs r�
__reduce__zOver.__reduce__�
s0���~��L����M��K��I� 
�
�	
rc�N�t|t��rt|��dkrtjd���|d�t
}nc	t
|d��}|dkrt}n?#t$r2}tj
tjd��|���Yd}~nd}~wwxYw|d�t
}nc	t
|d��}|dkrt}n?#t$r2}tj
tjd��|���Yd}~nd}~wwxYw||fS)Nrz2-tuple expected for range/rowsrz(Integer or None expected for range valuer�r)rA�tupler�rr�r��intr��
ValueErrorrr�)rPr��lowerr��uppers     rr�zOver._interpret_range�
s����&�%�(�(�	G�C��K�K�1�,<�,<��#�$E�F�F�F��!�9��#�E�E�
*��F�1�I�����A�:�:�)�E����
�
�
����%�B���%(�	�������������
�����!�9��#�E�E�
*��F�1�I�����A�:�:�)�E����
�
�
����%�B���%(�	�������������
�����e�|�s0�A1�1
B-�;(B(�(B-�C$�$
D �.(D�D z1.1z�the :attr:`.Over.func` member of the :class:`.Over` class is deprecated and will be removed in a future release.  Please refer to the :attr:`.Over.element` attribute.c��|jS)zIthe element referred to by this :class:`.Over`
        clause.


        rHrTs r�funcz	Over.func
s���|�rc��|jjSrr�rTs rr*z	Over.types
���|� � rc�>�d�|j|j|jfD��S)Nc��g|]}|�|��Srr�rs  rr�z%Over.get_children.<locals>.<listcomp>!s%��
�
�
���}�
��}�}r�rr�r�r�s  rr�zOver.get_children s1��
�
��l�D�$5�t�}�E�
�
�
�	
rc��||jfi|��|_|j�||jfi|��|_|j�||jfi|��|_dSdSrr�r�s   rr�zOver._copy_internals'sr���u�T�\�0�0�R�0�0�����(� %��d�&7� >� >�2� >� >�D���=�$�!�E�$�-�6�6�2�6�6�D�M�M�M�%�$rc�p�ttjd�|j|j|jfD�����S)Nc� �g|]}|�|j��Srr�rs  rr�z&Over._from_objects.<locals>.<listcomp>2�'�������}��O�$�}�}r)r�r�r�rr�r�rTs rr�zOver._from_objects.sH����O���"�l�D�,=�t�}�M����
�
�
�	
rr�)r�r�r�r�r�r�r�rrNr�r�r�rr�r�r�r*r�rr�r�r�rrr�r�]
s���������N��H��L��G��LP�k+�k+�k+�k+�Z
�
�
�$�$�$�L��T�_�
�	?�����
���X��
��!�!���!�
�
�
�%+�7�7�7�7��	
�	
��X�	
�	
�	
rr�c�n�eZdZdZdZdZd�Zd
d�Zej	d���Z
d�Zefd�Z
ed	���ZdS)�WithinGroupaRepresent a WITHIN GROUP (ORDER BY) clause.

    This is a special operator against so-called
    "ordered set aggregate" and "hypothetical
    set aggregate" functions, including ``percentile_cont()``,
    ``rank()``, ``dense_rank()``, etc.

    It's supported only by certain database backends, such as PostgreSQL,
    Oracle and MS SQL Server.

    The :class:`.WithinGroup` construct extracts its type from the
    method :meth:`.FunctionElement.within_group_type`.  If this returns
    ``None``, the function's ``.type`` is used.

    �withingroupNc�l�||_|�*ttj|��dti�|_dSdS)a�Produce a :class:`.WithinGroup` object against a function.

        Used against so-called "ordered set aggregate" and "hypothetical
        set aggregate" functions, including :class:`.percentile_cont`,
        :class:`.rank`, :class:`.dense_rank`, etc.

        :func:`_expression.within_group` is usually called using
        the :meth:`.FunctionElement.within_group` method, e.g.::

            from sqlalchemy import within_group
            stmt = select([
                department.c.id,
                func.percentile_cont(0.5).within_group(
                    department.c.salary.desc()
                )
            ])

        The above statement would produce SQL similar to
        ``SELECT department.id, percentile_cont(0.5)
        WITHIN GROUP (ORDER BY department.salary DESC)``.

        :param element: a :class:`.FunctionElement` construct, typically
         generated by :data:`~.expression.func`.
        :param \*order_by: one or more column elements that will be used
         as the ORDER BY clause of the WITHIN GROUP construct.

        .. versionadded:: 1.1

        .. seealso::

            :data:`.expression.func`

            :func:`_expression.over`

        Nr�)rr�rr�r[r�)rPrr�s   rrNzWithinGroup.__init__PsD��H�����&���h�'�'��!<���D�M�M�M� �rc�*�t|||||���S)z�Produce an OVER clause against this :class:`.WithinGroup`
        construct.

        This function has the same signature as that of
        :meth:`.FunctionElement.over`.

        �r�r�r�r��r��rPr�r�r�r�s     rr�zWithinGroup.over{s*����%����
�
�
�	
rc�V�|j�|��}|�|S|jjSr)r�within_group_typer*)rP�wgts  rr*zWithinGroup.type�s,���l�,�,�T�2�2���?��J��<�$�$rc�2�d�|j|jfD��S)Nc��g|]}|�|��Srr�rs  rr�z,WithinGroup.get_children.<locals>.<listcomp>�s��J�J�J�a�A�M��M�M�Mr�rr�r�s  rr�zWithinGroup.get_children�s��J�J�D�L�$�-�8�J�J�J�Jrc�d�||jfi|��|_|j�||jfi|��|_dSdSrr�r�s   rr�zWithinGroup._copy_internals�sL���u�T�\�0�0�R�0�0����=�$�!�E�$�-�6�6�2�6�6�D�M�M�M�%�$rc�d�ttjd�|j|jfD�����S)Nc� �g|]}|�|j��Srr�rs  rr�z-WithinGroup._from_objects.<locals>.<listcomp>�r�r)r�r�r�rr�rTs rr�zWithinGroup._from_objects�sC����O���"�l�D�M�:����
�
�
�	
rr�)r�r�r�r�r�r�rNr�rr�r*r�rr�r�r�r�rrr�r�;s��������� #�N��H�)�)�)�V
�
�
�
� 
��%�%���%�K�K�K�%+�7�7�7�7�
�	
�	
��X�	
�	
�	
rr�c�|�eZdZdZdZdZd�Zd�Zdd�Zd
d�Z	e
jd���Zd	�Z
efd
�Zed���ZdS)�FunctionFiltera�Represent a function FILTER clause.

    This is a special operator against aggregate and window functions,
    which controls which rows are passed to it.
    It's supported only by certain database backends.

    Invocation of :class:`.FunctionFilter` is via
    :meth:`.FunctionElement.filter`::

        func.count(1).filter(True)

    .. versionadded:: 1.0.0

    .. seealso::

        :meth:`.FunctionElement.filter`

    �
funcfilterNc�(�||_|j|�dS)a�Produce a :class:`.FunctionFilter` object against a function.

        Used against aggregate and window functions,
        for database backends that support the "FILTER" clause.

        E.g.::

            from sqlalchemy import funcfilter
            funcfilter(func.count(1), MyClass.name == 'some name')

        Would produce "COUNT(1) FILTER (WHERE myclass.name = 'some name')".

        This function is also available from the :data:`~.expression.func`
        construct itself via the :meth:`.FunctionElement.filter` method.

        .. versionadded:: 1.0.0

        .. seealso::

            :meth:`.FunctionElement.filter`


        N)r��filter)rPr��	criterions   rrNzFunctionFilter.__init__�s ��0��	����Y����rc��t|��D]/}t|��}|j�|j|z|_�(||_�0|S)a
Produce an additional FILTER against the function.

        This method adds additional criteria to the initial criteria
        set up by :meth:`.FunctionElement.filter`.

        Multiple criteria are joined together at SQL render time
        via ``AND``.


        )r�r�r�)rPr�s  rr�zFunctionFilter.filter�sL���i���	+�	+�I�3�I�>�>�I��~�)�!%��)�!;����!*�����rc�*�t|||||���S)a�Produce an OVER clause against this filtered function.

        Used against aggregate or so-called "window" functions,
        for database backends that support window functions.

        The expression::

            func.rank().filter(MyClass.y > 5).over(order_by='x')

        is shorthand for::

            from sqlalchemy import over, funcfilter
            over(funcfilter(func.rank(), MyClass.y > 5), order_by='x')

        See :func:`_expression.over` for a full description.

        r�r�r�s     rr�zFunctionFilter.over�s*��$��%����
�
�
�	
rc�b�tjtj|��rt|��S|Sr)rr��	filter_opr�r�s  rr�zFunctionFilter.self_groups+���!�)�"5�w�?�?�	��D�>�>�!��Krc��|jjSr)r�r*rTs rr*zFunctionFilter.types���y�~�rc�2�d�|j|jfD��S)Nc��g|]}|�|��Srr�rs  rr�z/FunctionFilter.get_children.<locals>.<listcomp>s��H�H�H�a�!�-��-�-�-r�r�r�r�s  rr�zFunctionFilter.get_childrens��H�H�D�I�t�~�6�H�H�H�Hrc�d�||jfi|��|_|j�||jfi|��|_dSdSrr�r�s   rr�zFunctionFilter._copy_internalssL���E�$�)�*�*�r�*�*��	��>�%�"�U�4�>�8�8�R�8�8�D�N�N�N�&�%rc�d�ttjd�|j|jfD�����S)Nc� �g|]}|�|j��Srr�rs  rr�z0FunctionFilter._from_objects.<locals>.<listcomp>!r�r)r�r�r�r�r�rTs rr�zFunctionFilter._from_objectssC����O���"�i���8����
�
�
�	
rr�r)r�r�r�r�r�r�rNr�r�r�rr�r*r�rr�r�r�r�rrr�r��s���������&"�N��I� � � �6���,
�
�
�
�4����
�������I�I�I�%+�9�9�9�9�
�	
�	
��X�	
�	
�	
rr�c�*�eZdZdZdZdd�Zd�Zejd���Z	ejd���Z
ed���Zejd	���Z
ejd
���Zdd�Zd�Zd
�Zed���Zed���Zd�Zedfd�Zed���Zdd�ZdS)r-z�Represents a column label (AS).

    Represent a label, as typically applied to any column-level
    element using the ``AS`` sql keyword.

    r.Nc	��t|t��r|j|_t|t��r|j}t|t���|r||_|j|_n5t
dt|��t|dd��fz��|_|jx|_	x|_|_
||_||_|g|_
dS)a�Return a :class:`Label` object for the
        given :class:`_expression.ColumnElement`.

        A label changes the name of an element in the columns clause of a
        ``SELECT`` statement, typically via the ``AS`` SQL keyword.

        This functionality is more conveniently available via the
        :meth:`_expression.ColumnElement.label` method on
        :class:`_expression.ColumnElement`.

        :param name: label name

        :param obj: a :class:`_expression.ColumnElement`.

        r0rr1N)rAr-r5r8rrr2r�r�r<r6�_element�_typer)rPrrr%s    rrNzLabel.__init__4s���"�g�u�%�%�	1�")�.�D����%�(�(�	&��o�G���%�(�(�	&��	��D�I�"&�)�D���(���4���'�'�6�6�*J�*J�K�K���D�I�48�9�<���<�4�;�����
���
� �	��
�
�
rc�8�|j|j|j|jffSr)rFrrrrTs rr�zLabel.__reduce__Xs���~��	�4�=�$�*�E�E�Erc��|jjSrr�rTs rr:zLabel._is_implicitly_boolean[r�rc��|jjSr)rr9rTs rr9zLabel._allow_label_resolve_s
���|�0�0rc��|Srr�rTs rr�zLabel._order_by_label_elementcs���rc�`�tj|jpt|jdd����Sr�)rr&rr�rrTs rr*z
Label.typegs/���#��J�>�'�$�-���>�>�
�
�	
rc�L�|j�tj���Sr�)rr�r�as_rTs rrz
Label.elementms���}�'�'�	�
�'�>�>�>rc�D�|�|jj|���Sr�)�_apply_to_innerrr�r�s  rr�zLabel.self_groupqs ���#�#�D�M�$<�g�#�N�N�Nrc�@�|�|jj��Sr)r
rr�rTs rr�z
Label._negatets���#�#�D�M�$9�:�:�:rc�`�||i|��}||jurt|j||j���S|S)Nr$)rr-rr)rP�fnr�r�sub_elements     rr
zLabel._apply_to_innerws>���b�#�n��n�n���d�m�+�+����K�t�z�B�B�B�B��Krc��|jjSr)rr3rTs rr3zLabel.primary_key~s
���|�'�'rc��|jjSr)rr4rTs rr4zLabel.foreign_keys�s
���|�(�(rc��|jfSrrHr�s  rr�zLabel.get_children�rtrFc	�V�||jfi|��|_|j�dd��|j�dd��|r]tdt	|��t|jdd��fz��x|_|_|jx|_	x|_
|_dSdS)Nrr9r0rr1)rrHr\r2r�r�rrr8r<r5r6)rPrg�anonymize_labelsrs    rr�zLabel._copy_internals�s�����d�m�2�2�r�2�2��
��
���)�T�*�*�*��
���0�$�7�7�7��	A�.>���d�8�8�W�T�\�6�6�B�B�C�D�/�/�
�D�I��+�8<�y�@�D�H�@�t�{�T�_�_�_�	A�	Arc��|jjSrrprTs rr�zLabel._from_objects�rqrc��|j�||r|n|jd���}|j�|��|j�|j|_|S)NT)r�disallow_is_literal)rr rrr�rr*)rPrrr�es     rr zLabel._make_proxy�s`���L�$�$���,���4�9� $�
%�
�
��
	
�
���$�����:�!��Z�A�F��rr)r�r�r�r�r�rNr�rr�r:r9r�r�r*rr�r�r
r3r4r�rr�r�r r�rrr-r-*s����������N�""�""�""�""�HF�F�F�
��3�3���3�
��1�1���1�����X��
��
�
���
�

��?�?���?�O�O�O�O�;�;�;�����(�(��X�(��)�)��X�)����%+�U�	A�	A�	A�	A��*�*��X�*�	�	�	�	�	�	rr-c�(�eZdZdZdZdxZxZxZZdZ	e
j��Zdd�Z
d�Zd�Zd�Zeee��Zed	���Ze
jd
���Zed���Zed���Zed
���Zed���Zdd�Zdd�Z				dd�ZdS)ra�Represents a column expression from any textual string.

    The :class:`.ColumnClause`, a lightweight analogue to the
    :class:`_schema.Column` class, is typically invoked using the
    :func:`_expression.column` function, as in::

        from sqlalchemy import column

        id, name = column("id"), column("name")
        stmt = select([id, name]).select_from("user")

    The above statement would produce SQL like::

        SELECT id, name FROM user

    :class:`.ColumnClause` is the immediate superclass of the schema-specific
    :class:`_schema.Column` object.  While the :class:`_schema.Column`
    class has all the
    same capabilities as :class:`.ColumnClause`, the :class:`.ColumnClause`
    class is usable by itself in those cases where behavioral requirements
    are limited to simple SQL expression generation.  The object has none of
    the associations with schema-level metadata or with execution-time
    behavior that :class:`_schema.Column` does,
    so in that sense is a "lightweight"
    version of :class:`_schema.Column`.

    Full details on :class:`.ColumnClause` usage is at
    :func:`_expression.column`.

    .. seealso::

        :func:`_expression.column`

        :class:`_schema.Column`

    r^NFc�p�|x|_|_||_tj|��|_||_dS)a7
Produce a :class:`.ColumnClause` object.

        The :class:`.ColumnClause` is a lightweight analogue to the
        :class:`_schema.Column` class.  The :func:`_expression.column`
        function can
        be invoked with just a name alone, as in::

            from sqlalchemy import column

            id, name = column("id"), column("name")
            stmt = select([id, name]).select_from("user")

        The above statement would produce SQL like::

            SELECT id, name FROM user

        Once constructed, :func:`_expression.column`
        may be used like any other SQL
        expression element such as within :func:`_expression.select`
        constructs::

            from sqlalchemy.sql import column

            id, name = column("id"), column("name")
            stmt = select([id, name]).select_from("user")

        The text handled by :func:`_expression.column`
        is assumed to be handled
        like the name of a database column; if the string contains mixed case,
        special characters, or matches a known reserved word on the target
        backend, the column expression will render using the quoting
        behavior determined by the backend.  To produce a textual SQL
        expression that is rendered exactly without any quoting,
        use :func:`_expression.literal_column` instead,
        or pass ``True`` as the
        value of :paramref:`_expression.column.is_literal`.   Additionally,
        full SQL
        statements are best handled using the :func:`_expression.text`
        construct.

        :func:`_expression.column` can be used in a table-like
        fashion by combining it with the :func:`.table` function
        (which is the lightweight analogue to :class:`_schema.Table`
        ) to produce
        a working table construct with minimal boilerplate::

            from sqlalchemy import table, column, select

            user = table("user",
                    column("id"),
                    column("name"),
                    column("description"),
            )

            stmt = select([user.c.description]).where(user.c.name == 'wendy')

        A :func:`_expression.column` / :func:`.table`
        construct like that illustrated
        above can be created in an
        ad-hoc fashion and is not associated with any
        :class:`_schema.MetaData`, DDL, or events, unlike its
        :class:`_schema.Table` counterpart.

        .. versionchanged:: 1.0.0 :func:`_expression.column` can now
           be imported from the plain ``sqlalchemy`` namespace like any
           other SQL element.

        :param text: the text of the element.

        :param type: :class:`_types.TypeEngine` object which can associate
          this :class:`.ColumnClause` with a type.

        :param is_literal: if True, the :class:`.ColumnClause` is assumed to
          be an exact expression that will be delivered to the output with no
          quoting rules applied regardless of case sensitive settings. the
          :func:`_expression.literal_column()` function essentially invokes
          :func:`_expression.column` while passing ``is_literal=True``.

        .. seealso::

            :class:`_schema.Column`

            :func:`_expression.literal_column`

            :func:`.table`

            :func:`_expression.text`

            :ref:`sqlexpression_literal_column`

        N)r<r�tablerr&r*r")rPryr%r"rs     rrNzColumnClause.__init__�s7��x $�#���4�9� ��
��(��/�/��	�$����rc�r�|jsR|j�K|jjs?t|d��r/t	|t
��rZ|js|j�|jjr@t|d��r|j|jkpt|d��o|j|jkS|j�	|j��S)Nrrr5)
r"r�_textualr�rArrr5rrr�s  rrz%ColumnClause._compare_name_for_result3s����O�	@��z�!��z�"�"��5�+�.�.�"��5�,�/�/�	"��$�
"��{�*��{�+�+�
�E�6�*�*�F�t�y�E�J�/F����x�(�(�H�T�[�E�L�-H�
��?�/�/���?�?�?rc��|jdS�Nr)rHrTs r�
_get_tablezColumnClause._get_tableHs���}�W�%�%rc�N�|j�|��||jd<dSr)�_memoized_property�expire_instancerH)rPrs  r�
_set_tablezColumnClause._set_tableKs+����/�/��5�5�5�!&��
�g���rc��|j}|�|gSgSr�r)rP�ts  rr�zColumnClause._from_objectsQs���J���=��3�J��Irc�^�tjr|jS|j�dd��Sr�)rr�rr�rTs rr�zColumnClause.descriptionYs.���9�	A��9���9�#�#�G�-?�@�@�@rc�d�|j|jkr|�|j��S|jSr)r<r�
_gen_labelr5rTs rr6zColumnClause._key_label`s-���8�t�y� � ��?�?�4�8�,�,�,��;�rc�6�|�|j��Sr�r)rrTs rr5zColumnClause._labelgs�����t�y�)�)�)rc��|jduSrr%rTs rr7z,ColumnClause._render_label_in_columns_clauseks���z��%�%rc�:�|�|jd���S)NF)�
dedupe_on_keyr+rTs r�
_ddl_labelzColumnClause._ddl_labelos�����t�y���>�>�>rTc��|j}|jrdS|��/|j�r't|dd��r-|j�dd��dz|jzdz|z}n
|jdz|z}t|dd���8t|t��r
|j	|_	n]t||j	��}nGt|jdd���1t|t��rJ�t||jj	��}|r;||j
vr2|}d}||j
vr#|dzt|��z}|dz
}||j
v�#|}t|��S|S)N�schema�.r?rLr)
rr"�named_with_columnr�r1�replacerrArBrLrQr�r)rPrr.r&r.r5�counters       rr)zColumnClause._gen_labelssj���J���?�)	��4�
�]�q�2�]��q�(�D�)�)�
,���(�(��c�2�2�S�8�1�6�A�C�G�$�N�������t�+���t�W�d�+�+�7��e�[�1�1�;�"&�*�E�K�K�'��t�z�:�:�E�E�����$�/�/�;�&�e�[�9�9�9�9�9�#�E�1�6�<�8�8���
#��A�C�<�<�"�F��G� �A�C�-�-�!&���s�7�|�|�!;���1���!�A�C�-�-�#�E� ��'�'�'��Krc�@�t|j|||j|d���S)NT)r�r�r%r5)r7r<r*r�s    rr�zColumnClause._bind_param�s/����H��"*�"�i���

�
�
�	
rc�`�|o|jo|dup
||jk}|�|rt|p|j��n|p|j|j||���}|�|j|_|g|_|j�)|jj�	|j��|_|r||j
|j<|S)N)r%rr")r"rrUrr*r<rrNrrr)	rPrr�attachrrrr"rQs	         rr zColumnClause._make_proxy�s��� $�#�
���
�
���%��4�9�$�	�
���"�
%�M�$�+�$�)�,�,�,��#�$�)��)�"�!�

�
�
���<��H�A�E��V��
��"�.�'�4�<�@�@���G�G�A�N��	+�)*�J����&��r)NFN)Tr)NTFF)r�r�r�r�r��onupdater��server_default�server_onupdate�_is_multiparam_columnr�!group_expirable_memoized_propertyr!rNrrr#r�rr�r�r�r6r5r7r/r)r�r r�rrrr�s�������#�#�J�N�<@�@�H�@�w�@��/�!��?��?�A�A��_%�_%�_%�_%�B@�@�@�*&�&�&�'�'�'�
�H�Z��,�,�E�������
��A�A���A��������*�*���*��&�&���&��?�?��X�?�,�,�,�,�\
�
�
�
���!�!�
)�)�)�)�)�)rrc��eZdZdZd�ZdS)r(r,c��||_dSr)r,)rPr,s  rrNzCollationClause.__init__�s
��"����rN)r�r�r�r�rNr�rrr(r(�s(������ �N�#�#�#�#�#rr(c�P�eZdZdZej�ddi��Zd�ZdS)�_IdentifiedClause�
identifiedrmFc��||_dSr)�ident)rPrDs  rrNz_IdentifiedClause.__init__�s
����
�
�
rN)r�r�r�r�r
r�r"rNr�rrrArA�sI������!�N�#�6�<�<�	�u���������rrAc��eZdZdZdS)�SavepointClause�	savepointN�r�r�r�r�r�rrrFrF�s������ �N�N�NrrFc��eZdZdZdS)�RollbackToSavepointClause�rollback_to_savepointNrHr�rrrJrJ�s������,�N�N�NrrJc��eZdZdZdS)�ReleaseSavepointClause�release_savepointNrHr�rrrMrM�s������(�N�N�NrrMc�>��eZdZdZdZ�fd�Zd�Zd�Zd�Zd�Z	�xZ
S)rBa�Represent a SQL identifier combined with quoting preferences.

    :class:`.quoted_name` is a Python unicode/str subclass which
    represents a particular identifier name along with a
    ``quote`` flag.  This ``quote`` flag, when set to
    ``True`` or ``False``, overrides automatic quoting behavior
    for this identifier in order to either unconditionally quote
    or to not quote the name.  If left at its default of ``None``,
    quoting behavior is applied to the identifier on a per-backend basis
    based on an examination of the token itself.

    A :class:`.quoted_name` object with ``quote=True`` is also
    prevented from being modified in the case of a so-called
    "name normalize" option.  Certain database backends, such as
    Oracle, Firebird, and DB2 "normalize" case-insensitive names
    as uppercase.  The SQLAlchemy dialects for these backends
    convert from SQLAlchemy's lower-case-means-insensitive convention
    to the upper-case-means-insensitive conventions of those backends.
    The ``quote=True`` flag here will prevent this conversion from occurring
    to support an identifier that's quoted as all lower case against
    such a backend.

    The :class:`.quoted_name` object is normally created automatically
    when specifying the name for key schema constructs such as
    :class:`_schema.Table`, :class:`_schema.Column`, and others.
    The class can also be
    passed explicitly as the name to any function that receives a name which
    can be quoted.  Such as to use the :meth:`_engine.Engine.has_table`
    method with
    an unconditionally quoted name::

        from sqlalchemy import create_engine
        from sqlalchemy.sql import quoted_name

        engine = create_engine("oracle+cx_oracle://some_dsn")
        engine.has_table(quoted_name("some_table", True))

    The above logic will run the "has table" logic against the Oracle backend,
    passing the name exactly as ``"some_table"`` without converting to
    upper case.

    .. versionadded:: 0.9.0

    .. versionchanged:: 1.2 The :class:`.quoted_name` construct is now
       importable from ``sqlalchemy.sql``, in addition to the previous
       location of ``sqlalchemy.sql.elements``.

    )rLr�r�c���|�dSt||��r|�|j|kr|Stt|���||��}||_|Sr)rArLr�rBrG)r�r8rLrPrFs    �rrGzquoted_name.__new__)sb����=��4���s�
#�
#�	��M�U�[�E�1�1��L��[�#�&�&�.�.�s�E�:�:����
��rc�F�ttj|��|jffSr)rBr�	text_typerLrTs rr�zquoted_name.__reduce__:s���T�^�D�1�1�4�:�>�>�>rc�`�|jr|Stj|�����Sr)rLrrRr�rTs r�_memoized_method_lowerz"quoted_name._memoized_method_lower=�-���:�	0��K��>�$�'�'�-�-�/�/�/rc�`�|jr|Stj|�����Sr)rLrrRr�rTs r�_memoized_method_upperz"quoted_name._memoized_method_upperCrUrc���tjr<|�dd��}tjs|�d��}d|zSt�|��S)Nr�r�z'%s')r�py2kr��decoder�r�)rP�backslasheds  rr�zquoted_name.__repr__IsZ���9�	&��+�+�g�/A�B�B�K��9�
:�)�0�0��9�9���K�'�'��<�<��%�%�%r)r�r�r�r��	__slots__rGr�rTrWr�r<rSs@rrBrB�s��������/�/�b*�I������"?�?�?�0�0�0�0�0�0�&�&�&�&�&�&�&rrBc�4��eZdZdZdZd�fd�	Zd�Zd�Z�xZS)�_truncated_labelzVA unicode subclass used to identify symbolic "
    "names that may require truncation.r�Nc�z��t|d|��}tt|���|||��S)NrL)r�r�r^rG)r�r8rLrFs   �rrGz_truncated_label.__new__Ys7�����w��.�.���%�s�+�+�3�3�C���F�F�Frc�F�|jtj|��|jffSr)rFrrRrLrTs rr�z_truncated_label.__reduce__^s ���~���t� 4� 4�d�j�A�A�Arc��|Srr��rP�map_s  r�	apply_mapz_truncated_label.apply_mapar�rr)	r�r�r�r�r\rGr�rdr<rSs@rr^r^Ssu�������+�+��I�G�G�G�G�G�G�
B�B�B�������rr^c��eZdZdZdZdS)�convaMark a string indicating that a name has already been converted
    by a naming convention.

    This is a string subclass that indicates a name that should not be
    subject to any further naming conventions.

    E.g. when we create a :class:`.Constraint` using a naming convention
    as follows::

        m = MetaData(naming_convention={
            "ck": "ck_%(table_name)s_%(constraint_name)s"
        })
        t = Table('t', m, Column('x', Integer),
                        CheckConstraint('x > 5', name='x5'))

    The name of the above constraint will be rendered as ``"ck_t_x5"``.
    That is, the existing name ``x5`` is used in the naming convention as the
    ``constraint_name`` token.

    In some situations, such as in migration scripts, we may be rendering
    the above :class:`.CheckConstraint` with a name that's already been
    converted.  In order to make sure the name isn't double-modified, the
    new name is applied using the :func:`_schema.conv` marker.  We can
    use this explicitly as follows::


        m = MetaData(naming_convention={
            "ck": "ck_%(table_name)s_%(constraint_name)s"
        })
        t = Table('t', m, Column('x', Integer),
                        CheckConstraint('x > 5', name=conv('ck_t_x5')))

    Where above, the :func:`_schema.conv` marker indicates that the constraint
    name here is final, and the name will render as ``"ck_t_x5"`` and not
    ``"ck_t_ck_t_x5"``

    .. versionadded:: 0.9.4

    .. seealso::

        :ref:`constraint_naming_conventions`

    r�N)r�r�r�r�r\r�rrrfrfes ������*�*�X�I�I�Irrf�	NONE_NAMEc�(�eZdZdZdZd�Zd�Zd�ZdS)r2zDA unicode subclass used to identify anonymously
    generated names.r�c
��tttj�|tj|����|j����Sr�r2rBrrR�__add__rLr�s  rrkz_anonymous_label.__add__�sD������&�&�t�T�^�E�-B�-B�C�C�T�Z�
�
�
�
�	
rc	��tttj�tj|��|��|j����Srrjr�s  r�__radd__z_anonymous_label.__radd__�sD������&�&�t�~�e�'<�'<�d�C�C�T�Z�
�
�
�
�	
rc�J�|j�t||z|j��S||zSr)rLrBrbs  rrdz_anonymous_label.apply_map�s,���:�!��t�d�{�D�J�7�7�7��$�;�rN)r�r�r�r�r\rkrmrdr�rrr2r2�sR���������I�
�
�
�
�
�
�����rr2c�N�t|t��r|St|��S)z�Coerce the given value to :class:`._truncated_label`.

    Existing :class:`._truncated_label` and
    :class:`._anonymous_label` objects are passed
    unchanged.

    )rAr^)r8s rrr�s*���%�)�*�*�'�����&�&�&rc��t|tj��r|S	t|��S#t$rd|zcYSwxYw)Nzunprintable element %r)rArr�r��	ExceptionrHs r�_string_or_unprintablerr�sY���'�4�,�-�-�6���	6��w�<�<����	6�	6�	6�+�g�5�5�5�5�	6���s�-�?�?c�2�tjd�|D���S)z\Expand the given set of ClauseElements to be the set of all 'cloned'
    predecessors.

    c��g|]	}|j��
Sr�)rJrs  rr�z"_expand_cloned.<locals>.<listcomp>�s��=�=�=�q�Q�]�=�=�=r�r�r���elementss r�_expand_clonedrx�s ��
�?�=�=�H�=�=�=�>�>rc�2�tjd�|D���S)zXExpand tables into individual columns in the
    given list of column expressions.

    c��g|]	}|j��
Sr�)r�rs  rr�z%_select_iterables.<locals>.<listcomp>�s��B�B�B�A�Q�/�B�B�Brrurvs r�_select_iterablesr{�s ��
�?�B�B��B�B�B�C�Crc���tt|�����t|�����t�fd�|D����S)z�Return the intersection of sets a and b, counting
    any overlap between 'cloned' predecessors.

    The returned set is in terms of the entities present within 'a'.

    c3�P�K�|] }��|j���|V��!dSr�rrJ�r�elem�all_overlaps  �rrz'_cloned_intersection.<locals>.<genexpr>�sM��������k�6�6�t�7G�H�H��������r�r�rxr��ar�r�s  @r�_cloned_intersectionr��sh����n�Q�'�'�(�(�5�5�n�Q�6G�6G�H�H�K������������rc���tt|�����t|�����t�fd�|D����S)Nc3�P�K�|] }��|j���|V��!dSrr~rs  �rrz%_cloned_difference.<locals>.<genexpr>�sM��������+�":�":�4�;K�"L�"L��������rr�r�s  @r�_cloned_differencer��sf����n�Q�'�'�(�(�5�5�n�Q�6G�6G�H�H�K������������rzsqlalchemy.sql.functionsc�z�t|d��rt||j��r|�d��S|S)Nr)r�rA�FunctionElementr.)�	functionsrs  r�_labeledr��sF���7�F�#�#��z���*�(�(���}�}�T�"�"�"��rc�,�t|t��S)zITrue if ``col`` is an instance of
    :class:`_expression.ColumnElement`.)rArL)r�s r�
_is_columnr�s���c�=�)�)�)rc�\�tj��}t|id|ji��|S)z2Locate Column objects within the given expression.r^)rrWrrX)rAr�s  r�
_find_columnsr�s/���?���D��V�R�(�D�H�-�.�.�.��Krc��t|tj��r|St|d��r|���}	|jS#t$rYdSwxYw�N�__clause_element__)rArr�r�r�r<r�rHs r�_column_as_keyr�so���'�4�,�-�-�����w�,�-�-�/��,�,�.�.����{��������t�t����s�A	�	
A�Ac�N�t|d��r|���S|Sr�)r�r�rHs r�_clause_element_as_exprr�)s,���w�,�-�-���)�)�+�+�+��rc��t|tj��rt|��St	|d��r|���}t
|��Sr�)rArr�rOr�r�r�rHs rr[r[0sW���'�4�,�-�-�/�'��0�0�0�	��.�	/�	/�/��,�,�.�.���G�$�$�$rc��t|tj��rt|��St	|d��r|���}t|t��r|j�t|��St|��Sr�)
rArr�rOr�r�rLr�rEr�rHs r�&_literal_and_labels_as_label_referencer�:s����'�4�,�-�-�/�'��0�0�0�	��.�	/�	/�/��,�,�.�.��	�7�M�*�*�)��+�7���(�(�(���(�(�(rc� �t|��Sr)r�rHs rr�r�Js���G�$�$�$rc�j�t|t��r|St|d��r|���St|tj��r||��St|tjtf��rt|��Stj
dt|��z���)Nr�z=SQL expression object expected, got object of type %r instead)rArr�r�rr��NoneTyper
�_const_exprrr�r*)r�
text_fallbacks  r�_literal_asr�Ns����'�9�%�%�
���	��.�	/�	/�

��)�)�+�+�+�	�G�T�.�	/�	/�
��}�W�%�%�%�	�G�d�m�T�2�	3�	3�
��7�#�#�#���
��W�
�
�
&�
�
�	
rc�Z�|rt|t��St|t��Sr)r�rk�_no_text_coercion)r�allow_coercion_to_texts  rr�r�^s+���7��7�J�/�/�/��7�$5�6�6�6rc�,�t|t��Sr)r�rrHs r�_literal_as_columnr�es���w��-�-�-rc��t|��}t�|��}tjdtj|��|rdndd�z���)Nz�Textual column expression %(column)r should be explicitly declared with text(%(column)r), or use %(literal_column)s(%(column)r) for more specificityr#r^)r^r#)r��_guess_straight_column�matchrr�r�ellipses_string)r�guess_is_literals  r�_no_column_coercionr�isn���'�l�l�G�1�7�7��@�@�@��

�
�	�
�*�7�3�3���.�.��	
�
�			
���rc��tj|dtj|��|rd|zndd�z��|���dS)NzX%(extra)sTextual SQL expression %(expr)r should be explicitly declared as text(%(expr)r)z%s �)r-�extrar�)rr�r�)r�exc_clsr�r�s    rr�r�zso��	�K���
4��,�W�5�5�*/�7�����R���
�	
�	
��
�
�
�
�
�
rc��t|d��r|���St|t��st	jd|�d����|S)Nr�zAmbiguous literal: zl.  Use the 'text()' function to indicate a SQL expression literal, or 'literal()' to indicate a bound value.)r�r�rArrr�rHs rrr�sf���w�,�-�-�
��)�)�+�+�+�
���
+�
+�����&�g�g�
(�
�
�	
��rc�P�t|t��ot|d��Sr�)rArr�rHs r�_is_literalr��s3���'�9�-�-�-��g��%�7�7�3�rc�*�|�dSt||��Sr)�_only_column_elements�rrs  r�_only_column_elements_or_noner��s�����t�$�W�d�3�3�3rc
���t|d��r|���}t|t��s*t	jd|�d|�dt
|�������|S)Nr�z6Column-based expression object expected for argument 'z	'; got: 'z', type )r�r�rArLrr�r*r�s  rr�r��st���w�,�-�-�/��,�,�.�.���g�}�-�-�
����*.�$�$�����g����
H�
�
�	
��Nrc��t|d��r|���St|t��s#|�t	��St|||d���S|S)Nr�Tr4)r�r�rArr�r7)rrr%s   rr&r&�sc���w�,�-�-���)�)�+�+�+�
���
+�
+���?��6�6�M� ��w�e�D�I�I�I�I��rz^\w\S*$c��t|t��r|St|d��r|���St	j|d���}|�1t|tjtf��rt|��Snt|d��r|j
S|dkrd}nGt|tj��rtt|��d���St|��t||���S)Nr�F)�raiseerrr�*T)r")rArr�r�r�inspectrr�r
r�r�numbers�Numberrr�r�)r�inspr�s   r�_interpret_as_column_or_fromr��s���'�9�%�%�,���	��.�	/�	/�,��)�)�+�+�+���g��6�6�6�D��|��g��
�t�4�5�5�	(��w�'�'�'�	(�	��|�	$�	$������#�~�~����	�G�g�n�	.�	.�%��C��L�L�T�:�:�:�:��G�$�$�$���,<�=�=�=�=rc���t|tttf��r|S|�t��S|durt��S|durt��St	jd���)NFTzExpected None, False, or True)rAr�r�r�rr�rHs rr�r��sg���'�D�&�%�0�1�1�	A���	���v�v�
�	�E�	�	��x�x��	�D����w�w���� ?�@�@�@rc�N�|D]}|jjs	|jcS�tjSr)r*�_isnullrr�)�argsr�s  r�_type_from_argsr��s8��
�!�!���v�~�	��6�M�M�M�	�� � rc
��|�||���}|�2tjd|�dt|dd���d|j�d����|S)N)�require_embeddedzGiven column 'z', attached to table 'rz7', failed to locate a corresponding column from table '�')�corresponding_columnr�InvalidRequestErrorr�r�)�
fromclauser^r�rQs    r�_corresponding_column_or_errorr��sv���'�'��!1�	(�	�	�A�	�y��%�%��v�v�w�v�w��5�5�5�5�z�7M�7M�7M�
O�
�
�	
�

�Hrc����eZdZd�Z�fd�Zejd���Zejd���Zejd���Z	ejd���Z
ejd���Z�xZS)�AnnotatedColumnElementc���tj|||��tj�|��dD]7}|j�|d���|j�|���8dS)N)rr<rF)rrNrLrMrKrHrr\)rPrrar�s    rrNzAnnotatedColumnElement.__init__�sv����4��&�1�1�1�� �'�'��-�-�-�,�	(�	(�D��}� � ��u�-�-�5��
�!�!�$�'�'�'��	(�	(rc���tt|���|��}tj�|��|Sr)r�r�rerLrMrK)rPrargrFs   �rrez(AnnotatedColumnElement._with_annotationss=����,�d�3�3�E�E�f�M�M��� �'�'��.�.�.��rc��|jjS)z'Pull 'name' from parent, if not present)�_Annotated__elementrrTs rrzAnnotatedColumnElement.names���'�,�,rc��|jjS)z(Pull 'table' from parent, if not present)r�rrTs rrzAnnotatedColumnElement.tables���'�-�-rc��|jjS)z&Pull 'key' from parent, if not present)r�r<rTs rr<zAnnotatedColumnElement.keys���'�+�+rc��|jjSr)r��inforTs rr�zAnnotatedColumnElement.infos���'�,�,rc��|jjSr)r�rrTs rrz!AnnotatedColumnElement.anon_labels���'�2�2r)
r�r�r�rNrerr�rrr<r�rr<rSs@rr�r��s��������(�(�(������

��-�-���-�
��.�.���.�
��,�,���,�
��-�-���-�
��3�3���3�3�3�3�3rr�)Frr�)tr��
__future__rr�r�r�rCr�rr�
annotationr�baser	r
rrr
�visitorsrrrrrrrr"r)r0r9r=rB�_self_inspectsrD�ColumnOperatorsrLr7rfrkr�r�r�r�r�r�r�r�r
r#r)r/r;rErOr�ryr�r'r�r�r��symbolr�r�r�r�r�r-rr(rArFrJrM�
MemoizedSlotsrRrBr^rf�
_NONE_NAME�_generated_labelr2rrrrxr{r�r�r�r�r�r�r�r�r[r�r�r�r�r�r�r�r�rr�r�r�r&r��Ir�r�r�r�r�r�r�rr�<module>r�s�����
(�'�'�'�'�'�������������	�	�	�	�������������!�!�!�!�!�!�������������������������"�"�"�"�"�"�%�%�%�%�%�%����������������������������������������25G�5G�5G�5G�p@�@�@�@�,
P�
P�
P�
P�4�4�4���o�o�o�o�o�I�o�o���o�dA
�A
�A
�A
�A
�I�-�}�A
�A
�A
�HG
�G
�G
�G
�G
�M�G
�G
�G
�T
�
�
�
�
��
�
�
�iI�iI�iI�iI�iI��]�iI�iI�iI�X'�'�'�'�'�=�'�'�'�08)�8)�8)�8)�8)�]�8)�8)�8)�v?(�?(�?(�?(�?(�M�?(�?(�?(�DZ�Z�Z�Z�Z��Z�Z�Z�zB(�B(�B(�B(�B(�
�M�B(�B(�B(�J������5�5�5�5�5�J�
�5�5�5�pM
�M
�M
�M
�M
�=�M
�M
�M
�`!<�!<�!<�!<�H_)�_)�_)�_)�_)�=�_)�_)�_)�D{�{�{�{�{��{�{�{�|'�'�'�'�'�m�'�'�'�8�����}����45�5�5�5�5�}�5�5�5�q�q�q�q�q�m�q�q�q�h	[
�[
�[
�[
�[
�/�[
�[
�[
�|G�G�G�G�G��G�G�G�(d;�d;�d;�d;�d;�}�d;�d;�d;�N�����M����*	�	�	�	�	�&�	�	�	�6
�6
�6
�6
�6
�}�6
�6
�6
�r�$�+�/�0�0�����O�,�,�
�[
�[
�[
�[
�[
�=�[
�[
�[
�|j
�j
�j
�j
�j
�-�j
�j
�j
�Z
�
�
�
�
�]�
�
�
�Dw�w�w�w�w�M�w�w�w�tp�p�p�p�p�9�m�p�p�p�f	#�#�#�#�#�m�#�#�#������
�M����!�!�!�!�!�'�!�!�!�-�-�-�-�-� 1�-�-�-�)�)�)�)�)�.�)�)�)�[&�[&�[&�[&�[&�$�$�d�n�[&�[&�[&�|�����{����$-�-�-�-�-��-�-�-�`�T�[��
%�
%�
�D�$�������'����:'�'�'�6�6�6�?�?�?�D�D�D�
�
�
�������-�.�.���/�.��*�*�*����&������%�%�%�
)�
)�
)� %�%�%�

�

�

� 7�7�7�7�.�.�.����$�&�d��
�
�
�
� ������4�4�4����	�	�	�	�$���J���5�5��>�>�>�0
A�
A�
A�!�!�!�

�

�

�

�"3�"3�"3�"3�"3�Y�"3�"3�"3�"3�"3r

Hacked By AnonymousFox1.0, Coded By AnonymousFox