Hacked By AnonymousFox

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

�

�܋fT�����dZddlmZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZdd	l
mZdd
l
m
Z
ddl
mZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZejd��Zejdd��Z d�Z!d�Z"ej#Gd�d ee	j$����Z%Gd!�d"e
e%e��Z&Gd#�d$e
e%e��Z'Gd%�d&e
e%��Z(Gd'�d(e)��Z*Gd)�d*e*e%��Z+Gd+�d,e+��Z,Gd-�d.e)��Z-Gd/�d0e-e+��Z.ej#Gd1�d2e*e����Z/Gd3�d4e/��Z0ej1d5d6��Gd7�d8e0����Z2Gd9�d:e
e%��Z3d;�Z4d<�Z5Gd=�d>e)��Z6Gd?�d@e6e3��Z7GdA�dBe7��Z8GdC�dDe7��Z9GdE�dFe7��Z:GdG�dHe7��Z;GdI�dJe
e6e%��Z<ej=dKdLi��Z>GdM�dNe%��Z?GdO�dPe?��Z@GdQ�dRe)��ZAeAd��ZBeAjCZCGdS�dTe/e%��ZDdS)Ua/The schema module provides the building blocks for database metadata.

Each element within this module describes a database entity which can be
created and dropped, or is otherwise part of such an entity.  Examples include
tables, columns, sequences, and indexes.

All entities are subclasses of :class:`~sqlalchemy.schema.SchemaItem`, and as
defined in this module they are intended to be agnostic of any vendor-specific
constructs.

A collection of entities are grouped into a unit called
:class:`~sqlalchemy.schema.MetaData`. MetaData serves as a logical grouping of
schema elements, and can also be associated with an actual database connection
such that operations involving the contained elements can contact the database
as needed.

Two of the elements here also build upon their "syntactic" counterparts, which
are defined in :class:`~sqlalchemy.sql.expression.`, specifically
:class:`~sqlalchemy.schema.Table` and :class:`~sqlalchemy.schema.Column`.
Since these objects are part of the SQL expression language, they are usable
as components in SQL expressions.

�)�absolute_importN�)�ddl)�type_api)�visitors)�_bind_or_error)�ColumnCollection)�
DialectKWArgs)�SchemaEventTarget)�
_as_truncated)�_document_text_coercion)�_literal_as_text)�
ClauseElement)�ColumnClause)�
ColumnElement)�quoted_name)�
TextClause)�TableClause���event)�exc)�
inspection)�util�
retain_schema�blank_schemaz�Symbol indicating that a :class:`_schema.Table` or :class:`.Sequence`
    should have 'None' for its schema, even if the parent
    :class:`_schema.MetaData` has specified a schema.

    .. versionadded:: 1.0.14

    c��|�|S|dz|zS)N�.�)�name�schemas  �L/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/sql/schema.py�_get_table_keyr#Is��
�~�����|�d�"�"�c�J�������|S��fd�}tj|i|��S)Nc���t|t��r)|j�ur |j�jvr�j|jSdS�N)�
isinstance�Column�table�key�c)�col�source_table�target_tables ��r"�replacez!_copy_expression.<locals>.replaceVsE����s�F�#�#�	��	�\�)�)���<�>�)�)��>�#�'�*�*��4r$)r�replacement_traverse)�
expressionr.r/r0s `` r"�_copy_expressionr3RsJ������|�3����������(��R��A�A�Ar$c��eZdZdZdZd�Zd�Zd�Zee	j
dd��d�����Ze	jd	���Z
d
�Zd�ZdS)
�
SchemaItemz3Base class for items that define a database schema.�schema_itemc��|D]Z}|�V	|j}||���#t$r5}tjt	jd|z��|���Yd}~�Rd}~wwxYw�[dS)z7Initialize the list of child items for this SchemaItem.NzJ'SchemaItem' object, such as a 'Column' or a 'Constraint' expected, got %r)�replace_context)�_set_parent_with_dispatch�AttributeErrorr�raise_r�
ArgumentError)�self�args�item�spwd�errs     r"�_init_itemszSchemaItem._init_itemsis����
	�
	�D�����9�D��D��J�J�J�J��&�����K��)�<�>B�C���),������������������ �
	�
	s��
A�+A�Ac��gS)z"used to allow SchemaVisitor accessr�r=�kwargss  r"�get_childrenzSchemaItem.get_children{s���	r$c�0�tj|dg���S)N�info)�
omit_kwarg�r�generic_repr�r=s r"�__repr__zSchemaItem.__repr__s��� ��6�(�;�;�;�;r$�0.9z�The :attr:`.SchemaItem.quote` attribute is deprecated and will be removed in a future release.  Use the :attr:`.quoted_name.quote` attribute on the ``name`` field of the target schema item to retrievequoted status.c��|jjS)z�Return the value of the ``quote`` flag passed
        to this schema object, for those schema items which
        have a ``name`` field.

        )r �quoterLs r"rPzSchemaItem.quote�s���y��r$c��iS)aZInfo dictionary associated with the object, allowing user-defined
        data to be associated with this :class:`.SchemaItem`.

        The dictionary is automatically generated when first accessed.
        It can also be specified in the constructor of some objects,
        such as :class:`_schema.Table` and :class:`_schema.Column`.

        rrLs r"rHzSchemaItem.info�s	���	r$c��d|jvr|j���|_|j�|j��|S)NrH)�__dict__rH�copy�dispatch�_update)r=r6s  r"�_schema_item_copyzSchemaItem._schema_item_copy�sB���T�]�"�"�#�y�~�~�/�/�K����$�$�T�]�3�3�3��r$c�.�|�||��Sr')�get)r=�effective_schema�map_s   r"�_translate_schemazSchemaItem._translate_schema�s���x�x�(�*:�;�;�;r$N)�__name__�
__module__�__qualname__�__doc__�__visit_name__rBrFrM�propertyr�
deprecatedrP�memoized_propertyrHrWr\rr$r"r5r5cs�������=�=�"�N����$���<�<�<���T�_�
�	��������X��
��	�	���	����<�<�<�<�<r$r5c���eZdZdZdZejd���d���Zeej	dd��d�����Z
d	�Z�fd
�Z			d'd�Z
ed���Zed���Zd�Zd�Zd�Zd�Zed���Zed���Zd�Zd�Zed���Zd�Zd�Zd�Zej	dd��d���Zd �Z	d(d"�Zd)d#�Zd*d$�Z d*d%�Z!e"d
d
fd&�Z#�xZ$S)+�Tablea7Represent a table in a database.

    e.g.::

        mytable = Table("mytable", metadata,
                        Column('mytable_id', Integer, primary_key=True),
                        Column('value', String(50))
                   )

    The :class:`_schema.Table`
    object constructs a unique instance of itself based
    on its name and optional schema name within the given
    :class:`_schema.MetaData` object. Calling the :class:`_schema.Table`
    constructor with the same name and same :class:`_schema.MetaData` argument
    a second time will return the *same* :class:`_schema.Table`
    object - in this way
    the :class:`_schema.Table` constructor acts as a registry function.

    .. seealso::

        :ref:`metadata_describing` - Introduction to database metadata

    Constructor arguments are as follows:

    :param name: The name of this table as represented in the database.

        The table name, along with the value of the ``schema`` parameter,
        forms a key which uniquely identifies this :class:`_schema.Table`
        within
        the owning :class:`_schema.MetaData` collection.
        Additional calls to :class:`_schema.Table` with the same name,
        metadata,
        and schema name will return the same :class:`_schema.Table` object.

        Names which contain no upper case characters
        will be treated as case insensitive names, and will not be quoted
        unless they are a reserved word or contain special characters.
        A name with any number of upper case characters is considered
        to be case sensitive, and will be sent as quoted.

        To enable unconditional quoting for the table name, specify the flag
        ``quote=True`` to the constructor, or use the :class:`.quoted_name`
        construct to specify the name.

    :param metadata: a :class:`_schema.MetaData`
        object which will contain this
        table.  The metadata is used as a point of association of this table
        with other tables which are referenced via foreign key.  It also
        may be used to associate this table with a particular
        :class:`.Connectable`.

    :param \*args: Additional positional arguments are used primarily
        to add the list of :class:`_schema.Column`
        objects contained within this
        table. Similar to the style of a CREATE TABLE statement, other
        :class:`.SchemaItem` constructs may be added here, including
        :class:`.PrimaryKeyConstraint`, and
        :class:`_schema.ForeignKeyConstraint`.

    :param autoload: Defaults to False, unless
        :paramref:`_schema.Table.autoload_with`
        is set in which case it defaults to True; :class:`_schema.Column`
        objects
        for this table should be reflected from the database, possibly
        augmenting or replacing existing :class:`_schema.Column`
        objects that were
        explicitly specified.

        .. versionchanged:: 1.0.0 setting the
           :paramref:`_schema.Table.autoload_with`
           parameter implies that :paramref:`_schema.Table.autoload`
           will default
           to True.

        .. seealso::

            :ref:`metadata_reflection_toplevel`

    :param autoload_replace: Defaults to ``True``; when using
        :paramref:`_schema.Table.autoload`
        in conjunction with :paramref:`_schema.Table.extend_existing`,
        indicates
        that :class:`_schema.Column` objects present in the already-existing
        :class:`_schema.Table`
        object should be replaced with columns of the same
        name retrieved from the autoload process.   When ``False``, columns
        already present under existing names will be omitted from the
        reflection process.

        Note that this setting does not impact :class:`_schema.Column` objects
        specified programmatically within the call to :class:`_schema.Table`
        that
        also is autoloading; those :class:`_schema.Column` objects will always
        replace existing columns of the same name when
        :paramref:`_schema.Table.extend_existing` is ``True``.

        .. seealso::

            :paramref:`_schema.Table.autoload`

            :paramref:`_schema.Table.extend_existing`

    :param autoload_with: An :class:`_engine.Engine` or
        :class:`_engine.Connection` object
        with which this :class:`_schema.Table` object will be reflected; when
        set to a non-None value, it implies that
        :paramref:`_schema.Table.autoload`
        is ``True``.   If left unset, but :paramref:`_schema.Table.autoload`
        is
        explicitly set to ``True``, an autoload operation will attempt to
        proceed by locating an :class:`_engine.Engine` or
        :class:`_engine.Connection` bound
        to the underlying :class:`_schema.MetaData` object.

        .. seealso::

            :paramref:`_schema.Table.autoload`

    :param extend_existing: When ``True``, indicates that if this
        :class:`_schema.Table` is already present in the given
        :class:`_schema.MetaData`,
        apply further arguments within the constructor to the existing
        :class:`_schema.Table`.

        If :paramref:`_schema.Table.extend_existing` or
        :paramref:`_schema.Table.keep_existing` are not set,
        and the given name
        of the new :class:`_schema.Table` refers to a :class:`_schema.Table`
        that is
        already present in the target :class:`_schema.MetaData` collection,
        and
        this :class:`_schema.Table`
        specifies additional columns or other constructs
        or flags that modify the table's state, an
        error is raised.  The purpose of these two mutually-exclusive flags
        is to specify what action should be taken when a
        :class:`_schema.Table`
        is specified that matches an existing :class:`_schema.Table`,
        yet specifies
        additional constructs.

        :paramref:`_schema.Table.extend_existing`
        will also work in conjunction
        with :paramref:`_schema.Table.autoload` to run a new reflection
        operation against the database, even if a :class:`_schema.Table`
        of the same name is already present in the target
        :class:`_schema.MetaData`; newly reflected :class:`_schema.Column`
        objects
        and other options will be added into the state of the
        :class:`_schema.Table`, potentially overwriting existing columns
        and options of the same name.

        As is always the case with :paramref:`_schema.Table.autoload`,
        :class:`_schema.Column` objects can be specified in the same
        :class:`_schema.Table`
        constructor, which will take precedence.  Below, the existing
        table ``mytable`` will be augmented with :class:`_schema.Column`
        objects
        both reflected from the database, as well as the given
        :class:`_schema.Column`
        named "y"::

            Table("mytable", metadata,
                        Column('y', Integer),
                        extend_existing=True,
                        autoload=True,
                        autoload_with=engine
                    )

        .. seealso::

            :paramref:`_schema.Table.autoload`

            :paramref:`_schema.Table.autoload_replace`

            :paramref:`_schema.Table.keep_existing`


    :param implicit_returning: True by default - indicates that
        RETURNING can be used by default to fetch newly inserted primary key
        values, for backends which support this.  Note that
        :func:`_sa.create_engine` also provides an ``implicit_returning``
        flag.

    :param include_columns: A list of strings indicating a subset of
        columns to be loaded via the ``autoload`` operation; table columns who
        aren't present in this list will not be represented on the resulting
        ``Table`` object. Defaults to ``None`` which indicates all columns
        should be reflected.

    :param resolve_fks: Whether or not to reflect :class:`_schema.Table`
        objects
        related to this one via :class:`_schema.ForeignKey` objects, when
        :paramref:`_schema.Table.autoload` or
        :paramref:`_schema.Table.autoload_with` is
        specified.   Defaults to True.  Set to False to disable reflection of
        related tables as :class:`_schema.ForeignKey`
        objects are encountered; may be
        used either to save on SQL calls or to avoid issues with related tables
        that can't be accessed. Note that if a related table is already present
        in the :class:`_schema.MetaData` collection, or becomes present later,
        a
        :class:`_schema.ForeignKey` object associated with this
        :class:`_schema.Table` will
        resolve to that table normally.

        .. versionadded:: 1.3

        .. seealso::

            :paramref:`.MetaData.reflect.resolve_fks`


    :param info: Optional data dictionary which will be populated into the
        :attr:`.SchemaItem.info` attribute of this object.

    :param keep_existing: When ``True``, indicates that if this Table
        is already present in the given :class:`_schema.MetaData`, ignore
        further arguments within the constructor to the existing
        :class:`_schema.Table`, and return the :class:`_schema.Table`
        object as
        originally created. This is to allow a function that wishes
        to define a new :class:`_schema.Table` on first call, but on
        subsequent calls will return the same :class:`_schema.Table`,
        without any of the declarations (particularly constraints)
        being applied a second time.

        If :paramref:`_schema.Table.extend_existing` or
        :paramref:`_schema.Table.keep_existing` are not set,
        and the given name
        of the new :class:`_schema.Table` refers to a :class:`_schema.Table`
        that is
        already present in the target :class:`_schema.MetaData` collection,
        and
        this :class:`_schema.Table`
        specifies additional columns or other constructs
        or flags that modify the table's state, an
        error is raised.  The purpose of these two mutually-exclusive flags
        is to specify what action should be taken when a
        :class:`_schema.Table`
        is specified that matches an existing :class:`_schema.Table`,
        yet specifies
        additional constructs.

        .. seealso::

            :paramref:`_schema.Table.extend_existing`

    :param listeners: A list of tuples of the form ``(<eventname>, <fn>)``
        which will be passed to :func:`.event.listen` upon construction.
        This alternate hook to :func:`.event.listen` allows the establishment
        of a listener function specific to this :class:`_schema.Table` before
        the "autoload" process begins.  Particularly useful for
        the :meth:`.DDLEvents.column_reflect` event::

            def listen_for_reflect(table, column_info):
                "handle the column reflection event"
                # ...

            t = Table(
                'sometable',
                autoload=True,
                listeners=[
                    ('column_reflect', listen_for_reflect)
                ])

    :param mustexist: When ``True``, indicates that this Table must already
        be present in the given :class:`_schema.MetaData` collection, else
        an exception is raised.

    :param prefixes:
        A list of strings to insert after CREATE in the CREATE TABLE
        statement.  They will be separated by spaces.

    :param quote: Force quoting of this table's name on or off, corresponding
        to ``True`` or ``False``.  When left at its default of ``None``,
        the column identifier will be quoted according to whether the name is
        case sensitive (identifiers with at least one upper case character are
        treated as case sensitive), or if it's a reserved word.  This flag
        is only needed to force quoting of a reserved word which is not known
        by the SQLAlchemy dialect.

    :param quote_schema: same as 'quote' but applies to the schema identifier.

    :param schema: The schema name for this table, which is required if
        the table resides in a schema other than the default selected schema
        for the engine's database connection.  Defaults to ``None``.

        If the owning :class:`_schema.MetaData` of this :class:`_schema.Table`
        specifies its
        own :paramref:`_schema.MetaData.schema` parameter,
        then that schema name will
        be applied to this :class:`_schema.Table`
        if the schema parameter here is set
        to ``None``.  To set a blank schema name on a :class:`_schema.Table`
        that
        would otherwise use the schema set on the owning
        :class:`_schema.MetaData`,
        specify the special symbol :attr:`.BLANK_SCHEMA`.

        .. versionadded:: 1.0.14  Added the :attr:`.BLANK_SCHEMA` symbol to
           allow a :class:`_schema.Table`
           to have a blank schema name even when the
           parent :class:`_schema.MetaData` specifies
           :paramref:`_schema.MetaData.schema`.

        The quoting rules for the schema name are the same as those for the
        ``name`` parameter, in that quoting is applied for reserved words or
        case-sensitive names; to enable unconditional quoting for the schema
        name, specify the flag ``quote_schema=True`` to the constructor, or use
        the :class:`.quoted_name` construct to specify the name.

    :param useexisting: the same as :paramref:`_schema.Table.extend_existing`.

    :param comment: Optional string that will render an SQL comment on table
         creation.

         .. versionadded:: 1.2 Added the :paramref:`_schema.Table.comment`
            parameter
            to :class:`_schema.Table`.

    :param \**kw: Additional keyword arguments not mentioned above are
        dialect specific, and passed in the form ``<dialectname>_<argname>``.
        See the documentation regarding an individual dialect at
        :ref:`dialect_toplevel` for detail on documented arguments.

    r*)�0.7z�The :paramref:`_schema.Table.useexisting` parameter is deprecated and will be removed in a future release.  Please use :paramref:`_schema.Table.extend_existing`.)�useexistingc��|st�|��S	|d|d|dd�}}}n#t$rtd���wxYw|�dd��}|�|j}n|turd}|�dd��}|�dd��}d	|vr.|rd
}tj	|���|�d	d��}|r|rd}tj	|���|�dd��}	t||��}
|
|jvrH|s(|s&t|��rtj
d
|
z���|j|
}|r
|j|i|��|S|	rtj
d|
z���t�|��}|j�||��|�|||��	|j||g|�Ri|��|j�||��|S#t)j��5|�||��ddd��YdS#1swxYwYYdSxYw)Nrrrz$Table() takes at least two argumentsr!�
keep_existingF�extend_existingrhz/useexisting is synonymous with extend_existing.z9keep_existing and extend_existing are mutually exclusive.�	mustexistz�Table '%s' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.zTable '%s' not defined)�object�__new__�
IndexError�	TypeErrorrYr!�BLANK_SCHEMA�poprr<r#�tables�bool�InvalidRequestError�_init_existingrU�before_parent_attach�
_add_table�_init�after_parent_attachr�safe_reraise�
_remove_table)�clsr>�kwr �metadatar!rjrk�msgrlr+r*s            r"rnz
Table.__new__�s���	'��>�>�#�&�&�&�	D�#'��7�D��G�T�!�"�"�X�D�(�D�D���	D�	D�	D��B�C�C�C�	D��������$�'�'���>��_�F�F�
�|�
#�
#��F������6�6�
��&�&�!2�E�:�:���B����
-�G���'��,�,�,� �f�f�]�E�:�:�O��	)�_�	)�M�C��#�C�(�(�(��F�F�;��.�.�	��T�6�*�*���(�/�!�!� �
��
�T�$�Z�Z�
��-�-�03�	3�����O�C�(�E��
2�$��$�d�1�b�1�1�1��L��
P��-�.F�#�.N�O�O�O��N�N�3�'�'�E��N�/�/��x�@�@�@�����f�e�4�4�4�
9����D�(�8�T�8�8�8�R�8�8�8���2�2�5�(�C�C�C����
9��&�(�(�9�9��*�*�4��8�8�8�9�9�9�9�9�9�9�9�9�9�9�9�9����9�9�9�9�9�9�9���s9�9�A�.H�I
�H?�1I
�?I	�I
�I	�I
rNz�The :meth:`.SchemaItem.quote` method is deprecated and will be removed in a future release.  Use the :attr:`.quoted_name.quote` attribute on the ``schema`` field of the target schema item to retrieve quoted status.c��|jjS)zeReturn the value of the ``quote_schema`` flag passed
        to this :class:`_schema.Table`.
        )r!rPrLs r"�quote_schemazTable.quote_schema5s���{� � r$c��dS)z�Constructor for :class:`_schema.Table`.

        This method is a no-op.   See the top-level
        documentation for :class:`_schema.Table`
        for constructor arguments.

        Nr)r=r>r~s   r"�__init__zTable.__init__Ds���r$c	���tt|���t||�dd������||_|�dd��|_|j�
|j|_nF|jturd|_n0|�dd��}t|j|��|_t��|_	t��|_
t��|_td����|��t��|_t��|_|j�|j�d|j��|_n|j|_|�dd��}|�d|du��}|�d	d��|�d
d��}|�dd��}	|�dd��}
|�d
d��|_|�dd��|_d|vr|�d��|_d|vr3|�d��}|D]\}}
t-j|||
���|�dg��|_|jdi|��|r|�|||
||	���|j|�dS)NrPr!r�T)�_implicit_generatedr�
autoload_with�autoload�autoload_replace�
_extend_on�resolve_fks�include_columns�implicit_returning�commentrH�	listeners�prefixes)r�r�r)�superrfr�rrrrr!rq�set�indexes�constraintsr	�_columns�PrimaryKeyConstraintr9�foreign_keys�_extra_dependenciesr �fullnamer�r�rHr�listen�	_prefixes�
_extra_kwargs�	_autoloadrB)r=r rr>rEr�r�r�r�r�r�r��evt�fn�	__class__s              �r"ryzTable._initOs����
�e�T���#�#���f�j�j��$�7�7�8�8�	
�	
�	
�!��
��j�j��4�0�0����;��"�/�D�K�K�
�[�L�
(�
(��D�K�K�!�:�:�n�d�;�;�L�%�d�k�<�@�@�D�K��u�u����5�5���(�*�*��
�� $�	
�	
�	
�
#�
#�D�
)�
)�
)��E�E���#&�5�5�� ��;�"�'+�{�{�{�D�I�I�>�D�M�M� �I�D�M��
�
�?�D�9�9�
��:�:�j�-�t�*C�D�D���
�
�%�t�,�,�,��Z�Z��d�3�3�
��j�j���5�5�� �*�*�%6��=�=��"(�*�*�-A�4�"H�"H����z�z�)�T�2�2����V����
�
�6�*�*�D�I��&� � ��
�
�;�/�/�I�$�
,�
,���R���T�3��+�+�+�+����J��3�3������$�$�V�$�$�$�
�	��N�N����%�'�
�
�
�
�	���$����r$rTNc���|r'|�|jj|||||���dSt|d���}|�|jj|||||���dS)N�r�z�No engine is bound to this Table's MetaData. Pass an engine to the Table via autoload_with=<someengine>, or associate the MetaData with an engine via metadata.bind=<someengine>)r�)�run_callable�dialect�reflecttabler)r=rr�r��exclude_columnsr�r��binds        r"r�zTable._autoload�s����	��&�&��%�2�����%�

'�
�
�
�
�
�"��-����D�
�����)�����%�

�
�
�
�
�
r$c�0�t|jd����S)zTReturn the set of constraints as a list, sorted by creation
        order.

        c��|jSr')�_creation_order)r,s r"�<lambda>z+Table._sorted_constraints.<locals>.<lambda>�s	��a�6G�r$�r+)�sortedr�rLs r"�_sorted_constraintszTable._sorted_constraints�s���d�&�,G�,G�H�H�H�Hr$c�>�td�|jD����S)a:class:`_schema.ForeignKeyConstraint` objects referred to by this
        :class:`_schema.Table`.

        This list is produced from the collection of
        :class:`_schema.ForeignKey`
        objects currently associated.

        .. versionadded:: 1.0.0

        c3�$K�|]}|jV��dSr')�
constraint)�.0�fkcs  r"�	<genexpr>z0Table.foreign_key_constraints.<locals>.<genexpr>�s$����?�?�c�3�>�?�?�?�?�?�?r$)r�r�rLs r"�foreign_key_constraintszTable.foreign_key_constraints�s$���?�?�T�->�?�?�?�?�?�?r$c�@�|�dd��}|�d|du��}|�dd��}|�dd��}|�dd��}|r'||jkrtjd|j|f���|�dd��}|�d	d��}	|�-|jD]%}
|
j|vr|j�|
���&d
D]}||vrtjd����d|vr|�dd��|_d
|vr|�d
��|_	|r6|sd�|jD��}nd}|�
|j||||	|���|jdi|��|j
|�dS)Nr�r�r�Tr!r�z7Can't change schema of existing table from '%s' to '%s'r�r�)rPr�z2Can't redefine 'quote' or 'quote_schema' argumentsr�rHc��g|]	}|j��
Sr�r �r�r,s  r"�
<listcomp>z(Table._init_existing.<locals>.<listcomp>�s��":�":�":�a�1�6�":�":�":r$rr�)rrr!rr<r,r r��remover�rHr�rr�rB)
r=r>rEr�r�r�r!r�r�r�r,r+r�s
             r"rvzTable._init_existing�s���
�
�?�D�9�9�
��:�:�j�-�t�*C�D�D��!�:�:�&8�$�?�?�����H�d�+�+���Z�Z��d�3�3�
��	�f���+�+��#�I���f�%���
�
!�*�*�%6��=�=���j�j���5�5���&��V�
,�
,���6��0�0��M�(�(��+�+�+��,�	�	�C��f�}�}��'�H�����
����!�:�:�i��6�6�D�L��V����
�
�6�*�*�D�I��	�#�
%�#;�":�4�6�":�":�":���"$���N�N��
�����%�

�
�
�
�	���$�$�V�$�$�$����$����r$c�0�|�|��dSr'��_validate_dialect_kwargsrDs  r"r�zTable._extra_kwargs����%�%�f�-�-�-�-�-r$c��dSr'rrLs r"�_init_collectionszTable._init_collections����r$c��dSr'rrLs r"�_reset_exportedzTable._reset_exported
r�r$c��|jjSr')�primary_key�_autoincrement_columnrLs r"r�zTable._autoincrement_column
s����5�5r$c�6�t|j|j��S)a�Return the 'key' for this :class:`_schema.Table`.

        This value is used as the dictionary key within the
        :attr:`_schema.MetaData.tables` collection.   It is typically the same
        as that of :attr:`_schema.Table.name` for a table with no
        :attr:`_schema.Table.schema`
        set; otherwise it is typically of the form
        ``schemaname.tablename``.

        )r#r r!rLs r"r+z	Table.keys���d�i���5�5�5r$c����dd�t�j��gt�j��gzd��jD��z�fd�dD��z��zS)Nz	Table(%s)�, c�,�g|]}t|����Sr��repr�r��xs  r"r�z"Table.__repr__.<locals>.<listcomp>#s��-�-�-�1�t�A�w�w�-�-�-r$c
�T��g|]$}|�dtt�|��������%S��=�r��getattr�r��kr=s  �r"r�z"Table.__repr__.<locals>.<listcomp>$s7���I�I�I��!�!�!�T�'�$��"2�"2�3�3�3�4�I�I�Ir$�r!)�joinr�r r�columnsrLs`r"rMzTable.__repr__s{����T�Y�Y�
�$�)�_�_���D�M�"�"�#�
$�-�-���-�-�-�
.�J�I�I�I�j�I�I�I�
J�
�
�
�	
r$c�6�t|j|j��Sr')r#�descriptionr!rLs r"�__str__z
Table.__str__'s���d�.���<�<�<r$c�,�|jr|jjpdS)z2Return the connectable associated with this Table.N�rr�rLs r"r�z
Table.bind*s���}�3���!3�;�t�;r$c�:�|j�|��dS)a�Add a 'dependency' for this Table.

        This is another Table object which must be created
        first before this one can, or dropped after this one.

        Usually, dependencies between tables are determined via
        ForeignKey objects.   However, for other situations that
        create dependencies outside of foreign keys (rules, inheriting),
        this method can manually establish such a link.

        N)r��add�r=r*s  r"�add_is_dependent_onzTable.add_is_dependent_on0s!��	
� �$�$�U�+�+�+�+�+r$c�0�|�|��dS)auAppend a :class:`_schema.Column` to this :class:`_schema.Table`.

        The "key" of the newly added :class:`_schema.Column`, i.e. the
        value of its ``.key`` attribute, will then be available
        in the ``.c`` collection of this :class:`_schema.Table`, and the
        column definition will be included in any CREATE TABLE, SELECT,
        UPDATE, etc. statements generated from this :class:`_schema.Table`
        construct.

        Note that this does **not** change the definition of the table
        as it exists within any underlying database, assuming that
        table has already been created in the database.   Relational
        databases support the addition of columns to existing tables
        using the SQL ALTER command, which would need to be
        emitted for an already-existing table that doesn't contain
        the newly added column.

        N�r9�r=�columns  r"�
append_columnzTable.append_column>s��(	�(�(��.�.�.�.�.r$c�0�|�|��dS)a�Append a :class:`_schema.Constraint` to this
        :class:`_schema.Table`.

        This has the effect of the constraint being included in any
        future CREATE TABLE statement, assuming specific DDL creation
        events have not been associated with the given
        :class:`_schema.Constraint` object.

        Note that this does **not** produce the constraint within the
        relational database automatically, for a table that already exists
        in the database.   To add a constraint to an
        existing relational database table, the SQL ALTER command must
        be used.  SQLAlchemy also provides the
        :class:`.AddConstraint` construct which can produce this SQL when
        invoked as an executable clause.

        Nr�)r=r�s  r"�append_constraintzTable.append_constraintTs��&	�,�,�T�2�2�2�2�2r$rgz�the :meth:`_schema.Table.append_ddl_listener` method is deprecated and will be removed in a future release.  Please refer to :class:`.DDLEvents`.c�p�����fd�}tj|d��dd��z|��dS)z.Append a DDL event listener to this ``Table``.c�"����||��dSr'r)�target�
connectionr~�
event_name�listeners   ��r"�adapt_listenerz1Table.append_ddl_listener.<locals>.adapt_listenerss����H�Z���4�4�4�4�4r$��-�_N�rr�r0�r=r�r�r�s `` r"�append_ddl_listenerzTable.append_ddl_listenerisS����	5�	5�	5�	5�	5�	5�	��T�2�
� 2� 2�3�� <� <�<�n�M�M�M�M�Mr$c�V�|�|j|j|��||_dSr')rxr r!r�r=rs  r"�_set_parentzTable._set_parentxs)�����D�I�t�{�D�9�9�9� ��
�
�
r$Fc�^�|stj|fd|i|��S|rt|j��SgS)N�column_collections)rrF�listr�)r=r��schema_visitorr~s    r"rFzTable.get_children|sX���	��+����);��?A���
�"�
��D�L�)�)�)��	r$c�|�|�t|��}|�|jj|j|j���S)z!Return True if this table exists.Nr�)rr�r��	has_tabler r!�r=r�s  r"�existszTable.exists�sC���<�!�$�'�'�D�� � ��L�"�D�I�d�k�!�
�
�	
r$c�l�|�t|��}|�tj||���dS)z�Issue a ``CREATE`` statement for this
        :class:`_schema.Table`, using the given :class:`.Connectable`
        for connectivity.

        .. seealso::

            :meth:`_schema.MetaData.create_all`.

        N��
checkfirst�r�_run_visitorr�SchemaGenerator�r=r�rs   r"�createzTable.create�s:���<�!�$�'�'�D����#�-�t�
��K�K�K�K�Kr$c�l�|�t|��}|�tj||���dS)z�Issue a ``DROP`` statement for this
        :class:`_schema.Table`, using the given :class:`.Connectable`
        for connectivity.

        .. seealso::

            :meth:`_schema.MetaData.drop_all`.

        Nr�rrr�
SchemaDropperrs   r"�dropz
Table.drop�s:���<�!�$�'�'�D����#�+�T�j��I�I�I�I�Ir$c����|��j}|tur�j}n	|�|j}t||��}||jvr)tjd�jz��|j|Sg}�jD]+}|�	|�
|������,t||g|�R|�jd��j
����jD]�}t|t ��rR|j}|r|�|||��}	n|�jkr|nd}	��|�
|	�������i|js2|jr�x��|�
|���������jD]>}
|
jr�
t-|
jg��fd�|
jD���R|
j�d�|
j
���?�����S)a�
Return a copy of this :class:`_schema.Table`
        associated with a different
        :class:`_schema.MetaData`.

        E.g.::

            m1 = MetaData()

            user = Table('user', m1, Column('id', Integer, primary_key=True))

            m2 = MetaData()
            user_copy = user.tometadata(m2)

        :param metadata: Target :class:`_schema.MetaData` object,
         into which the
         new :class:`_schema.Table` object will be created.

        :param schema: optional string name indicating the target schema.
         Defaults to the special symbol :attr:`.RETAIN_SCHEMA` which indicates
         that no change to the schema name should be made in the new
         :class:`_schema.Table`.  If set to a string name, the new
         :class:`_schema.Table`
         will have this new name as the ``.schema``.  If set to ``None``, the
         schema will be set to that of the schema set on the target
         :class:`_schema.MetaData`, which is typically ``None`` as well,
         unless
         set explicitly::

            m2 = MetaData(schema='newschema')

            # user_copy_one will have "newschema" as the schema name
            user_copy_one = user.tometadata(m2, schema=None)

            m3 = MetaData()  # schema defaults to None

            # user_copy_two will have None as the schema name
            user_copy_two = user.tometadata(m3, schema=None)

        :param referred_schema_fn: optional callable which can be supplied
         in order to provide for the schema name that should be assigned
         to the referenced table of a :class:`_schema.ForeignKeyConstraint`.
         The callable accepts this parent :class:`_schema.Table`, the
         target schema that we are changing to, the
         :class:`_schema.ForeignKeyConstraint` object, and the existing
         "target schema" of that constraint.  The function should return the
         string schema name that should be applied.
         E.g.::

                def referred_schema_fn(table, to_schema,
                                                constraint, referred_schema):
                    if referred_schema == 'base_tables':
                        return referred_schema
                    else:
                        return to_schema

                new_table = table.tometadata(m2, schema="alt_schema",
                                        referred_schema_fn=referred_schema_fn)

         .. versionadded:: 0.9.2

        :param name: optional string name indicating the target table name.
         If not specified or None, the table name is retained.  This allows
         a :class:`_schema.Table` to be copied to the same
         :class:`_schema.MetaData` target
         with a new name.

         .. versionadded:: 1.0.0

        NzBTable '%s' already exists within the given MetaData - not copying.r�)r!r�)r!r/c�2��g|]}t|������Sr)r3)r��exprr=r*s  ��r"r�z$Table.tometadata.<locals>.<listcomp>4s5�������%�T�4��7�7���r$)�unique�_table)r �
RETAIN_SCHEMAr!r#rsr�warnr�r��appendrTrfr�rEr�r(�ForeignKeyConstraint�_referred_schemar��_type_bound�_column_flagr��Index�expressionsrrW)r=rr!�referred_schema_fnr r+r>r,�referred_schema�fk_constraint_schema�indexr*s`          @r"�
tometadatazTable.tometadata�s�����X�<��9�D��]�"�"��[�F�F�
�^��_�F��T�6�*�*���(�/�!�!��I�*�,0�,<�=�
�
�
��?�3�'�'�����	/�	/�A��K�K����f��-�-�.�.�.�.����
�
�
�
���L�	
�
��k�

�
���!�	�	�A��!�1�2�2�
�"#�"4��%��+=�+=��f�a��,�,�(�(�
#2�T�[�"@�"@���d�)��'�'��F�F�"6�U�F�K�K������]�
��>����'�'��F�F�&�u�F�=�=������\�	�	�E��!�
����
�	
������ %� 1����	
�	
��|�
�	
�	
��,�	
�	
�	
�	
��%�%�e�,�,�,r$)rTN)TFr'�NF)%r]r^r_r`rar�deprecated_paramsrnrbrcr�r�ryr�r�r�rvr�r�r�r�r+rMr�r�r�r�r�r�r�rFrr	r
rr �
__classcell__�r�s@r"rfrf�s��������F�F�P
�N��T��
����69�69���69�p��T�_�
�	"���!�!����X�!����B �B �B �B �B �R���#�#�#�#�J�I�I��X�I��@�@��X�@�4 �4 �4 �l.�.�.�
�
�
�
�
�
��6�6��X�6��6�6��X�6�
�
�
�=�=�=��<�<��X�<�
,�,�,�/�/�/�,3�3�3�*�T�_�
�	���N�N���N�!�!�!�
7<�����
�
�
�
�
L�
L�
L�
L�J�J�J�J�"��
�K-�K-�K-�K-�K-�K-�K-�K-r$rfc�n��eZdZdZdZ�fd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Z	dd�Zdd�Z�xZS)r)z(Represents a column in a database table.r�c�
��|�dd��}|�dd��}t|��}|rKt|dtj��r+|�tjd���|�d��}|rC|d}t|d��r+|�tjd���|�d��}|�%t||�dd����}nd|vrtjd	���tt|���||��|�d
|��|_|�dd��|_
|�d
|j
��|_|�dd��|_|�dd��|_|�dd��|_|�dd��|_|�dd��|_|�dd��|_|�dd��|_|�dd��|_|�dd��|_t1��|_t1��|_|�dd��|_d|_d|vr|�d��|_n4t|jt>��r|j� |��|j��t|jtBtDf��r|�#|j��n�tI|jdd��rDt|jtj%��r%tj&d|j�d|j�d���|�#tC|j����|j�ot|jtN��r.|�#|j�(d����n'|�#tS|j����|j�et|jtBtDf��r|�#|j��n)|�#tC|jd�����|j�qt|jtN��r.|�#|j�(d����n)|�#tS|jd�����|j*|�tj+|��d |vr|�d ��|_,|j-d!i|��dS)"aI
        Construct a new ``Column`` object.

        :param name: The name of this column as represented in the database.
          This argument may be the first positional argument, or specified
          via keyword.

          Names which contain no upper case characters
          will be treated as case insensitive names, and will not be quoted
          unless they are a reserved word.  Names with any number of upper
          case characters will be quoted and sent exactly.  Note that this
          behavior applies even for databases which standardize upper
          case names as case insensitive such as Oracle.

          The name field may be omitted at construction time and applied
          later, at any time before the Column is associated with a
          :class:`_schema.Table`.  This is to support convenient
          usage within the :mod:`~sqlalchemy.ext.declarative` extension.

        :param type\_: The column's type, indicated using an instance which
          subclasses :class:`~sqlalchemy.types.TypeEngine`.  If no arguments
          are required for the type, the class of the type can be sent
          as well, e.g.::

            # use a type with arguments
            Column('data', String(50))

            # use no arguments
            Column('level', Integer)

          The ``type`` argument may be the second positional argument
          or specified by keyword.

          If the ``type`` is ``None`` or is omitted, it will first default to
          the special type :class:`.NullType`.  If and when this
          :class:`_schema.Column` is made to refer to another column using
          :class:`_schema.ForeignKey` and/or
          :class:`_schema.ForeignKeyConstraint`, the type
          of the remote-referenced column will be copied to this column as
          well, at the moment that the foreign key is resolved against that
          remote :class:`_schema.Column` object.

          .. versionchanged:: 0.9.0
            Support for propagation of type to a :class:`_schema.Column`
            from its
            :class:`_schema.ForeignKey` object has been improved and should be
            more reliable and timely.

        :param \*args: Additional positional arguments include various
          :class:`.SchemaItem` derived constructs which will be applied
          as options to the column.  These include instances of
          :class:`.Constraint`, :class:`_schema.ForeignKey`,
          :class:`.ColumnDefault`,
          :class:`.Sequence`, :class:`.Computed`.  In some cases an
          equivalent keyword argument is available such as ``server_default``,
          ``default`` and ``unique``.

        :param autoincrement: Set up "auto increment" semantics for an integer
          primary key column.  The default value is the string ``"auto"``
          which indicates that a single-column primary key that is of
          an INTEGER type with no stated client-side or python-side defaults
          should receive auto increment semantics automatically;
          all other varieties of primary key columns will not.  This
          includes that :term:`DDL` such as PostgreSQL SERIAL or MySQL
          AUTO_INCREMENT will be emitted for this column during a table
          create, as well as that the column is assumed to generate new
          integer primary key values when an INSERT statement invokes which
          will be retrieved by the dialect.

          The flag may be set to ``True`` to indicate that a column which
          is part of a composite (e.g. multi-column) primary key should
          have autoincrement semantics, though note that only one column
          within a primary key may have this setting.    It can also
          be set to ``True`` to indicate autoincrement semantics on a
          column that has a client-side or server-side default configured,
          however note that not all dialects can accommodate all styles
          of default as an "autoincrement".  It can also be
          set to ``False`` on a single-column primary key that has a
          datatype of INTEGER in order to disable auto increment semantics
          for that column.

          .. versionchanged:: 1.1 The autoincrement flag now defaults to
             ``"auto"`` which indicates autoincrement semantics by default
             for single-column integer primary keys only; for composite
             (multi-column) primary keys, autoincrement is never implicitly
             enabled; as always, ``autoincrement=True`` will allow for
             at most one of those columns to be an "autoincrement" column.
             ``autoincrement=True`` may also be set on a
             :class:`_schema.Column`
             that has an explicit client-side or server-side default,
             subject to limitations of the backend database and dialect.


          The setting *only* has an effect for columns which are:

          * Integer derived (i.e. INT, SMALLINT, BIGINT).

          * Part of the primary key

          * Not referring to another column via :class:`_schema.ForeignKey`,
            unless
            the value is specified as ``'ignore_fk'``::

                # turn on autoincrement for this column despite
                # the ForeignKey()
                Column('id', ForeignKey('other.id'),
                            primary_key=True, autoincrement='ignore_fk')

            It is typically not desirable to have "autoincrement" enabled on a
            column that refers to another via foreign key, as such a column is
            required to refer to a value that originates from elsewhere.

          The setting has these two effects on columns that meet the
          above criteria:

          * DDL issued for the column will include database-specific
            keywords intended to signify this column as an
            "autoincrement" column, such as AUTO INCREMENT on MySQL,
            SERIAL on PostgreSQL, and IDENTITY on MS-SQL.  It does
            *not* issue AUTOINCREMENT for SQLite since this is a
            special SQLite flag that is not required for autoincrementing
            behavior.

            .. seealso::

                :ref:`sqlite_autoincrement`

          * The column will be considered to be available using an
            "autoincrement" method specific to the backend database, such
            as calling upon ``cursor.lastrowid``, using RETURNING in an
            INSERT statement to get at a sequence-generated value, or using
            special functions such as "SELECT scope_identity()".
            These methods are highly specific to the DBAPIs and databases in
            use and vary greatly, so care should be taken when associating
            ``autoincrement=True`` with a custom default generation function.


        :param default: A scalar, Python callable, or
            :class:`_expression.ColumnElement` expression representing the
            *default value* for this column, which will be invoked upon insert
            if this column is otherwise not specified in the VALUES clause of
            the insert. This is a shortcut to using :class:`.ColumnDefault` as
            a positional argument; see that class for full detail on the
            structure of the argument.

            Contrast this argument to
            :paramref:`_schema.Column.server_default`
            which creates a default generator on the database side.

            .. seealso::

                :ref:`metadata_defaults_toplevel`

        :param doc: optional String that can be used by the ORM or similar
            to document attributes on the Python side.   This attribute does
            **not** render SQL comments; use the
            :paramref:`_schema.Column.comment`
            parameter for this purpose.

        :param key: An optional string identifier which will identify this
            ``Column`` object on the :class:`_schema.Table`.
            When a key is provided,
            this is the only identifier referencing the ``Column`` within the
            application, including ORM attribute mapping; the ``name`` field
            is used only when rendering SQL.

        :param index: When ``True``, indicates that a :class:`_schema.Index`
            construct will be automatically generated for this
            :class:`_schema.Column`, which will result in a "CREATE INDEX"
            statement being emitted for the :class:`_schema.Table` when the DDL
            create operation is invoked.

            Using this flag is equivalent to making use of the
            :class:`_schema.Index` construct explicitly at the level of the
            :class:`_schema.Table` construct itself::

                Table(
                    "some_table",
                    metadata,
                    Column("x", Integer),
                    Index("ix_some_table_x", "x")
                )

            To add the :paramref:`_schema.Index.unique` flag to the
            :class:`_schema.Index`, set both the
            :paramref:`_schema.Column.unique` and
            :paramref:`_schema.Column.index` flags to True simultaneously,
            which will have the effect of rendering the "CREATE UNIQUE INDEX"
            DDL instruction instead of "CREATE INDEX".

            The name of the index is generated using the
            :ref:`default naming convention <constraint_default_naming_convention>`
            which for the :class:`_schema.Index` construct is of the form
            ``ix_<tablename>_<columnname>``.

            As this flag is intended only as a convenience for the common case
            of adding a single-column, default configured index to a table
            definition, explicit use of the :class:`_schema.Index` construct
            should be preferred for most use cases, including composite indexes
            that encompass more than one column, indexes with SQL expressions
            or ordering, backend-specific index configuration options, and
            indexes that use a specific name.

            .. note:: the :attr:`_schema.Column.index` attribute on
               :class:`_schema.Column`
               **does not indicate** if this column is indexed or not, only
               if this flag was explicitly set here.  To view indexes on
               a column, view the :attr:`_schema.Table.indexes` collection
               or use :meth:`_reflection.Inspector.get_indexes`.

            .. seealso::

                :ref:`schema_indexes`

                :ref:`constraint_naming_conventions`

                :paramref:`_schema.Column.unique`

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

        :param nullable: When set to ``False``, will cause the "NOT NULL"
            phrase to be added when generating DDL for the column.   When
            ``True``, will normally generate nothing (in SQL this defaults to
            "NULL"), except in some very specific backend-specific edge cases
            where "NULL" may render explicitly.   Defaults to ``True`` unless
            :paramref:`_schema.Column.primary_key` is also ``True``,
            in which case it
            defaults to ``False``.  This parameter is only used when issuing
            CREATE TABLE statements.

        :param onupdate: A scalar, Python callable, or
            :class:`~sqlalchemy.sql.expression.ClauseElement` representing a
            default value to be applied to the column within UPDATE
            statements, which will be invoked upon update if this column is not
            present in the SET clause of the update. This is a shortcut to
            using :class:`.ColumnDefault` as a positional argument with
            ``for_update=True``.

            .. seealso::

                :ref:`metadata_defaults` - complete discussion of onupdate

        :param primary_key: If ``True``, marks this column as a primary key
            column. Multiple columns can have this flag set to specify
            composite primary keys. As an alternative, the primary key of a
            :class:`_schema.Table` can be specified via an explicit
            :class:`.PrimaryKeyConstraint` object.

        :param server_default: A :class:`.FetchedValue` instance, str, Unicode
            or :func:`~sqlalchemy.sql.expression.text` construct representing
            the DDL DEFAULT value for the column.

            String types will be emitted as-is, surrounded by single quotes::

                Column('x', Text, server_default="val")

                x TEXT DEFAULT 'val'

            A :func:`~sqlalchemy.sql.expression.text` expression will be
            rendered as-is, without quotes::

                Column('y', DateTime, server_default=text('NOW()'))

                y DATETIME DEFAULT NOW()

            Strings and text() will be converted into a
            :class:`.DefaultClause` object upon initialization.

            Use :class:`.FetchedValue` to indicate that an already-existing
            column will generate a default value on the database side which
            will be available to SQLAlchemy for post-fetch after inserts. This
            construct does not specify any DDL and the implementation is left
            to the database, such as via a trigger.

            .. seealso::

                :ref:`server_defaults` - complete discussion of server side
                defaults

        :param server_onupdate: A :class:`.FetchedValue` instance
            representing a database-side default generation function,
            such as a trigger. This
            indicates to SQLAlchemy that a newly generated value will be
            available after updates. This construct does not actually
            implement any kind of generation function within the database,
            which instead must be specified separately.


            .. warning:: This directive **does not** currently produce MySQL's
               "ON UPDATE CURRENT_TIMESTAMP()" clause.  See
               :ref:`mysql_timestamp_onupdate` for background on how to
               produce this clause.

            .. seealso::

                :ref:`triggered_columns`

        :param quote: Force quoting of this column's name on or off,
             corresponding to ``True`` or ``False``. When left at its default
             of ``None``, the column identifier will be quoted according to
             whether the name is case sensitive (identifiers with at least one
             upper case character are treated as case sensitive), or if it's a
             reserved word. This flag is only needed to force quoting of a
             reserved word which is not known by the SQLAlchemy dialect.

        :param unique: When ``True``, and the :paramref:`_schema.Column.index`
            parameter is left at its default value of ``False``,
            indicates that a :class:`_schema.UniqueConstraint`
            construct will be automatically generated for this
            :class:`_schema.Column`,
            which will result in a "UNIQUE CONSTRAINT" clause referring
            to this column being included
            in the ``CREATE TABLE`` statement emitted, when the DDL create
            operation for the :class:`_schema.Table` object is invoked.

            When this flag is ``True`` while the
            :paramref:`_schema.Column.index` parameter is simultaneously
            set to ``True``, the effect instead is that a
            :class:`_schema.Index` construct which includes the
            :paramref:`_schema.Index.unique` parameter set to ``True``
            is generated.  See the documentation for
            :paramref:`_schema.Column.index` for additional detail.

            Using this flag is equivalent to making use of the
            :class:`_schema.UniqueConstraint` construct explicitly at the
            level of the :class:`_schema.Table` construct itself::

                Table(
                    "some_table",
                    metadata,
                    Column("x", Integer),
                    UniqueConstraint("x")
                )

            The :paramref:`_schema.UniqueConstraint.name` parameter
            of the unique constraint object is left at its default value
            of ``None``; in the absence of a :ref:`naming convention <constraint_naming_conventions>`
            for the enclosing :class:`_schema.MetaData`, the UNIQUE CONSTRAINT
            construct will be emitted as unnamed, which typically invokes
            a database-specific naming convention to take place.

            As this flag is intended only as a convenience for the common case
            of adding a single-column, default configured unique constraint to a table
            definition, explicit use of the :class:`_schema.UniqueConstraint` construct
            should be preferred for most use cases, including composite constraints
            that encompass more than one column, backend-specific index configuration options, and
            constraints that use a specific name.

            .. note:: the :attr:`_schema.Column.unique` attribute on
                :class:`_schema.Column`
                **does not indicate** if this column has a unique constraint or
                not, only if this flag was explicitly set here.  To view
                indexes and unique constraints that may involve this column,
                view the
                :attr:`_schema.Table.indexes` and/or
                :attr:`_schema.Table.constraints` collections or use
                :meth:`_reflection.Inspector.get_indexes` and/or
                :meth:`_reflection.Inspector.get_unique_constraints`

            .. seealso::

                :ref:`schema_unique_constraint`

                :ref:`constraint_naming_conventions`

                :paramref:`_schema.Column.index`

        :param system: When ``True``, indicates this is a "system" column,
             that is a column which is automatically made available by the
             database, and should not be included in the columns list for a
             ``CREATE TABLE`` statement.

             For more elaborate scenarios where columns should be
             conditionally rendered differently on different backends,
             consider custom compilation rules for :class:`.CreateColumn`.

        :param comment: Optional string that will render an SQL comment on
             table creation.

             .. versionadded:: 1.2 Added the
                :paramref:`_schema.Column.comment`
                parameter to :class:`_schema.Column`.


        r N�type_rz0May not pass name positionally and as a keyword.�
_sqla_typez1May not pass type_ positionally and as a keyword.rPz9Explicit 'name' is required when sending 'quote' argumentr+r�F�nullable�default�server_default�server_onupdaterr�system�doc�onupdate�
autoincrement�autor��_proxies�_warn_on_bytestringzUnicode column 'z ' has non-unicode default value z specified.T��
for_updaterHr).rrr�r(r�string_typesrr<�hasattrrr�r)r�r+r�r)r*r+r,rrr-r.r/r0r�r�r�r��computedr2�typerr9�
ColumnDefault�Sequencerr��binary_typer�FetchedValue�_as_for_update�
DefaultClauserB�set_creation_orderrHr�)r=r>rEr r'�coltyper�s      �r"r�zColumn.__init__Cs	���H�z�z�&�$�'�'���
�
�7�D�)�)���D�z�z���	#��$�q�'�4�#4�5�5�
#��#��+�J�����x�x��{�{���	$��1�g�G��w��-�-�
$��$��+�K��������������t�V�Z�Z���%>�%>�?�?�D�D�
��
�
��#�N���
�	�f�d���$�$�T�5�1�1�1��:�:�e�T�*�*���!�:�:�m�U�;�;����
�
�:�4�3C�/C�D�D��
��z�z�)�T�2�2���$�j�j�)9�4�@�@���%�z�z�*;�T�B�B���
�Z�Z���.�.��
��j�j��4�0�0����j�j��5�1�1����:�:�e�T�*�*����
�
�:�t�4�4��
�#�Z�Z���@�@����5�5����E�E����z�z�)�T�2�2�����
�����"�J�J�z�2�2�D�M�M�
��	�#4�
5�
5�	6��I�/�/��5�5�5��<�#��$�,���(A�B�B�

9����D�L�)�)�)�)��4�9�&;�U�C�C��!�$�,��0@�A�A���	�	� $�x�x�x�����7����
���M�$�,�7�7�8�8�8���*��$�-�|�<�<�
@����D�/�>�>�u�E�E�F�F�F�F����M�$�*=�>�>�?�?�?��=�$��$�-�-��)B�C�C�
K����D�M�*�*�*�*����M�$�-�D�I�I�I�J�J�J���+��$�.��=�=�
����D�0�?�?��E�E�F�F�F�F����!�$�"6�4�H�H�H����	���$������%�%�%��V����
�
�6�*�*�D�I����$�$�V�$�$�$�$�$r$c�0�|�|��dSr'r�rDs  r"r�zColumn._extra_kwargs)r�r$c��|j�dS|j�*|jjr|jjdz|jzS|jS|jS)Nz	(no name)r)r r*�named_with_columnr�rLs r"r�zColumn.__str__0sN���9���;�
�Z�
#��z�+�
(��z�-��3�d�6F�F�F��'�'��#�#r$c�h�|jD])}|jj�|j��rdS�*dS)zOReturn True if this Column references the given column via foreign
        key.TF)r�r��	proxy_set�intersection�r=r��fks   r"�
referenceszColumn.references;sG���#�	�	�B��y�"�/�/��0@�A�A�
��t�t�
��5r$c�0�|�|��dSr'r�)r=rIs  r"�append_foreign_keyzColumn.append_foreign_keyEs��
�$�$�T�*�*�*�*�*r$c����g}�j�jkr|�d���jr|�d���js|�d���jr|�d���jr|�d���jr|�d���jr|�d��dd	�	t�j��gt�j��gzd
��jD��zd��j
D��z�jdurd�jjzpd
gz�fd�|D��z��zS)Nr+r�r)r/r*r+r�z
Column(%s)r�c�0�g|]}|�t|����Sr'r�r�s  r"r�z#Column.__repr__.<locals>.<listcomp>[s��C�C�C�1�Q�]�t�A�w�w�]�]�]r$c�,�g|]}t|����Srr�r�s  r"r�z#Column.__repr__.<locals>.<listcomp>\s��1�1�1�1�t�A�w�w�1�1�1r$z
table=<%s>z
table=Nonec
�T��g|]$}|�dtt�|��������%Sr�r�r�s  �r"r�z#Column.__repr__.<locals>.<listcomp>ds7���D�D�D��!�!�!�T�'�$��"2�"2�3�3�3�4�D�D�Dr$)r+r rr�r)r/r*r+r�r�r�r9r�r�r*r�)r=�kwargs` r"rMzColumn.__repr__Hs�������8�t�y� � ��L�L�������	(��L�L��'�'�'��}�	%��L�L��$�$�$��=�	%��L�L��$�$�$��<�	$��L�L��#�#�#���	+��L�L�)�*�*�*��<�	$��L�L��#�#�#��d�i�i�
�$�)�_�_���D�I����
 �C�C�� 1�C�C�C�
D�2�1�� 0�1�1�1�
2��J�d�*�>�$�t�z�'=�=�$�#�	�	

�E�D�D�D�e�D�D�D�
E�

�

�

�
	
r$c	���|jstjd���|j�|j|_t	|dd��}|�)|�ur%tjd|j�d|j�d����|j�jvrt�j�|j��}||urQ|jD]I}�j�	|��|j
�jvr�j�	|j
���J�j�|���|_
|jr�j�|��n3|j�jvr%tjd|j�d�j�d����|jrqt%|jt&j��rtjd�����t-d|jt/|j��d	�
����nc|jr\t%|jt&j��rtjd�����t3|jd	�����|��fd
���dS)NzfColumn must be constructed with a non-blank name or assign a non-blank .name before adding to a Table.r*zColumn object 'z' already assigned to Table '�'z'Trying to redefine primary-key column 'z(' as a non-primary-key column on table 'z�The 'index' keyword argument on Column is boolean only. To create indexes with a specific name, create an explicit Index object external to the Table.T)rrz�The 'unique' keyword argument on Column is boolean only. To create unique constraints or indexes with a specific name, append an explicit UniqueConstraint to the Table's list of elements, or create an explicit Index object external to the Table.)rc�.��|����Sr')�_set_remote_table)rIr*s �r"r�z$Column._set_parent.<locals>.<lambda>�s���r�/C�/C�E�/J�/J�r$)r rr<r+r�r�r�rYr�r�r�r�r0r*r��_replacer�rr(rr6r�rrtr�UniqueConstraint�_setup_on_memoized_fks)r=r*�existingr-rIs `   r"r�zColumn._set_parentgs�����y�	��#�E���
��8���y�D�H��4��$�/�/����H�E�$9�$9��#�#��8�8�8�X�1�1�1�3���
�
�8�u�~�%�%��.�$�$�T�X�.�.�C��$����*�@�@�B��&�-�-�b�1�1�1��}��(9�9�9��)�0�0���?�?�?��
����t�$�$�$���
���	���&�&�t�,�,�,�,�
�X��*�
*�
*��#�#��8�8�8�U�^�^�^�-���
��:�	��$�*�d�&7�8�8�
��'�C����

�#�#���$�(�4���+<�+<�4����
�
�
�
��[�	��$�+�t�'8�9�9�
��'�:����
�#�#� ����=�=�=�
�
�
�	
�#�#�$J�$J�$J�$J�K�K�K�K�Kr$c���|jj|jfdf|jj|jfdfg}|D]F\}}||jjjvr.|jjj|D]}|j|ur||����GdS)NFT)r*r+r r�	_fk_memos�link_to_name)r=r��fk_keys�fk_keyr\rIs      r"rXzColumn._setup_on_memoized_fks�s����j�n�d�h�
'��/��j�n�d�i�
(�$�/�
��%,�	�	� �F�L����,�6�6�6��*�-�7��?���B���,�6�6���2������		�	r$c�f�|j�|||j��dStj|d|��dS)Nrz)r*rr�)r=r�s  r"�_on_table_attachzColumn._on_table_attach�s?���:�!��B�t�T�Z� � � � � ��L��4�b�9�9�9�9�9r$c����fd�|jD���fd�|jD��z}i}|jD]9}|j|j}|���D]\}}|||dz|z<��:|j}|j}	t|t��r)dx}}	|�	|jj
di�����|j}
t|
t��r
|
j
di���}
|j
||j|
|j|j|j|j|j|j|j|j||j|	|j|jd�|��}|�|��S)zuCreate a copy of this ``Column``, uninitialized.

        This is used in :meth:`_schema.Table.tometadata`.

        c�8��g|]}|j�	|jdi�����S�r)rrT�r�r,r~s  �r"r�zColumn.copy.<locals>.<listcomp>�s>���
�
�
��!�-�
��A�F�L�L�R�L�L�
�
�
r$c�8��g|]}|j�	|jdi�����Src)r�rTrds  �r"r�zColumn.copy.<locals>.<listcomp>�s.���I�I�I�a�A�L�I�V�Q�V�\�\�b�\�\�I�I�Ir$r�N)r r'r+r�r)rr-rr0r*r+r/r,r.r�r)r�r��dialect_options�
_non_defaults�itemsr+r,r(�ComputedrrTr9r�_constructorr r+r�r)rr-rr0r*r/r.r�rW)r=r~r>�
column_kwargs�dialect_namerf�dialect_option_key�dialect_option_valuer+r,r'r,s `          r"rTzColumn.copy�s����
�
�
�
�"&�"2�
�
�
�I�I�I�I�4�#4�I�I�I�J��
�
� �0�	)�	)�L�"�2�<�@�N�O�!�&�&�(�(�
)�
)��"�$�)�� �3�&�);�;���	
)��,���.���n�h�/�/�	8�/3�3�N�_��K�K�0��+�0�6�6�2�6�6�7�7�7��	���e�.�/�/�	%��E�J�$�$��$�$�E��D��"�!������(��]��;��;��*��,��L�)��]�+����L�!
�
�$�%
�
��(�%�%�a�(�(�(r$NFc��d�|jD��}|�|j�tjd���	|j|rt|p|j��n|p|j|jg|�R|r|n
|r|n|j|j|j	|gd��}nB#t$r5}tjtd|j
z��|���Yd}~nd}~wwxYw||_|j�|��|j�)|jj�|j��|_|jr|j�|��|j�||��|S)a$Create a *proxy* for this column.

        This is a copy of this ``Column`` referenced by a different parent
        (such as an alias or select statement).  The column should
        be used only in select scenarios, as its full DDL/default
        information is not transferred.

        c�D�g|]}t|j|j�����S))�_constraint)�
ForeignKeyr�r�)r��fs  r"r�z&Column._make_proxy.<locals>.<listcomp>�s9��
�
�
��
�q�x�Q�\�:�:�:�
�
�
r$Nz^Cannot initialize a sub-selectable with this Column object until its 'name' has been assigned.)r+r�r)r2z�Could not create a copy of this %r object.  Ensure the class includes a _constructor() attribute or method which accepts the standard Column constructor arguments, or references the Column class itself.��from_)r�r rrurjrr9r+r�r)rprr;r�r*r�r��_is_clone_ofr�rYrUrz)	r=�
selectabler r+�name_is_truncatabler~rIr,rAs	         r"�_make_proxyzColumn._make_proxy�s���
�
��&�
�
�
���<�D�I�-��)�!���
�
	�!��!�&�)�
�d�/�d�i�0�0�0��'�d�i��	�	
��
�
�
�>�C�C�D�$>�D�D�d�h� �,�����
�
�
�A�A���
	�
	�
	��K��:�=A�N�	K����	
�	
�	
�	
�	
�	
�	
�	
�	
�����
	������������"�"�"��"�.�'�4�<�@�@���G�G�A�N���	*��"�&�&�q�)�)�)�	�
�&�&�q�*�5�5�5��s�AB�
C�+B<�<Cc��|rBd�|j|jfD��t|j��zt|j��zStj|fi|��S)Nc��g|]}|�|��Sr'rr�s  r"r�z'Column.get_children.<locals>.<listcomp>-s��K�K�K�q�Q�]��]�]�]r$)r*r/r�r�r�rrF)r=r�rEs   r"rFzColumn.get_children*sj���	=�K�K�T�\�4�=�9�K�K�K��t�(�)�)�*��t�'�(�(�)�
� �,�T�<�<�V�<�<�<r$)NNF�F)r]r^r_r`rar�r�r�rJrLrMr�rXr`rTryrFr#r$s@r"r)r)>s�������2�2��N�d%�d%�d%�d%�d%�L.�.�.�	$�	$�	$����+�+�+�
�
�
�>BL�BL�BL�H	�	�	�:�:�:�6)�6)�6)�rDI�4�4�4�4�l=�=�=�=�=�=�=�=r$r)c���eZdZdZdZ										dd�Zd�Zdd�Zdd�Ze	d	���Z
d
�Ze	e��Zd�Z
d�Zejd
���Zd�Zd�Zd�Zejd���Zd�Zd�Zd�Zd�ZdS)rra;Defines a dependency between two columns.

    ``ForeignKey`` is specified as an argument to a :class:`_schema.Column`
    object,
    e.g.::

        t = Table("remote_table", metadata,
            Column("remote_id", ForeignKey("main_table.id"))
        )

    Note that ``ForeignKey`` is only a marker object that defines
    a dependency between two columns.   The actual constraint
    is in all cases represented by the :class:`_schema.ForeignKeyConstraint`
    object.   This object will be generated automatically when
    a ``ForeignKey`` is associated with a :class:`_schema.Column` which
    in turn is associated with a :class:`_schema.Table`.   Conversely,
    when :class:`_schema.ForeignKeyConstraint` is applied to a
    :class:`_schema.Table`,
    ``ForeignKey`` markers are automatically generated to be
    present on each associated :class:`_schema.Column`, which are also
    associated with the constraint object.

    Note that you cannot define a "composite" foreign key constraint,
    that is a constraint between a grouping of multiple parent/child
    columns, using ``ForeignKey`` objects.   To define this grouping,
    the :class:`_schema.ForeignKeyConstraint` object must be used, and applied
    to the :class:`_schema.Table`.   The associated ``ForeignKey`` objects
    are created automatically.

    The ``ForeignKey`` objects associated with an individual
    :class:`_schema.Column`
    object are available in the `foreign_keys` collection
    of that column.

    Further examples of foreign key configuration are in
    :ref:`metadata_foreignkeys`.

    �foreign_keyNFc��||_t|jtj��rd|_n�t|jd��r|j���|_n|j|_t|jt��stj	d|jz���t|jj
tjtf��s!tj	d|jj
z���||_
d|_||_||_||_||_||_||_|	|_|
|_|r||_||_dS)a�
        Construct a column-level FOREIGN KEY.

        The :class:`_schema.ForeignKey` object when constructed generates a
        :class:`_schema.ForeignKeyConstraint`
        which is associated with the parent
        :class:`_schema.Table` object's collection of constraints.

        :param column: A single target column for the key relationship. A
            :class:`_schema.Column` object or a column name as a string:
            ``tablename.columnkey`` or ``schema.tablename.columnkey``.
            ``columnkey`` is the ``key`` which has been assigned to the column
            (defaults to the column name itself), unless ``link_to_name`` is
            ``True`` in which case the rendered name of the column is used.

        :param name: Optional string. An in-database name for the key if
            `constraint` is not provided.

        :param onupdate: Optional string. If set, emit ON UPDATE <value> when
            issuing DDL for this constraint. Typical values include CASCADE,
            DELETE and RESTRICT.

        :param ondelete: Optional string. If set, emit ON DELETE <value> when
            issuing DDL for this constraint. Typical values include CASCADE,
            DELETE and RESTRICT.

        :param deferrable: Optional bool. If set, emit DEFERRABLE or NOT
            DEFERRABLE when issuing DDL for this constraint.

        :param initially: Optional string. If set, emit INITIALLY <value> when
            issuing DDL for this constraint.

        :param link_to_name: if True, the string name given in ``column`` is
            the rendered name of the referenced column, not its locally
            assigned ``key``.

        :param use_alter: passed to the underlying
            :class:`_schema.ForeignKeyConstraint`
            to indicate the constraint should
            be generated/dropped externally from the CREATE TABLE/ DROP TABLE
            statement.  See :paramref:`_schema.ForeignKeyConstraint.use_alter`
            for further description.

            .. seealso::

                :paramref:`_schema.ForeignKeyConstraint.use_alter`

                :ref:`use_alter`

        :param match: Optional string. If set, emit MATCH <value> when issuing
            DDL for this constraint. Typical values include SIMPLE, PARTIAL
            and FULL.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param \**dialect_kw:  Additional keyword arguments are dialect
            specific, and passed in the form ``<dialectname>_<argname>``.  The
            arguments are ultimately handled by a corresponding
            :class:`_schema.ForeignKeyConstraint`.
            See the documentation regarding
            an individual dialect at :ref:`dialect_toplevel` for detail on
            documented arguments.

            .. versionadded:: 0.9.2

        N�__clause_element__z9String, Column, or Column-bound argument expected, got %rz8ForeignKey received Column not bound to a Table, got: %r)�_colspecr(rr6�
_table_columnr7r�rrr<r*�NoneTyperr��parent�	use_alterr r/�ondelete�
deferrable�	initiallyr\�matchrH�_unvalidated_dialect_kw)
r=r�rqr�r r/r�r�r�r\r�rH�
dialect_kws
             r"r�zForeignKey.__init___sW��j��
��d�m�T�%6�7�7�	�!%�D����t�}�&:�;�;�
3�%)�]�%E�%E�%G�%G��"�"�%)�]��"��d�0�,�?�?�
��'�'�)-�);�<���� ��"�(�4�=�+�*F���
��'�*�,0�,>�,D�E����&������"�����	� ��
� ��
�$���"���(�����
��	��D�I�'1��$�$�$r$c�0�d|���zS)NzForeignKey(%r))�_get_colspecrLs r"rMzForeignKey.__repr__�s���$�"3�"3�"5�"5�5�5r$c���t|�|���f|j|j|j|j|j|j|j|j	d�|j
��}|�|��S)aProduce a copy of this :class:`_schema.ForeignKey` object.

        The new :class:`_schema.ForeignKey` will not be bound
        to any :class:`_schema.Column`.

        This method is usually used by the internal
        copy procedures of :class:`_schema.Column`, :class:`_schema.Table`,
        and :class:`_schema.MetaData`.

        :param schema: The returned :class:`_schema.ForeignKey` will
          reference the original table and column name, qualified
          by the given string schema name.

        r�)r�r r/r�r�r�r\r�)rrr�r�r r/r�r�r�r\r�r�rW)r=r!rIs   r"rTzForeignKey.copy�s}�� ����V��,�,�
��n����]��]����n��*��*�
�
��*�
�
���%�%�b�)�)�)r$c���|r|j\}}}|�|}|�d|�d|��S|r|j\}}}|r
|�d|�d|��S|�d|��S|j� |jjj�d|jj��S|jS)z�Return a string based 'column specification' for this
        :class:`_schema.ForeignKey`.

        This is usually the equivalent of the string-based "tablename.colname"
        argument first passed to the object's constructor.

        Nr)�_column_tokensr�r*r�r+r�)r=r!�
table_name�_schema�tname�colnames      r"r�zForeignKey._get_colspec�s����	!�&*�&9�#�G�U�G��%�"��!'��������8�8�
�	!�%)�%8�"�F�E�7��
7�%+�V�V�Z�Z�Z���A�A�",�*�*�g�g�6�6�
�
�
+��"�(�1�1�1��"�&�&��
�
�=� r$c��|jdS)Nr)r�rLs r"rzForeignKey._referred_schemas���"�1�%�%r$c��|j�|jj�dS|jjjS|j\}}}t	||��Sr')r�r*r+r�r#)r=r!r�r�s    r"�
_table_keyzForeignKey._table_keysJ����)��!�'�/��t��)�/�3�3�%)�%8�"�F�E�7�!�%��0�0�0r$c�:�|�|j��duS)zrReturn True if the given :class:`_schema.Table`
        is referenced by this
        :class:`_schema.ForeignKey`.N��corresponding_columnr�r�s  r"rJzForeignKey.references)s��
�)�)�$�+�6�6�d�B�Br$c�6�|�|j��S)aReturn the :class:`_schema.Column` in the given
        :class:`_schema.Table`
        referenced by this :class:`_schema.ForeignKey`.

        Returns None if this :class:`_schema.ForeignKey`
        does not reference the given
        :class:`_schema.Table`.

        r�r�s  r"�get_referentzForeignKey.get_referent0s���)�)�$�+�6�6�6r$c��|����d��}|�tjd|jz���t|��dkr|���}d}n(|���}|���}t|��dkrd�|��}nd}|||fS)z7parse a string-based _colspec into its component parts.rNz,Invalid foreign key column specification: %srr)r��splitrr<r��lenrrr�)r=�mr�r�r!s     r"r�zForeignKey._column_tokens=s���
�����%�%�c�*�*���9��#�>���N���
��q�6�6�Q�;�;��E�E�G�G�E��G�G��e�e�g�g�G��E�E�G�G�E��q�6�6�A�:�:��X�X�a�[�[�F�F��F��u�g�%�%r$c�j�|j�tjd���|jj�tjd���|jj}|jjD]$}t|t��r
|j|usJ�n�%J�|j\}}}|�|jj	�|jj	}t||��}|||fS)NzLthis ForeignKey object does not yet have a parent Column associated with it.zCthis ForeignKey's parent column is not yet associated with a Table.)r�rrur*�base_columnsr(r)r�rr!r#)r=�parenttabler,r!r�r��tablekeys       r"�_resolve_col_tokenszForeignKey._resolve_col_tokens\s����;���)�4���
�
�[�
�
&��)� ���
�
�k�'����)�	�	�A��!�V�$�$�
��w�+�-�-�-�-���
�
�5�"&�!4����w��>�k�2�9�E� �)�0�F�!�%��0�0���H�g�-�-r$c���t|jd��s
||j_n|jj|usJ�d}|�-|j}|j�|jjd��}n>|jr|}|jD]}|j|kr|}�n|}|j�|d��}|�7tj
d|j�d|j�d|j�d|�d�	|j|���|�|��dS)N�_referred_table�3Could not initialize target column for ForeignKey '�' on table '�
': table '�' has no column named 'rS)
r7r�r�r�r,rYr+r\r r�NoReferencedColumnErrorr��_set_target_column)r=r�r*r��_columnr+r,s       r"�_link_to_col_by_colstringz$ForeignKey._link_to_col_by_colstrings*���t��(9�:�:�	<�.3�D�O�+�+��?�2�e�;�;�;�;����?�
�+�C��g�k�k�$�+�/�4�8�8�G�G�
�
�	1��C��W�
 �
 ���6�W�$�$��G��
 ��C��g�k�k�'�4�0�0�G��?��-�-��=�=�=�+�"2�"2�"2�E�J�J�J����E��
��
��
�	
����(�(�(�(�(r$c����|jjjr�j|j_t|jjt
��r�fd�}|j�|���|_dS)Nc�P��|jjjr�j|j_dSdSr')r�r9�_isnull)rIr�s �r"�set_typez/ForeignKey._set_target_column.<locals>.set_type�s+����9�>�)�1�%+�[�B�I�N�N�N�1�1r$)r�r9r�r(r*rfrXr�)r=r�r�s ` r"r�zForeignKey._set_target_column�st����;��#�	+�%�{�D�K���d�k�'��/�/�	9�
1�
1�
1�
1�
1�
�K�.�.�x�8�8�8�����r$c���t|jtj��r�|���\}}}||jvr$t
jd|j�d|�d|�d�|���|j	|jvrt
j
d|z���t
jd|j�d|j�d|�d	|�d�	||���t|jd
��r|j���}|S|j}|S)a�Return the target :class:`_schema.Column` referenced by this
        :class:`_schema.ForeignKey`.

        If no target column has been established, an exception
        is raised.

        .. versionchanged:: 0.9.0
            Foreign key target column resolution now occurs as soon as both
            the ForeignKey object and the remote Column to which it refers
            are both associated with the same MetaData object.

        z$Foreign key associated with column 'z' could not find table 'z9' with which to generate a foreign key to target column 'rSz9Table %s is no longer associated with its parent MetaDatar�r�r�r�r�)r(r�rr6r�rr�NoReferencedTableErrorr�r+rur�r r7r�)r=r�r�r�r�s     r"r�zForeignKey.column�s3���d�m�T�%6�7�7�	�-1�-E�-E�-G�-G�*�K��7��{�3�3�3��0�0��{�{�{�H�H�H�g�g�g�7��������(<�<�<��-�&�(3�4����
�1�1��}�}�}�k�&6�&6�&6����'�'�'�K���
����T�]�$8�
9�
9�	��m�6�6�8�8�G��N��m�G��Nr$c���|j�|j|urtjd���||_|jj�|��|j�|j��dS)Nz&This ForeignKey already has a parent !)r�rrur�r�r`�
_set_tabler�s  r"r�zForeignKey._set_parent�sn���;�"�t�{�&�'@�'@��)�8���
������ �$�$�T�*�*�*���$�$�T�_�5�5�5�5�5r$c��|���\}}}|�|||��|j�|��dSr')r�r�r��_validate_dest_table)r=r*r�r�r�s     r"rUzForeignKey._set_remote_table�sN��)-�)A�)A�)C�)C�&��X�w��&�&�{�E�7�C�C�C���,�,�U�3�3�3�3�3r$c��|���\}}}||f}||j|vr"|j|�|��dSdSr')r�r[r�)r=rr��	table_keyr�r^s      r"�_remove_from_metadataz ForeignKey._remove_from_metadata�sa��*.�*B�*B�*D�*D�'��Y���W�%���8�%�f�-�-�-���v�&�-�-�d�3�3�3�3�3�.�-r$c��|j��t|t��rxtggf|j|j|j|j|j|j	|j
d�|j��|_|j�||��|j�
|��|j�|��t|jt"j��r�|���\}}}||f}||jjvr@|jj|}	|�|||��n#t.j$rYnwxYw|jj|�|��dSt7|jd��r0|j���}|�|��dS|j}|�|��dS)N)r�r r/r�r�r�r�r�)r�r(rfrr�r r/r�r�r�r�r��_append_elementr9r�r�r�rr6r�rrsr�rr�r[rr7r�r�)r=r�r*r�r�r�r^r�s        r"r�zForeignKey._set_table�s����?�"�z�%��'?�'?�"�2�����.��Y������?��.��j����.���D�O�
�O�+�+�F�D�9�9�9��O�5�5�e�<�<�<�
����t�$�$�$��d�m�T�%6�7�7�	-�.2�.F�.F�.H�.H�+�K��G���)�F��K�0�7�7�7�#�,�3�I�>����2�2�;��w�O�O�O�O���2�����D�����
� �*�6�2�9�9�$�?�?�?�?�?�
�T�]�$8�
9�
9�	-��m�6�6�8�8�G��#�#�G�,�,�,�,�,��m�G��#�#�G�,�,�,�,�,s�D#�#D5�4D5)
NFNNNNNFNNr'�NN)r]r^r_r`rar�rMrTr�rbrr��target_fullnamerJr�rrdr�r�r�r�r�r�rUr�r�rr$r"rrrr5s�������%�%�N#�N�
��
�������
�|2�|2�|2�|2�|6�6�6�*�*�*�*�<!�!�!�!�6�&�&��X�&�1�1�1��h�|�,�,�O�C�C�C�7�7�7�
��&�&���&�<!.�!.�!.�F!)�!)�!)�F���"
��-�-���-�^6�6�6�4�4�4�
4�4�4�&-�&-�&-�&-�&-r$rrc�6�eZdZd�Zd�xZZed���ZdS)�_NotAColumnExprc�D�tjd|jjz���)Nz7This %s cannot be used directly as a column expression.�rrur�r]rLs r"�_not_a_column_exprz"_NotAColumnExpr._not_a_column_expr#	s*���%�
&�(,��(?�
@�
�
�	
r$c�*�|���Sr'�r�rLs r"r�z_NotAColumnExpr.<lambda>)	s��4�3J�3J�3L�3L�r$c�*�|���Sr'r�rLs r"r�z_NotAColumnExpr.<lambda>*	s��$�*A�*A�*C�*C�r$N)r]r^r_r�r��
self_grouprb�
_from_objectsrr$r"r�r�"	sA������
�
�
�'M�&L�L����H�C�C�D�D�M�M�Mr$r�c�T�eZdZdZdZdZdZdZd
d�Zd�Z	dd�Z
d�Zed	���Z
dS)�DefaultGeneratorz'Base class for column *default* values.�default_generatorFNc��||_dSr'r4�r=r5s  r"r�zDefaultGenerator.__init__6	�
��$����r$c�V�||_|jr||j_dS||j_dSr')r�r5r/r*r�s  r"r�zDefaultGenerator._set_parent9	s3������?�	'�#'�D�K� � � �"&�D�K���r$c�@�|�t|��}|j|fi|��Sr')r�execute)r=r�rEs   r"r�zDefaultGenerator.execute@	s.���<�!�$�'�'�D��t�|�D�+�+�F�+�+�+r$c�0�|�|||��Sr')�_execute_default)r=r��multiparams�paramss    r"�_execute_on_connectionz'DefaultGenerator._execute_on_connectionE	s���*�*�4��f�E�E�Er$c�J�t|dd���|jjjSdS)z4Return the connectable associated with this default.r�N)r�r�r*r�rLs r"r�zDefaultGenerator.bindH	s)���4��4�(�(�4��;�$�)�)��4r$r|r')r]r^r_r`ra�is_sequence�is_server_defaultr�r�r�r�r�rbr�rr$r"r�r�-	s�������1�1�(�N��K���
�F�%�%�%�%�'�'�'�,�,�,�,�
F�F�F�����X���r$r�c���eZdZdZ�fd�Zejd���Zejd���Zejd���Z	ejej
d��d�����Zd�Zd	�Z
ee
��Zd
�Z�xZS)r:a�A plain default value on a column.

    This could correspond to a constant, a callable function,
    or a SQL clause.

    :class:`.ColumnDefault` is generated automatically
    whenever the ``default``, ``onupdate`` arguments of
    :class:`_schema.Column` are used.  A :class:`.ColumnDefault`
    can be passed positionally as well.

    For example, the following::

        Column('foo', Integer, default=50)

    Is equivalent to::

        Column('foo', Integer, ColumnDefault(50))


    c���tt|��jdi|��t|t��rtjd���tj|��r|�	|��}||_
dS)a{Construct a new :class:`.ColumnDefault`.


        :param arg: argument representing the default value.
         May be one of the following:

         * a plain non-callable Python value, such as a
           string, integer, boolean, or other simple type.
           The default value will be used as is each time.
         * a SQL expression, that is one which derives from
           :class:`_expression.ColumnElement`.  The SQL expression will
           be rendered into the INSERT or UPDATE statement,
           or in the case of a primary key column when
           RETURNING is not used may be
           pre-executed before an INSERT within a SELECT.
         * A Python callable.  The function will be invoked for each
           new row subject to an INSERT or UPDATE.
           The callable must accept exactly
           zero or one positional arguments.  The one-argument form
           will receive an instance of the :class:`.ExecutionContext`,
           which provides contextual information as to the current
           :class:`_engine.Connection` in use as well as the current
           statement and parameters.

        z4ColumnDefault may not be a server-side default type.Nr)r�r:r�r(r=rr<r�callable�_maybe_wrap_callable�arg)r=r�rEr�s   �r"r�zColumnDefault.__init__g	s����4	,��m�T�"�"�+�5�5�f�5�5�5��c�<�(�(�	��#�F���
��=����	1��+�+�C�0�0�C�����r$c�4�tj|j��Sr')rr�r�rLs r"�is_callablezColumnDefault.is_callable�	s���}�T�X�&�&�&r$c�6�t|jt��Sr')r(r�rrLs r"�is_clause_elementzColumnDefault.is_clause_element�	s���$�(�M�2�2�2r$c�2�|jo|jo|jSr')r�r�r�rLs r"�	is_scalarzColumnDefault.is_scalar�	s.��� � �
%��*�*�
%��$�$�	
r$zsqlalchemy.sql.sqltypesc�T�|jr t|jj|j��SdSr!)r�r(r�r9�NullType)r=�sqltypess  r"�
_arg_is_typedzColumnDefault._arg_is_typed�	s.���!�	�!�$�(�-��1B�C�C�C�C��5r$c�j��	tj�d���}n(#t$rtj�fd����cYSwxYw|ddurt	|d��pd}t	|d��|z
}|dkrtj�fd����S|dkr�Stjd	���)
z�Wrap callables that don't accept a context.

        This is to allow easy compatibility with default callables
        that aren't specific to accepting of a context.

        T)�no_selfc������Sr'r��ctxr�s �r"r�z4ColumnDefault._maybe_wrap_callable.<locals>.<lambda>�	�
���"�"�$�$�r$�Nrc������Sr'rr�s �r"r�z4ColumnDefault._maybe_wrap_callable.<locals>.<lambda>�	r�r$rzDColumnDefault Python function takes zero or one positional arguments)r�get_callable_argspecrp�
wrap_callabler�rr<)r=r��argspec�	defaulted�positionalss `   r"r�z"ColumnDefault._maybe_wrap_callable�	s����	<��/��D�A�A�A�G�G���	<�	<�	<��%�&6�&6�&6�&6��;�;�;�;�;�	<�����A�J�d�*�>�s�7�1�:���C�!�	��'�!�*�o�o�	�1���!����%�&6�&6�&6�&6��;�;�;�
�A�
�
��I��#�'���
s��"?�?c��|jrdSdS)N�column_onupdate�column_defaultr4rLs r"�_visit_namezColumnDefault._visit_name�	s���?�	$�$�$�#�#r$c��d|j�d�S)NzColumnDefault(�))r�rLs r"rMzColumnDefault.__repr__�	s���&*�h�h�h�0�0r$)r]r^r_r`r�rrdr�r�r��dependenciesr�r�r�rbrarMr#r$s@r"r:r:Q	s���������*!�!�!�!�!�F
��'�'���'�
��3�3���3�
��
�
���
�
���T��0�1�1���2�1�������4$�$�$��X�k�*�*�N�1�1�1�1�1�1�1r$r:c�,�eZdZdZ									dd�ZdS)�IdentityOptionsz�Defines options for a named database sequence or an identity column.

    .. versionadded:: 1.3.18

    .. seealso::

        :class:`.Sequence`

    Nc
��||_||_||_||_||_||_||_||_|	|_dS)aiConstruct a :class:`.IdentityOptions` object.

        See the :class:`.Sequence` documentation for a complete description
        of the parameters

        :param start: the starting index of the sequence.
        :param increment: the increment value of the sequence.
        :param minvalue: the minimum value of the sequence.
        :param maxvalue: the maximum value of the sequence.
        :param nominvalue: no minimum value of the sequence.
        :param nomaxvalue: no maximum value of the sequence.
        :param cycle: allows the sequence to wrap around when the maxvalue
         or minvalue has been reached.
        :param cache: optional integer value; number of future values in the
         sequence which are calculated in advance.
        :param order: optional boolean value; if ``True``, renders the
         ORDER keyword.
         name.
        N�	�start�	increment�minvalue�maxvalue�
nominvalue�
nomaxvalue�cycle�cache�order)
r=rrrrrrr	r
rs
          r"r�zIdentityOptions.__init__�	sG��>��
�"��� ��
� ��
�$���$�����
���
���
�
�
r$)	NNNNNNNNN�r]r^r_r`r�rr$r"rr�	sO�����������������'�'�'�'�'�'r$rc���eZdZdZdZdZ															dd�Zejd���Z	ejd���Z
ejd	��d
���Z�fd�Z
d�Zd
�Zed���Zdd�Zdd�Zd�Z�xZS)r;a�Represents a named database sequence.

    The :class:`.Sequence` object represents the name and configurational
    parameters of a database sequence.   It also represents
    a construct that can be "executed" by a SQLAlchemy :class:`_engine.Engine`
    or :class:`_engine.Connection`,
    rendering the appropriate "next value" function
    for the target database and returning a result.

    The :class:`.Sequence` is typically associated with a primary key column::

        some_table = Table(
            'some_table', metadata,
            Column('id', Integer, Sequence('some_table_seq'),
            primary_key=True)
        )

    When CREATE TABLE is emitted for the above :class:`_schema.Table`, if the
    target platform supports sequences, a CREATE SEQUENCE statement will
    be emitted as well.   For platforms that don't support sequences,
    the :class:`.Sequence` construct is ignored.

    .. seealso::

        :class:`.CreateSequence`

        :class:`.DropSequence`

    �sequenceTNFc��t�||���t�|||||||||
|��
�
t||
��|_||_|	tur
dx|_}	n/|�|	�|jr|jx|_}	nt|	|��|_||_t||	��|_
|r|�|��dSdS)alConstruct a :class:`.Sequence` object.

        :param name: the name of the sequence.
        :param start: the starting index of the sequence.  This value is
         used when the CREATE SEQUENCE command is emitted to the database
         as the value of the "START WITH" clause.   If ``None``, the
         clause is omitted, which on most platforms indicates a starting
         value of 1.
        :param increment: the increment value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "INCREMENT BY" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates an
         increment of 1.
        :param minvalue: the minimum value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "MINVALUE" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates a
         minvalue of 1 and -2^63-1 for ascending and descending sequences,
         respectively.

         .. versionadded:: 1.0.7

        :param maxvalue: the maximum value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "MAXVALUE" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates a
         maxvalue of 2^63-1 and -1 for ascending and descending sequences,
         respectively.

         .. versionadded:: 1.0.7

        :param nominvalue: no minimum value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "NO MINVALUE" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates a
         minvalue of 1 and -2^63-1 for ascending and descending sequences,
         respectively.

         .. versionadded:: 1.0.7

        :param nomaxvalue: no maximum value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "NO MAXVALUE" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates a
         maxvalue of 2^63-1 and -1 for ascending and descending sequences,
         respectively.

         .. versionadded:: 1.0.7

        :param cycle: allows the sequence to wrap around when the maxvalue
         or minvalue has been reached by an ascending or descending sequence
         respectively.  This value is used when the CREATE SEQUENCE command
         is emitted to the database as the "CYCLE" clause.  If the limit is
         reached, the next number generated will be the minvalue or maxvalue,
         respectively.  If cycle=False (the default) any calls to nextval
         after the sequence has reached its maximum value will return an
         error.

         .. versionadded:: 1.0.7

        :param schema: optional schema name for the sequence, if located
         in a schema other than the default.  The rules for selecting the
         schema name when a :class:`_schema.MetaData`
         is also present are the same
         as that of :paramref:`_schema.Table.schema`.

        :param cache: optional integer value; number of future values in the
         sequence which are calculated in advance.  Renders the CACHE keyword
         understood by Oracle and PostgreSQL.

         .. versionadded:: 1.1.12

        :param order: optional boolean value; if ``True``, renders the
         ORDER keyword, understood by Oracle, indicating the sequence is
         definitively ordered.   May be necessary to provide deterministic
         ordering using Oracle RAC.

         .. versionadded:: 1.1.12

        :param optional: boolean value, when ``True``, indicates that this
         :class:`.Sequence` object only needs to be explicitly generated
         on backends that don't provide another way to generate primary
         key identifiers.  Currently, it essentially means, "don't create
         this sequence on the PostgreSQL backend, where the SERIAL keyword
         creates a sequence for us automatically".
        :param quote: boolean value, when ``True`` or ``False``, explicitly
         forces quoting of the :paramref:`_schema.Sequence.name` on or off.
         When left at its default of ``None``, normal quoting rules based
         on casing and reserved words take place.
        :param quote_schema: Set the quoting preferences for the ``schema``
         name.

        :param metadata: optional :class:`_schema.MetaData` object which this
         :class:`.Sequence` will be associated with.  A :class:`.Sequence`
         that is associated with a :class:`_schema.MetaData`
         gains the following
         capabilities:

         * The :class:`.Sequence` will inherit the
           :paramref:`_schema.MetaData.schema`
           parameter specified to the target :class:`_schema.MetaData`, which
           affects the production of CREATE / DROP DDL, if any.

         * The :meth:`.Sequence.create` and :meth:`.Sequence.drop` methods
           automatically use the engine bound to the :class:`_schema.MetaData`
           object, if any.

         * The :meth:`_schema.MetaData.create_all` and
           :meth:`_schema.MetaData.drop_all`
           methods will emit CREATE / DROP for this :class:`.Sequence`,
           even if the :class:`.Sequence` is not associated with any
           :class:`_schema.Table` / :class:`_schema.Column`
           that's a member of this
           :class:`_schema.MetaData`.

         The above behaviors can only occur if the :class:`.Sequence` is
         explicitly associated with the :class:`_schema.MetaData`
         via this parameter.

         .. seealso::

            :ref:`sequence_metadata` - full discussion of the
            :paramref:`.Sequence.metadata` parameter.

        :param for_update: Indicates this :class:`.Sequence`, when associated
         with a :class:`_schema.Column`,
         should be invoked for UPDATE statements
         on that column's table, rather than for INSERT statements, when
         no value is otherwise present for that column in the statement.

        r4rN)r�r�rrr �optionalrqr!rr#�_key�
_set_metadata)r=r rrrrrrr	r!r
rrrPrr�r5s                 r"r�zSequence.__init__ 
s��l	�!�!�$�:�!�>�>�>�� � ������!�!����	!�	
�	
�	
� ��e�,�,��	� ��
��\�!�!�#'�'�D�K�&�&�
�
!�f�n���n�#+�?�2�D�K�&�&�%�f�l�;�;�D�K� ��
�"�4��0�0��	��	)����x�(�(�(�(�(�	)�	)r$c��dSr!rrLs r"r�zSequence.is_callable�
����ur$c��dSr!rrLs r"r�zSequence.is_clause_element�
rr$zsqlalchemy.sql.functions.funcc�:�|�||j���S)z�Return a :class:`.next_value` function element
        which will render the appropriate increment function
        for this :class:`.Sequence` within any SQL expression.

        �r�)�
next_valuer�)r=�funcs  r"rzSequence.next_value�
s�����t�$�)��4�4�4r$c���tt|���|��|�|j��dSr')r�r;r�r`r�)r=r�r�s  �r"r�zSequence._set_parent�
s=���
�h����)�)�&�1�1�1������0�0�0�0�0r$c�:�|�|j��dSr')rr)r=r�r*s   r"r�zSequence._set_table�
s�����5�>�*�*�*�*�*r$c�<�||_||jj|j<dSr')r�
_sequencesrr�s  r"rzSequence._set_metadata�
s �� ��
�.2��
� ���+�+�+r$c�,�|jr|jjSdSr'r�rLs r"r�z
Sequence.bind�
s���=�	��=�%�%��4r$c�l�|�t|��}|�tj||���dS)z&Creates this sequence in the database.Nrrrs   r"r	zSequence.create�
s:���<�!�$�'�'�D����#�-�t�
��K�K�K�K�Kr$c�l�|�t|��}|�tj||���dS)z&Drops this sequence from the database.Nrrrs   r"r
z
Sequence.drop�
s:���<�!�$�'�'�D����#�+�T�j��I�I�I�I�Ir$c�D�tjd|jjz���)Nz�This %s cannot be used directly as a column expression.  Use func.next_value(sequence) to produce a 'next value' function that's usable as a column element.r�rLs r"r�zSequence._not_a_column_exprs+���%�
#�&*�^�%<�
=�
�
�	
r$)NNNNNNNNNNFNNNF)NT)r]r^r_r`rar�r�rrdr�r�r�rr�r�rrbr�r	r
r�r#r$s@r"r;r;�	sv���������< �N��K�
���������������#n)�n)�n)�n)�`
�������
��������T��6�7�7�5�5�8�7�5�1�1�1�1�1�+�+�+�3�3�3�����X��L�L�L�L�J�J�J�J�
�
�
�
�
�
�
r$r;c�>�eZdZdZdZdZdZd
d�Zd�Zd�Z	d�Z
d�Zd	S)r=a�A marker for a transparent database-side default.

    Use :class:`.FetchedValue` when the database is configured
    to provide some automatic default for a column.

    E.g.::

        Column('foo', Integer, FetchedValue())

    Would indicate that some trigger or default generator
    will create a new value for the ``foo`` column during an
    INSERT.

    .. seealso::

        :ref:`triggered_columns`

    TFc��||_dSr'r4r�s  r"r�zFetchedValue.__init__#r�r$c�F�||jkr|S|�|��Sr')r5�_cloner�s  r"r>zFetchedValue._as_for_update&s&�����(�(��K��;�;�z�*�*�*r$c���|j�|j��}|j�|j��|j�dd��||_|S)Nr�)r�rnrS�updaterrr5)r=r5�ns   r"r%zFetchedValue._clone,sS���N�"�"�4�>�2�2��	�
���$�-�(�(�(�	�
���x��&�&�&�!����r$c�V�||_|jr||j_dS||j_dSr')r�r5r,r+r�s  r"r�zFetchedValue._set_parent3s3������?�	.�*.�D�K�'�'�'�)-�D�K�&�&�&r$c�*�tj|��Sr'rJrLs r"rMzFetchedValue.__repr__:s��� ��&�&�&r$Nr|)r]r^r_r`r��	reflected�has_argumentr�r>r%r�rMrr$r"r=r=
s���������&���I��L�%�%�%�%�+�+�+����.�.�.�'�'�'�'�'r$r=c�.��eZdZdZdZd�fd�	Zd�Z�xZS)r?a>A DDL-specified DEFAULT column value.

    :class:`.DefaultClause` is a :class:`.FetchedValue`
    that also generates a "DEFAULT" clause when
    "CREATE TABLE" is emitted.

    :class:`.DefaultClause` is generated automatically
    whenever the ``server_default``, ``server_onupdate`` arguments of
    :class:`_schema.Column` are used.  A :class:`.DefaultClause`
    can be passed positionally as well.

    For example, the following::

        Column('foo', Integer, server_default="50")

    Is equivalent to::

        Column('foo', Integer, DefaultClause("50"))

    TFc����tj|tjdttfd��tt|���|��||_||_	dS)Nrr�)
r�assert_arg_typer6rrr�r?r�r�r+)r=r�r5�
_reflectedr�s    �r"r�zDefaultClause.__init__Vs`������$�#�A�&�
�z�B�E�	
�	
�	
�	�m�T�"�"�+�+�J�7�7�7����#����r$c�(�d|j�d|j�d�S)NzDefaultClause(z
, for_update=r�)r�r5rLs r"rMzDefaultClause.__repr__^s���59�X�X�X�t����O�Or$)FF)r]r^r_r`r,r�rMr#r$s@r"r?r?>sd���������*�L�$�$�$�$�$�$�P�P�P�P�P�P�Pr$r?z0.6zy:class:`.PassiveDefault` is deprecated and will be removed in a future release.  Please refer to :class:`.DefaultClause`.c��eZdZdZd�ZdS)�PassiveDefaultz%A DDL-specified DEFAULT column value.c�0�tj|g|�Ri|��dSr')r?r�)r=r�r~s   r"r�zPassiveDefault.__init__js)����t�0�c�0�0�0�R�0�0�0�0�0r$Nrrr$r"r3r3bs+������0�/�1�1�1�1�1r$r3c�L�eZdZdZdZ						d	d�Zed���Zd�Zd�Z	dS)
�
ConstraintzA table-level SQL constraint.r�NFc��||_||_||_|r||_||_||_t
j|��|�|��dS)a�Create a SQL constraint.

        :param name:
          Optional, the in-database name of this ``Constraint``.

        :param deferrable:
          Optional bool.  If set, emit DEFERRABLE or NOT DEFERRABLE when
          issuing DDL for this constraint.

        :param initially:
          Optional string.  If set, emit INITIALLY <value> when issuing DDL
          for this constraint.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param _create_rule:
          a callable which is passed the DDLCompiler object during
          compilation. Returns True or False to signal inline generation of
          this Constraint.

          The AddConstraint and DropConstraint DDL constructs provide
          DDLElement's more comprehensive "conditional DDL" approach that is
          passed a database connection when DDL is being issued. _create_rule
          is instead called during any CREATE TABLE compilation, where there
          may not be any transaction/connection in progress. However, it
          allows conditional compilation of the constraint even for backends
          which do not support addition of constraints through ALTER TABLE,
          which currently includes SQLite.

          _create_rule is used by some types to create constraints.
          Currently, its call signature is subject to change at any time.

        :param \**dialect_kw:  Additional keyword arguments are dialect
            specific, and passed in the form ``<dialectname>_<argname>``.  See
            the documentation regarding an individual dialect at
            :ref:`dialect_toplevel` for detail on documented arguments.

        N)	r r�r�rH�_create_rulerrr@r�)r=r r�r�r8rHrr�s        r"r�zConstraint.__init__ssd��h��	�$���"����	��D�I�(���&������%�%�%��%�%�j�1�1�1�1�1r$c��	t|jt��r|jSn#t$rYnwxYwt	jd���)NzdThis constraint is not bound to a table.  Did you mean to call table.append_constraint(constraint) ?)r(r�rfr:rrurLs r"r*zConstraint.table�sc��	��$�+�u�-�-�
#��{�"�
#���	�	�	��D�	�����%�
A�
�
�	
s� $�
1�1c�H�||_|j�|��dSr')r�r�r��r=r�s  r"r�zConstraint._set_parent�s&���������t�$�$�$�$�$r$c��t���r')�NotImplementedError)r=r~s  r"rTzConstraint.copy�s��!�#�#�#r$)NNNNNF)
r]r^r_r`rar�rbr*r�rTrr$r"r6r6ns�������'�'�!�N�����
��<2�<2�<2�<2�|�	
�	
��X�	
�%�%�%�$�$�$�$�$r$r6c��t|d��r|���}t|t��st	jd���|S)Nr�zschema.Column object expected)r7r�r(r)rr<)�elements r"�_to_schema_columnr@�sP���w�,�-�-�/��,�,�.�.���g�v�&�&�A��� ?�@�@�@��Nr$c���|�|St|d��r|���}t|tjt
fz��sd}t
j||z���|S)Nr�z1Element %r is not a string name or column element)r7r�r(rr6rrr<)r?r�s  r"�_to_schema_column_or_stringrB�sl������	��.�	/�	/�/��,�,�.�.���g�t�0�M�3C�C�D�D�/�A�����g�
�.�.�.��Nr$c�H�eZdZdZ	dZd�Zed���Zdd�Zd�Z	d�Z
dS)	�ColumnCollectionMixinNFc���|�dd��}|�dd��|_t��|_d�|D��|_|r|jr|���dSdSdS)N�_autoattachTrFc�,�g|]}t|����Sr)rBr�s  r"r�z2ColumnCollectionMixin.__init__.<locals>.<listcomp>�s.��!
�!
�!
�/0�'��*�*�!
�!
�!
r$)rrrr	r��_pending_colargs�
_check_attach)r=r�r~rFs    r"r�zColumnCollectionMixin.__init__�s����f�f�]�D�1�1���F�F�>�5�9�9���'�)�)���!
�!
�4;�!
�!
�!
����	!�4�0�	!���� � � � � �	!�	!�	!�	!r$c#�K�|D]�}d}d}t|d��r|���}t|ttf��s|}n)g}tj|id|ji��|r|d}|�|n|}||||fV���dS)Nr�r�r)r7r�r(rrr�traverser)r}rr�strnamer��cols�add_elements       r"�"_extract_col_expression_collectionz8ColumnCollectionMixin._extract_col_expression_collection�s������	5�	5�D��G��F��t�1�2�2�
1��.�.�0�0���d�]�J�$?�@�@�
%�������!�$��X�t�{�,C�D�D�D��%�!�!�W�F�$*�$6�&�&�G�K�����4�4�4�4�4�	5�	5r$c����
��d��jD��}d�|D��}t|���|���
�
rh|r
Jd���td��jD�����|��}|s)�
�fd�}�
�_�
D]}|�|���dS|}d�|D��}t|��dkr)��|�����dSt|��dkri�jsd|dj	��fd	�|dd�D��}	|	rAtjd
d�d�|	D�����d
�j
�d����dSdSdS)Nc�<�g|]}t|t���|��Sr)r(r)r�s  r"r�z7ColumnCollectionMixin._check_attach.<locals>.<listcomp>s'��N�N�N�!�
�1�f�8M�8M�N�A�N�N�Nr$c�F�g|]}t|jt���|��Sr)r(r*rfr�s  r"r�z7ColumnCollectionMixin._check_attach.<locals>.<listcomp>s)��J�J�J�a�z�!�'�5�/I�/I�J��J�J�Jr$z#Should not reach here on event callc3�K�|]}|�|V��	dSr'rr�s  r"r�z6ColumnCollectionMixin._check_attach.<locals>.<genexpr>s+����"�"��A�M��M�M�M�M�"�"r$c���t|t��r/��|���s��d���dSdSdS)NT)r�)r(rf�discardrI)r�r*�
cols_wo_tabler=s  ��r"�
_col_attachedz:ColumnCollectionMixin._check_attach.<locals>._col_attachedsd���"�%��/�/�9�%�-�-�f�5�5�5�,�9� �.�.�4�.�8�8�8�8�8�9�9�9�9r$c��h|]	}|j��
Sr�r*r�s  r"�	<setcomp>z6ColumnCollectionMixin._check_attach.<locals>.<setcomp>$s��+�+�+�a�!�'�+�+�+r$rrc�&��g|]
}|j�u�|��SrrY)r�r,r*s  �r"r�z7ColumnCollectionMixin._check_attach.<locals>.<listcomp>)s%���E�E�E�A���u�0D�0D�a�0D�0D�0Dr$z
Column(s) r�c3� K�|]	}d|zV��
dS�z'%s'Nrr�s  r"r�z6ColumnCollectionMixin._check_attach.<locals>.<genexpr>.s&����!=�!=��&�1�*�!=�!=�!=�!=�!=�!=r$z are not part of table '�'.)rHr��
difference�_cols_wo_tabler`r�r9rr�_allow_multiple_tablesr*rr<r�r�)r=r��col_objs�cols_w_table�has_string_colsrWr-r�rs�othersrVr*s`         @@r"rIz#ColumnCollectionMixin._check_attachs������N�N�t�4�N�N�N��J�J�8�J�J�J���H�
�
�0�0��>�>�
��	��A�A�A�A�A�7�"�"�"��0�"�"�"����j��"�"�
�#�
�9�9�9�9�9�9�'4��#�(�8�8�C��(�(��7�7�7�7�����+�+�7�+�+�+���v�;�;�!����*�*�6�:�:�<�<�8�8�8�8�8�
��[�[�1�_�_�T�%@�_��A�J�$�E�E�E�E�E������E�E�E�F��
��'�'��	�	�!=�!=�f�!=�!=�!=�=�=�=�=��)�)�)�����	�_�_�_�
�
r$c�*���fd�|jD��S)Nc�b��g|]+}t|tj��r
�j|n|��,Sr)r(rr6r,)r�r-r*s  �r"r�z:ColumnCollectionMixin._col_expressions.<locals>.<listcomp>4sE���
�
�
��'�s�D�,=�>�>�G�E�G�C�L�L�C�
�
�
r$)rHr�s `r"�_col_expressionsz&ColumnCollectionMixin._col_expressions3s1���
�
�
�
��,�
�
�
�	
r$c�n�|�|��D]}|�|j�|���dSr')rhr�r�)r=r*r-s   r"r�z!ColumnCollectionMixin._set_parent9sE���(�(��/�/�	&�	&�C����� � ��%�%�%��	&�	&r$r|)r]r^r_r�rar��classmethodrOrIrhr�rr$r"rDrD�s��������G��#��!�!�!��5�5��[�5�$/�/�/�/�b
�
�
�&�&�&�&�&r$rDc�D�eZdZdZd�ZdZ	d�Zd�Zd
d�Zd�Z	d�Z
d	�ZdS)�ColumnCollectionConstraintz-A constraint that proxies a ColumnCollection.c��|�dd��}|�dd��}tj|fi|��tj|g|�R||d��dS)aZ
        :param \*columns:
          A sequence of column names or Column objects.

        :param name:
          Optional, the in-database name of this constraint.

        :param deferrable:
          Optional bool.  If set, emit DEFERRABLE or NOT DEFERRABLE when
          issuing DDL for this constraint.

        :param initially:
          Optional string.  If set, emit INITIALLY <value> when issuing DDL
          for this constraint.

        :param \**kw: other keyword arguments including dialect-specific
          arguments are propagated to the :class:`.Constraint` superclass.

        rFTrF)rFrN)rrr6r�rD)r=r�r~rFrs     r"r�z#ColumnCollectionConstraint.__init__Bs���(�f�f�]�D�1�1���v�v�n�e�4�4����D�'�'�B�'�'�'��&��	
��	
�	
�(3�,�	
�	
�	
�	
�	
�	
r$Nc�r�t�||��t�||��dSr')r6r�rDr�s  r"r�z&ColumnCollectionConstraint._set_parentcs4�����t�U�+�+�+��)�)�$��6�6�6�6�6r$c��||jvSr')r�)r=r�s  r"�__contains__z'ColumnCollectionConstraint.__contains__gs���D�L� � r$c����i}�jD]9}�j|j}|���D]\}}|||dz|z<��:�j��fd��jD���j�j�jd�|��}��|��S)Nr�c�<��g|]}t|�j�����Sr)r3r�)r�rr=r/s  ��r"r�z3ColumnCollectionConstraint.copy.<locals>.<listcomp>{s7�������!��t�{�L�A�A���r$)r r�r�)	rfrgrhr�r�r r�r�rW)	r=r/r~�constraint_kwargsrlrfrmrnr,s	``       r"rTzColumnCollectionConstraint.copyjs������� �0�	)�	)�L�"�2�<�@�N�O�!�&�&�(�(�
)�
)��"�$�)�"� �3�&�);�;���	
)�
�D�N������ �L���������n�	
�	
� �	
�	
���%�%�a�(�(�(r$c�6�|j�|��S)z�Return True if this constraint contains the given column.

        Note that this object also contains an attribute ``.columns``
        which is a :class:`_expression.ColumnCollection` of
        :class:`_schema.Column` objects.

        )r��contains_column�r=r-s  r"ruz*ColumnCollectionConstraint.contains_column�s���|�+�+�C�0�0�0r$c�B��|jj��fd��jD��S)Nc3�(�K�|]}�|V��
dSr'r)r�r+�ordered_dicts  �r"r�z6ColumnCollectionConstraint.__iter__.<locals>.<genexpr>�s(�����@�@�c��S�!�@�@�@�@�@�@r$)r��_data�_list)r=rys @r"�__iter__z#ColumnCollectionConstraint.__iter__�s,����|�)��@�@�@�@�\�-?�@�@�@�@r$c�4�t|jj��Sr')r�r�rzrLs r"�__len__z"ColumnCollectionConstraint.__len__�s���4�<�%�&�&�&r$r')r]r^r_r`r�r�r�rprTrur|r~rr$r"rlrl?s�������7�7�
�
�
�6�G��
7�7�7�!�!�!�)�)�)�)�2	1�	1�	1�A�A�A�'�'�'�'�'r$rlc���eZdZdZdZeddd��								d�fd�	��Zd	�Zee��Zdd
�Z	�xZ
S)
�CheckConstraintzlA table- or column-level CHECK constraint.

    Can be included in the definition of a Table or Column.
    T�sqltextz:class:`.CheckConstraint`z$:paramref:`.CheckConstraint.sqltext`NFc
���t|d���|_g}tj|jid|ji��tt|��j|||||||	|d�|
��|�|�|��dSdS)a�Construct a CHECK constraint.

        :param sqltext:
         A string containing the constraint definition, which will be used
         verbatim, or a SQL expression construct.   If given as a string,
         the object is converted to a :func:`_expression.text` object.
         If the textual
         string includes a colon character, escape this using a backslash::

           CheckConstraint(r"foo ~ E'a(?\:b|c)d")

        :param name:
          Optional, the in-database name of the constraint.

        :param deferrable:
          Optional bool.  If set, emit DEFERRABLE or NOT DEFERRABLE when
          issuing DDL for this constraint.

        :param initially:
          Optional string.  If set, emit INITIALLY <value> when issuing DDL
          for this constraint.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        T��allow_coercion_to_textr�)r r�r�r8rHrrFN)	rr�rrKrr�r�r�r9)
r=r�r r�r�r*rHr8rFrr~r�r�s
            �r"r�zCheckConstraint.__init__�s����^(���M�M�M�������$�,��X�w�~�,F�G�G�G�-��o�t�$�$�-���!��%��#�#�
	
�
	
��
	
�
	
�
	
����*�*�5�1�1�1�1�1��r$c�>�t|jt��rdSdS)N�check_constraint�column_check_constraint)r(r�rfrLs r"razCheckConstraint.__visit_name__�s"���d�k�5�)�)�	-�%�%�,�,r$c
���|�t|j|j|��}n|j}t||j|j|j|j|d|j���}|�	|��S)NF)r r�r�r8r*rFr)
r3r�r*r�r r�r�r8rrW)r=r/r~r�r,s     r"rTzCheckConstraint.copy�sv���#�'�t�|�T�Z��N�N�G�G��l�G������n����*����(�	
�	
�	
���%�%�a�(�(�(r$)NNNNNNTFr')r]r^r_r`rar
r�rarbrTr#r$s@r"r�r��s����������
"�����#�.�������
����;2�;2�;2�;2�;2���
;2�z-�-�-��X�n�-�-�N�)�)�)�)�)�)�)�)r$r�c���eZdZdZdZ										dd�Zd�ZdZ	dZ	e	d���Z
e	d���Ze	d	���Zd
�Z
e	d���Ze	d���Zd
�Zdd�ZdS)ra�A table-level FOREIGN KEY constraint.

    Defines a single column or composite FOREIGN KEY ... REFERENCES
    constraint. For a no-frills, single column foreign key, adding a
    :class:`_schema.ForeignKey` to the definition of a :class:`_schema.Column`
    is a
    shorthand equivalent for an unnamed, single column
    :class:`_schema.ForeignKeyConstraint`.

    Examples of foreign key configuration are in :ref:`metadata_foreignkeys`.

    �foreign_key_constraintNFc
�2��tj�f||||d�|
��|�_|�_|	�_|�_|
�_tt|����t|��krUtt|����t|��krtj
d���tj
d����fd�|D���_tj�g|�R�|�2t�d��r|�jusJ���|��dSdS)a-Construct a composite-capable FOREIGN KEY.

        :param columns: A sequence of local column names. The named columns
          must be defined and present in the parent Table. The names should
          match the ``key`` given to each column (defaults to the name) unless
          ``link_to_name`` is True.

        :param refcolumns: A sequence of foreign column names or Column
          objects. The columns must all be located within the same Table.

        :param name: Optional, the in-database name of the key.

        :param onupdate: Optional string. If set, emit ON UPDATE <value> when
          issuing DDL for this constraint. Typical values include CASCADE,
          DELETE and RESTRICT.

        :param ondelete: Optional string. If set, emit ON DELETE <value> when
          issuing DDL for this constraint. Typical values include CASCADE,
          DELETE and RESTRICT.

        :param deferrable: Optional bool. If set, emit DEFERRABLE or NOT
          DEFERRABLE when issuing DDL for this constraint.

        :param initially: Optional string. If set, emit INITIALLY <value> when
          issuing DDL for this constraint.

        :param link_to_name: if True, the string name given in ``column`` is
          the rendered name of the referenced column, not its locally assigned
          ``key``.

        :param use_alter: If True, do not emit the DDL for this constraint as
          part of the CREATE TABLE definition. Instead, generate it via an
          ALTER TABLE statement issued after the full collection of tables
          have been created, and drop it via an ALTER TABLE statement before
          the full collection of tables are dropped.

          The use of :paramref:`_schema.ForeignKeyConstraint.use_alter` is
          particularly geared towards the case where two or more tables
          are established within a mutually-dependent foreign key constraint
          relationship; however, the :meth:`_schema.MetaData.create_all` and
          :meth:`_schema.MetaData.drop_all`
          methods will perform this resolution
          automatically, so the flag is normally not needed.

          .. versionchanged:: 1.0.0  Automatic resolution of foreign key
             cycles has been added, removing the need to use the
             :paramref:`_schema.ForeignKeyConstraint.use_alter` in typical use
             cases.

          .. seealso::

                :ref:`use_alter`

        :param match: Optional string. If set, emit MATCH <value> when issuing
          DDL for this constraint. Typical values include SIMPLE, PARTIAL
          and FULL.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param \**dialect_kw:  Additional keyword arguments are dialect
          specific, and passed in the form ``<dialectname>_<argname>``.  See
          the documentation regarding an individual dialect at
          :ref:`dialect_toplevel` for detail on documented arguments.

            .. versionadded:: 0.9.2

        )r r�r�rHzOForeignKeyConstraint with duplicate source column references are not supported.z_ForeignKeyConstraint number of constrained columns must match the number of referenced columns.c���g|]F}t|f��j�j�j�j�j�j�j�jd�	�j	����GS))	rqr r/r�r�r\r�r�r�)
rrr r/r�r�r\r�r�r��dialect_kwargs)r��refcolr=s  �r"r�z1ForeignKeyConstraint.__init__.<locals>.<listcomp>�
s{���
�
�
��
��
� ��Y������.�!�.��j��?��.�
�
��%�
�
�
�
�
r$Nr�)r6r�r/r�r\r�r�r�r�rr<�elementsrDr7r�r9)r=r��
refcolumnsr r/r�r�r�r�r\r�r*rHr�s`             r"r�zForeignKeyConstraint.__init__
sl���n	���	
��!���	
�	
��
	
�	
�	
�!��
� ��
�(���"�����
��s�7�|�|����J���/�/��3�w�<�<� � �C��L�L�0�0��'�4�����'�*����
�
�
�
�%�
�
�
��
�"	�&�t�6�g�6�6�6�6����t�X�&�&�
,����+�+�+�+��*�*�5�1�1�1�1�1��r$c�n�|j�|��|j�|��dSr')r�r�r�rrHs   r"r�z$ForeignKeyConstraint._append_element�
s4������� � � ��
���R� � � � � r$c�Z�tjt|j|j����Sr')r�OrderedDict�zip�column_keysr�rLs r"�	_elementszForeignKeyConstraint._elements�
s$�����D�$4�d�m� D� D�E�E�Er$c�*�|jD]
}|jcSdSr')r�r)r=�elems  r"rz%ForeignKeyConstraint._referred_schema�
s'���M�	�	�D��(�(�(�(��4r$c�0�|jdjjS)alThe :class:`_schema.Table` object to which this
        :class:`_schema.ForeignKeyConstraint` references.

        This is a dynamically calculated attribute which may not be available
        if the constraint and/or parent table is not yet associated with
        a metadata collection that contains the referred table.

        .. versionadded:: 1.0.0

        r)r�r�r*rLs r"�referred_tablez#ForeignKeyConstraint.referred_table�
s���}�Q��&�,�,r$c
��td�|jD����}d|vrWt|��dkrFt|��dd�\}}t	jd|j�d|j�d|�d|�����dSdS)	Nc�6�g|]}|�����Sr)r�)r�r�s  r"r�z=ForeignKeyConstraint._validate_dest_table.<locals>.<listcomp>�
s"��F�F�F��$�/�/�+�+�F�F�Fr$rrrzForeignKeyConstraint on �(z$) refers to multiple remote tables: � and )r�r�r�r�rr<r��_col_description)r=r*�
table_keys�elem0�elem1s     r"r�z)ForeignKeyConstraint._validate_dest_table�
s����F�F��
�F�F�F�G�G�
��z�!�!�c�*�o�o��&9�&9�!�*�-�-�a��c�2�L�E�5��#�#��>�>�>�4�#8�#8�#8�%�%�%���H���
�"�!�&9�&9r$c�v�t|d��r|j���Sd�|jD��S)a�Return a list of string keys representing the local
        columns in this :class:`_schema.ForeignKeyConstraint`.

        This list is either the original string arguments sent
        to the constructor of the :class:`_schema.ForeignKeyConstraint`,
        or if the constraint has been initialized with :class:`_schema.Column`
        objects, is the string ``.key`` of each element.

        .. versionadded:: 1.0.0

        r�c�d�g|]-}t|t��r|jnt|����.Sr)r(rr+�str)r�r-s  r"r�z4ForeignKeyConstraint.column_keys.<locals>.<listcomp>�
sC������&�c�=�9�9�G����s�3�x�x���r$)r7r��keysrHrLs r"r�z ForeignKeyConstraint.column_keys�
sN���4��"�"�	��<�$�$�&�&�&����0����
r$c�6�d�|j��S)Nr�)r�r�rLs r"r�z%ForeignKeyConstraint._col_description�
s���y�y��)�*�*�*r$c
���t�||��	t�||��nV#t$rI}t	jt
jd|j�d|j	d�d���|���Yd}~nd}~wwxYwt|j|j��D]3\}}t|d��r	|j|ur|�|���4|�|��dS)Nz,Can't create ForeignKeyConstraint on table 'z': no column named 'rz
' is present.rtr�)r6r�rl�KeyErrorrr;rr<r�r>r�r�r�r7r�r9r�)r=r*�ker-rIs     r"r�z ForeignKeyConstraint._set_parent�
s/�����t�U�+�+�+�
	�&�2�2�4��?�?�?�?���	�	�	��K��!�!�16�0A�0A�0A�2�7�1�:�:�:�O���
�

�
�
�
�
�
�
�
�
�����	�����4�<���7�7�	2�	2�G�C���2�x�(�(�
2�B�I�S�,@�,@��,�,�S�1�1�1���!�!�%�(�(�(�(�(s�9�
B�?B�Bc�^���td�|jD����fd�|jD��|j|j|j|j|j|j|j|j	��
�
}t|j|j��D]\}}|�|���|�|��S)Nc�&�g|]}|jj��Sr)r�r+r�s  r"r�z-ForeignKeyConstraint.copy.<locals>.<listcomp>
s��1�1�1�a�Q�X�\�1�1�1r$c���g|]I}|����.|���|jjjkr�jnd�����JS)N)r!r�)r�r�r�r*r+r )r�r�r!r/s  ��r"r�z-ForeignKeyConstraint.copy.<locals>.<listcomp>sq���	
�	
�	
�����!�#�/������!�(�.�*<�<�<� ,�0�0�����	
�	
�	
r$)r r/r�r�r�r�r\r�)rr�r r/r�r�r�r�r\r�r�rW)r=r!r/r~r��self_fk�other_fks ``    r"rTzForeignKeyConstraint.copys�����"�1�1�4�=�1�1�1�	
�	
�	
�	
�	
���	
�	
�	
����]��]��n����n��*��*�'
�
�
��*"%�T�]�C�L�!A�!A�	0�	0��G�X��%�%�h�/�/�/�/��%�%�c�*�*�*r$)
NNNNNFFNNNr�)r]r^r_r`rar�r�r�r�rbr�rr�r�r�r�r�rTrr$r"rr
sA��������.�N����������
�O2�O2�O2�O2�b!�!�!��G��
�H���F�F��X�F�����X���-�-��X�-��������X��(�+�+��X�+�)�)�)�*+�+�+�+�+�+r$rc�r��eZdZdZdZ�fd�Z�fd�Zd�Zd�Ze	d���Z
ejd���Z
�xZS)	r�a�
A table-level PRIMARY KEY constraint.

    The :class:`.PrimaryKeyConstraint` object is present automatically
    on any :class:`_schema.Table` object; it is assigned a set of
    :class:`_schema.Column` objects corresponding to those marked with
    the :paramref:`_schema.Column.primary_key` flag::

        >>> my_table = Table('mytable', metadata,
        ...                 Column('id', Integer, primary_key=True),
        ...                 Column('version_id', Integer, primary_key=True),
        ...                 Column('data', String(50))
        ...     )
        >>> my_table.primary_key
        PrimaryKeyConstraint(
            Column('id', Integer(), table=<mytable>,
                   primary_key=True, nullable=False),
            Column('version_id', Integer(), table=<mytable>,
                   primary_key=True, nullable=False)
        )

    The primary key of a :class:`_schema.Table` can also be specified by using
    a :class:`.PrimaryKeyConstraint` object explicitly; in this mode of usage,
    the "name" of the constraint can also be specified, as well as other
    options which may be recognized by dialects::

        my_table = Table('mytable', metadata,
                    Column('id', Integer),
                    Column('version_id', Integer),
                    Column('data', String(50)),
                    PrimaryKeyConstraint('id', 'version_id',
                                         name='mytable_pk')
                )

    The two styles of column-specification should generally not be mixed.
    An warning is emitted if the columns present in the
    :class:`.PrimaryKeyConstraint`
    don't match the columns that were marked as ``primary_key=True``, if both
    are present; in this case, the columns are taken strictly from the
    :class:`.PrimaryKeyConstraint` declaration, and those columns otherwise
    marked as ``primary_key=True`` are ignored.  This behavior is intended to
    be backwards compatible with previous behavior.

    .. versionchanged:: 0.9.2  Using a mixture of columns within a
       :class:`.PrimaryKeyConstraint` in addition to columns marked as
       ``primary_key=True`` now emits a warning if the lists don't match.
       The ultimate behavior of ignoring those columns marked with the flag
       only is currently maintained for backwards compatibility; this warning
       may raise an exception in a future release.

    For the use case where specific options are to be specified on the
    :class:`.PrimaryKeyConstraint`, but the usual style of using
    ``primary_key=True`` flags is still desirable, an empty
    :class:`.PrimaryKeyConstraint` may be specified, which will take on the
    primary key column collection from the :class:`_schema.Table` based on the
    flags::

        my_table = Table('mytable', metadata,
                    Column('id', Integer, primary_key=True),
                    Column('version_id', Integer, primary_key=True),
                    Column('data', String(50)),
                    PrimaryKeyConstraint(name='mytable_pk',
                                         mssql_clustered=True)
                )

    .. versionadded:: 0.9.2 an empty :class:`.PrimaryKeyConstraint` may now
       be specified for the purposes of establishing keyword arguments with
       the constraint, independently of the specification of "primary key"
       columns within the :class:`_schema.Table` itself; columns marked as
       ``primary_key=True`` will be gathered into the empty constraint's
       column collection.

    �primary_key_constraintc�~��|�dd��|_tt|��j|i|��dS)Nr�F)rrr�r�r�r�)r=r�r~r�s   �r"r�zPrimaryKeyConstraint.__init__osC���#%�6�6�*?��#G�#G�� �2��"�D�)�)�2�G�B�r�B�B�B�B�Br$c
���tt|���|��|j|ur@|j�|j��||_|j�|��d�|jD��}|jr�|r�t|��t|j�
����kr�tjd|j
�dd�d�|D�����dd�d�|jD�����dd�d	�|jD�����d
�	��g|dd�<|jD]}d|_d|_�|j�|��dS)
Nc� �g|]}|j�	|��Sr)r�r�s  r"r�z4PrimaryKeyConstraint._set_parent.<locals>.<listcomp>{s��9�9�9�1�1�=�9�Q�9�9�9r$zTable 'z' specifies columns r�c3�*K�|]}d|jzV��dSr]r�r�s  r"r�z3PrimaryKeyConstraint._set_parent.<locals>.<genexpr>�s(����A�A�!�f�q�v�o�A�A�A�A�A�Ar$z= as primary_key=True, not matching locally specified columns c3�*K�|]}d|jzV��dSr]r�r�s  r"r�z3PrimaryKeyConstraint._set_parent.<locals>.<genexpr>��(����D�D�!�f�q�v�o�D�D�D�D�D�Dr$z-; setting the current primary key columns to c3�*K�|]}d|jzV��dSr]r�r�s  r"r�z3PrimaryKeyConstraint._set_parent.<locals>.<genexpr>�r�r$z:. This warning may become an exception in a future releaseTF)r�r�r�r�r�rUr�r,r�r��valuesrrr r�r)�extend)r=r*�	table_pksr,r�s    �r"r�z PrimaryKeyConstraint._set_parentss����
�"�D�)�)�5�5�e�<�<�<���D�(�(���%�%�e�&7�8�8�8� $�E����!�!�$�'�'�'�9�9���9�9�9�	��L�	��	��I���#�d�l�&9�&9�&;�&;�"<�"<�<�<��I�I��J�J�J��I�I�A�A�y�A�A�A�A�A�A�A��I�I�D�D�t�|�D�D�D�D�D�D�D��I�I�D�D�t�|�D�D�D�D�D�D�D�	�
�
�
��I�a�a�a�L���	�	�A� �A�M��A�J�J�����I�&�&�&�&�&r$c���|D]	}d|_�
|j�|��tj�|��|�|j��dS)aKrepopulate this :class:`.PrimaryKeyConstraint` given
        a set of columns.

        Existing columns in the table that are marked as primary_key=True
        are maintained.

        Also fires a new event.

        This is basically like putting a whole new
        :class:`.PrimaryKeyConstraint` object on the parent
        :class:`_schema.Table` object without actually replacing the object.

        The ordering of the given list of columns is also maintained; these
        columns will be appended to the list of columns after any which
        are already present.

        TN)r�r�r�r�r��_resetr9r*)r=r�r-s   r"�_reloadzPrimaryKeyConstraint._reload�se��*�	#�	#�C�"�C�O�O�����G�$�$�$��2�9�9�$�?�?�?��&�&�t�z�2�2�2�2�2r$c��tj�|��|j�|��|j�||��dSr')r�r�r�r�r0rU�'_sa_event_column_added_to_pk_constraintrvs  r"rVzPrimaryKeyConstraint._replace�sM���2�9�9�$�?�?�?�����S�!�!�!��
�=�=�d�C�H�H�H�H�Hr$c�l��|j����g�fd�|jD��zSt|j��S)Nc���g|]}|�u�|��	Srr)r�r,�autoincs  �r"r�z>PrimaryKeyConstraint.columns_autoinc_first.<locals>.<listcomp>�s#���L�L�L�a�1�G�;K�;K��;K�;K�;Kr$)r�r�r�)r=r�s @r"�columns_autoinc_firstz*PrimaryKeyConstraint.columns_autoinc_first�sE����,�����9�L�L�L�L�4�<�L�L�L�L�L����%�%�%r$c�h�d�}t|j��dkrLt|j��d}|jdur||d��|S|jdvr||d��r|SdSdSd}|jD]@}|jdur5||d��|�%t	jd|j�d|j�d	����|}�A|S)
Nc�L�|jj�)t|jjtjj��s$|r tjd|j�d|�d����dSt|jtd��tf��s|sdS|j
�|sdS|jr|jdvrdSdS)NzColumn type z on column 'z+' is not compatible with autoincrement=TrueF)T�	ignore_fkT)
r9�_type_affinity�
issubclassr�INTEGERTYPErr<r(r*r;r+r�r0)r-�autoinc_trues  r"�_validate_autoinczEPrimaryKeyConstraint._autoincrement_column.<locals>._validate_autoinc�s����x�&�.�j���'��)=�)L�7�7�.� �!��+�+�@C����#�#�#�O����
!�5��s�{�T�$�Z�Z��,B�C�C�
�$�
��u��#�/��/��u��!�
�c�&7�@�'�'��u��4r$rrT)r1r�Fz=Only one Column may be marked autoincrement=True, found both r�r)r�r�r�r0rr<r )r=r�r-r�s    r"r�z*PrimaryKeyConstraint._autoincrement_column�s%��	�	�	�2�t�|����!�!��t�|�$�$�Q�'�C�� �D�(�(�!�!�#�t�,�,�,��
��!����
&�%�c�5�1�1���
������G��|�

&�

&���$��,�,�%�%�c�4�0�0�0��*�!�/�/� #�x�x�x�����7����#&����Nr$)r]r^r_r`rar�r�r�rVrbr�rrdr�r#r$s@r"r�r�#s��������G�G�R.�N�C�C�C�C�C�'�'�'�'�'�B3�3�3�:I�I�I��&�&��X�&�
��8�8���8�8�8�8�8r$r�c��eZdZdZdZdS)rWaA table-level UNIQUE constraint.

    Defines a single column or composite UNIQUE constraint. For a no-frills,
    single column constraint, adding ``unique=True`` to the ``Column``
    definition is a shorthand equivalent for an unnamed, single column
    UniqueConstraint.
    �unique_constraintN)r]r^r_r`rarr$r"rWrW�s��������)�N�N�Nr$rWc�N�eZdZdZdZd�Zd�Zed���Zd
d�Z	d
d�Z
d	�ZdS)ra�	A table-level INDEX.

    Defines a composite (one or more column) INDEX.

    E.g.::

        sometable = Table("sometable", metadata,
                        Column("name", String(50)),
                        Column("address", String(100))
                    )

        Index("some_index", sometable.c.name)

    For a no-frills, single column index, adding
    :class:`_schema.Column` also supports ``index=True``::

        sometable = Table("sometable", metadata,
                        Column("name", String(50), index=True)
                    )

    For a composite index, multiple columns can be specified::

        Index("some_index", sometable.c.name, sometable.c.address)

    Functional indexes are supported as well, typically by using the
    :data:`.func` construct in conjunction with table-bound
    :class:`_schema.Column` objects::

        Index("some_index", func.lower(sometable.c.name))

    An :class:`.Index` can also be manually associated with a
    :class:`_schema.Table`,
    either through inline declaration or using
    :meth:`_schema.Table.append_constraint`.  When this approach is used,
    the names
    of the indexed columns can be specified as strings::

        Table("sometable", metadata,
                        Column("name", String(50)),
                        Column("address", String(100)),
                        Index("some_index", "name", "address")
                )

    To support functional or expression-based indexes in this form, the
    :func:`_expression.text` construct may be used::

        from sqlalchemy import text

        Table("sometable", metadata,
                        Column("name", String(50)),
                        Column("address", String(100)),
                        Index("some_index", text("lower(name)"))
                )

    .. versionadded:: 0.9.5 the :func:`_expression.text`
       construct may be used to
       specify :class:`.Index` expressions, provided the :class:`.Index`
       is explicitly associated with the :class:`_schema.Table`.


    .. seealso::

        :ref:`schema_indexes` - General information on :class:`.Index`.

        :ref:`postgresql_indexes` - PostgreSQL-specific options available for
        the :class:`.Index` construct.

        :ref:`mysql_indexes` - MySQL-specific options available for the
        :class:`.Index` construct.

        :ref:`mssql_indexes` - MSSQL-specific options available for the
        :class:`.Index` construct.

    rc�d�dx|_}g}g}|�|��D]1\}}}	}
|�|
��|�|���2||_t	||�dd����|_|�dd��|_|�dd��}d|vr|�d��|_d|vr|�d��}|�	|��tj|g|�Rd|i�|�|�|��dSdS)a�Construct an index object.

        :param name:
          The name of the index

        :param \*expressions:
          Column expressions to include in the index.   The expressions
          are normally instances of :class:`_schema.Column`, but may also
          be arbitrary SQL expressions which ultimately refer to a
          :class:`_schema.Column`.

        :param unique=False:
            Keyword only argument; if True, create a unique index.

        :param quote=None:
            Keyword only argument; whether to apply quoting to the name of
            the index.  Works in the same manner as that of
            :paramref:`_schema.Column.quote`.

        :param info=None: Optional data dictionary which will be populated
            into the :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param \**kw: Additional keyword arguments not mentioned above are
            dialect specific, and passed in the form
            ``<dialectname>_<argname>``. See the documentation regarding an
            individual dialect at :ref:`dialect_toplevel` for detail on
            documented arguments.

        NrPrFrrHr)
r*rOrrrrrr rrHr�rDr�r�)r=r rr~r*r��processed_expressionsrr�rLrNrs            r"r�zIndex.__init__Vsj��@"�!��
�U��� "���
4�
4�[�
A�
A�	/�	/�
������N�N�;�'�'�'�!�(�(��.�.�.�.�0�����b�f�f�W�d�&;�&;�<�<��	��f�f�X�u�-�-����v�v�n�e�4�4���R�<�<����v���D�I��r�>�>��F�F�8�$�$�E��%�%�b�)�)�)�	�&��	
��	
�	
�	
�)5�	
�	
�	
������U�#�#�#�#�#��r$c	��t�||��|j�;||jur2tjd|j�d|jj�d|j�d����||_|j�|��|j	}|�
|��}t|��t|��ksJ�d�t||��D��|_	dS)NzIndex 'z' is against table 'z(', and cannot be associated with table 'r^c�F�g|]\}}t|t��r|n|��Sr)r(r)r�r�colexprs   r"r�z%Index._set_parent.<locals>.<listcomp>�s?��
�
�
���g��t�]�3�3�@�D�D��
�
�
r$)
rDr�r*rr<r r�r�r�rrhr�r�)r=r*r�col_expressionss    r"r�zIndex._set_parent�s����)�)�$��6�6�6��:�!�e�4�:�&=�&=��#�#��9�9�9�d�j�4�4�4�e�6G�6G�6G�I���
�
��
�
�
���$�����&���/�/��6�6���;���3��#7�#7�7�7�7�7�
�
�!$�[�/�!B�!B�
�
�
����r$c��|jjS)z2Return the connectable associated with this Index.)r*r�rLs r"r�z
Index.bind�s���z��r$Nc�h�|�t|��}|�tj|��|S)z�Issue a ``CREATE`` statement for this
        :class:`.Index`, using the given :class:`.Connectable`
        for connectivity.

        .. seealso::

            :meth:`_schema.MetaData.create_all`.

        rrs  r"r	zIndex.create�s4���<�!�$�'�'�D����#�-�t�4�4�4��r$c�h�|�t|��}|�tj|��dS)z�Issue a ``DROP`` statement for this
        :class:`.Index`, using the given :class:`.Connectable`
        for connectivity.

        .. seealso::

            :meth:`_schema.MetaData.drop_all`.

        Nrrs  r"r
z
Index.drop�s5���<�!�$�'�'�D����#�+�T�2�2�2�2�2r$c��dd�t|j��gd�|jD��z|jrdgpgz��zS)Nz	Index(%s)r�c�,�g|]}t|����Srr�)r��es  r"r�z"Index.__repr__.<locals>.<listcomp>�s��5�5�5�q�4��7�7�5�5�5r$zunique=True)r�r�r rrrLs r"rMzIndex.__repr__�s]����I�I��d�i���!�5�5�D�$4�5�5�5�6��;�2�M�?�8�b�:�
�
�
�	
r$r')r]r^r_r`rar�r�rbr�r	r
rMrr$r"rrs�������I�I�V�N�B$�B$�B$�H
�
�
�(����X��

�
�
�
�3�3�3�3�
�
�
�
�
r$r�ixzix_%(column_0_label)sc�T�eZdZdZdZejd���						dd���ZdZ	d�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zejd��d���Zeee��Zd�Zd�Zed���Z							dd�Zejdd��d���Zdd�Zdd�ZdS)�MetaDataaDA collection of :class:`_schema.Table`
    objects and their associated schema
    constructs.

    Holds a collection of :class:`_schema.Table` objects as well as
    an optional binding to an :class:`_engine.Engine` or
    :class:`_engine.Connection`.  If bound, the :class:`_schema.Table` objects
    in the collection and their columns may participate in implicit SQL
    execution.

    The :class:`_schema.Table` objects themselves are stored in the
    :attr:`_schema.MetaData.tables` dictionary.

    :class:`_schema.MetaData` is a thread-safe object for read operations.
    Construction of new tables within a single :class:`_schema.MetaData`
    object,
    either explicitly or via reflection, may not be completely thread-safe.

    .. seealso::

        :ref:`metadata_describing` - Introduction to database metadata

    r)z0.8z�The :paramref:`_schema.MetaData.reflect` flag is deprecated and will be removed in a future release.   Please use the :meth:`_schema.MetaData.reflect` method.)�reflectNFc�l�tj��|_t||��|_|r|nt
|_|r||_t��|_	i|_
tjt��|_||_|r,|st!jd���|���dSdS)a�Create a new MetaData object.

        :param bind:
          An Engine or Connection to bind to.  May also be a string or URL
          instance, these are passed to :func:`_sa.create_engine` and
          this :class:`_schema.MetaData` will
          be bound to the resulting engine.

        :param reflect:
          Optional, automatically load all tables from the bound database.
          Defaults to False. :paramref:`_schema.MetaData.bind` is required
          when this option is set.

        :param schema:
           The default schema to use for the :class:`_schema.Table`,
           :class:`.Sequence`, and potentially other objects associated with
           this :class:`_schema.MetaData`. Defaults to ``None``.

           When this value is set, any :class:`_schema.Table` or
           :class:`.Sequence`
           which specifies ``None`` for the schema parameter will instead
           have this schema name defined.  To build a :class:`_schema.Table`
           or :class:`.Sequence` that still has ``None`` for the schema
           even when this parameter is present, use the :attr:`.BLANK_SCHEMA`
           symbol.

           .. note::

                As referred above, the :paramref:`_schema.MetaData.schema`
                parameter
                only refers to the **default value** that will be applied to
                the :paramref:`_schema.Table.schema` parameter of an incoming
                :class:`_schema.Table` object.   It does not refer to how the
                :class:`_schema.Table` is catalogued within the
                :class:`_schema.MetaData`,
                which remains consistent vs. a :class:`_schema.MetaData`
                collection
                that does not define this parameter.  The
                :class:`_schema.Table`
                within the :class:`_schema.MetaData`
                will still be keyed based on its
                schema-qualified name, e.g.
                ``my_metadata.tables["some_schema.my_table"]``.

                The current behavior of the :class:`_schema.ForeignKey`
                object is to
                circumvent this restriction, where it can locate a table given
                the table name alone, where the schema will be assumed to be
                present from this value as specified on the owning
                :class:`_schema.MetaData` collection.  However,
                this implies  that a
                table qualified with BLANK_SCHEMA cannot currently be referred
                to by string name from :class:`_schema.ForeignKey`.
                Other parts of
                SQLAlchemy such as Declarative may not have similar behaviors
                built in, however may do so in a future release, along with a
                consistent method of referring to a table in BLANK_SCHEMA.


           .. seealso::

                :paramref:`_schema.Table.schema`

                :paramref:`.Sequence.schema`

        :param quote_schema:
            Sets the ``quote_schema`` flag for those :class:`_schema.Table`,
            :class:`.Sequence`, and other objects which make usage of the
            local ``schema`` name.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param naming_convention: a dictionary referring to values which
          will establish default naming conventions for :class:`.Constraint`
          and :class:`.Index` objects, for those objects which are not given
          a name explicitly.

          The keys of this dictionary may be:

          * a constraint or Index class, e.g. the :class:`.UniqueConstraint`,
            :class:`_schema.ForeignKeyConstraint` class, the :class:`.Index`
            class

          * a string mnemonic for one of the known constraint classes;
            ``"fk"``, ``"pk"``, ``"ix"``, ``"ck"``, ``"uq"`` for foreign key,
            primary key, index, check, and unique constraint, respectively.

          * the string name of a user-defined "token" that can be used
            to define new naming tokens.

          The values associated with each "constraint class" or "constraint
          mnemonic" key are string naming templates, such as
          ``"uq_%(table_name)s_%(column_0_name)s"``,
          which describe how the name should be composed.  The values
          associated with user-defined "token" keys should be callables of the
          form ``fn(constraint, table)``, which accepts the constraint/index
          object and :class:`_schema.Table` as arguments, returning a string
          result.

          The built-in names are as follows, some of which may only be
          available for certain types of constraint:

            * ``%(table_name)s`` - the name of the :class:`_schema.Table`
              object
              associated with the constraint.

            * ``%(referred_table_name)s`` - the name of the
              :class:`_schema.Table`
              object associated with the referencing target of a
              :class:`_schema.ForeignKeyConstraint`.

            * ``%(column_0_name)s`` - the name of the :class:`_schema.Column`
              at
              index position "0" within the constraint.

            * ``%(column_0N_name)s`` - the name of all :class:`_schema.Column`
              objects in order within the constraint, joined without a
              separator.

            * ``%(column_0_N_name)s`` - the name of all
              :class:`_schema.Column`
              objects in order within the constraint, joined with an
              underscore as a separator.

            * ``%(column_0_label)s``, ``%(column_0N_label)s``,
              ``%(column_0_N_label)s`` - the label of either the zeroth
              :class:`_schema.Column` or all :class:`.Columns`, separated with
              or without an underscore

            * ``%(column_0_key)s``, ``%(column_0N_key)s``,
              ``%(column_0_N_key)s`` - the key of either the zeroth
              :class:`_schema.Column` or all :class:`.Columns`, separated with
              or without an underscore

            * ``%(referred_column_0_name)s``, ``%(referred_column_0N_name)s``
              ``%(referred_column_0_N_name)s``,  ``%(referred_column_0_key)s``,
              ``%(referred_column_0N_key)s``, ...  column tokens which
              render the names/keys/labels of columns that are referenced
              by a  :class:`_schema.ForeignKeyConstraint`.

            * ``%(constraint_name)s`` - a special key that refers to the
              existing name given to the constraint.  When this key is
              present, the :class:`.Constraint` object's existing name will be
              replaced with one that is composed from template string that
              uses this token. When this token is present, it is required that
              the :class:`.Constraint` is given an explicit name ahead of time.

            * user-defined: any additional token may be implemented by passing
              it along with a ``fn(constraint, table)`` callable to the
              naming_convention dictionary.

          .. versionadded:: 1.3.0 - added new ``%(column_0N_name)s``,
             ``%(column_0_N_name)s``, and related tokens that produce
             concatenations of names, keys, or labels for all columns referred
             to by a given constraint.

          .. seealso::

                :ref:`constraint_naming_conventions` - for detailed usage
                examples.

        z8A bind must be supplied in conjunction with reflect=TrueN)r�
immutabledictrsrr!�DEFAULT_NAMING_CONVENTION�naming_conventionrHr��_schemasr�collections�defaultdictr�r[r�rr<r�)r=r�r�r!r�r�rHs       r"r�zMetaData.__init__�s���n�(�*�*���!�&�,�7�7���!�
+���*�	
��
�	��D�I�����
����$�0��6�6�����	��	��
��'�(����
�L�L�N�N�N�N�N�
	�	r$c��d|jzS)NzMetaData(bind=%r)rrLs r"rMzMetaData.__repr__�s��"�T�Y�.�.r$c�V�t|tj��s|j}||jvSr')r(rr6r+rs)r=�table_or_keys  r"rpzMetaData.__contains__�s,���,��(9�:�:�	,�'�+�L��t�{�*�*r$c��t||��}t�|j||��|r|j�|��dSdSr')r#�dict�__setitem__rsr�r�)r=r r!r*r+s     r"rxzMetaData._add_table�sY���T�6�*�*�������c�5�1�1�1��	&��M���f�%�%�%�%�%�	&�	&r$c�&�t||��}t�|j|d��}|�|jD]}|�|���|jr7td�|j���D����|_dSdS)Nc�*�g|]}|j�	|j��Sr'r�)r��ts  r"r�z*MetaData._remove_table.<locals>.<listcomp>�s,�������x�+��H�+�+�+r$)	r#r�rrrsr�r�r�r�r�)r=r r!r+�removedrIs      r"r|zMetaData._remove_table�s����T�6�*�*���(�(�4�;��T�2�2�����*�
/�
/���(�(��.�.�.�.��=�	����!�[�/�/�1�1������D�M�M�M�	�	r$c�P�|j|j|j|j|j|jd�S)N)rsr!�schemas�	sequences�fk_memosr�)rsr!r�rr[r�rLs r"�__getstate__zMetaData.__getstate__�s0���k��k��}�����!%�!7�

�
�	
r$c��|d|_|d|_|d|_d|_|d|_|d|_|d|_dS)Nrsr!r�r�r�r�)rsr!r��_bindrr�r[)r=�states  r"�__setstate__zMetaData.__setstate__�sU���H�o����H�o���!&�':�!;�����
���,����i�(��
��z�*����r$c��|jduS)z:True if this MetaData is bound to an Engine or Connection.N�r�rLs r"�is_boundzMetaData.is_bounds���z��%�%r$c��|jS)a-An :class:`_engine.Engine` or :class:`_engine.Connection`
        to which this
        :class:`_schema.MetaData` is bound.

        Typically, a :class:`_engine.Engine` is assigned to this attribute
        so that "implicit execution" may be used, or alternatively
        as a means of providing engine binding information to an
        ORM :class:`.Session` object::

            engine = create_engine("someurl://")
            metadata.bind = engine

        .. seealso::

           :ref:`dbengine_implicit` - background on "bound metadata"

        r�rLs r"r�z
MetaData.bind
s��$�z�r$�sqlalchemy.engine.urlc��t|tj|jfz��rt	j|��|_dS||_dS)z;Bind this MetaData to an Engine, Connection, string or URL.N)r(rr6�URL�
sqlalchemy�
create_enginer�)r=�urlr�s   r"�_bind_tozMetaData._bind_to!sC���d�D�-���
�:�;�;�	�#�1�$�7�7�D�J�J�J��D�J�J�Jr$c��t�|j��|j���|j���dS)z+Clear all Table objects from this MetaData.N)r��clearrsr�r[rLs r"rzMetaData.clear,sF��	
�
�
�4�;�����
��������������r$c�F�|�|j|j��dS)z1Remove the given Table object from this MetaData.N)r|r r!r�s  r"r�zMetaData.remove3s$��	
���5�:�u�|�4�4�4�4�4r$c�x�tjt|j���d������S)a�Returns a list of :class:`_schema.Table` objects sorted in order of
        foreign key dependency.

        The sorting will place :class:`_schema.Table`
        objects that have dependencies
        first, before the dependencies themselves, representing the
        order in which they can be created.   To get the order in which
        the tables would be dropped, use the ``reversed()`` Python built-in.

        .. warning::

            The :attr:`.MetaData.sorted_tables` attribute cannot by itself
            accommodate automatic resolution of dependency cycles between
            tables, which are usually caused by mutually dependent foreign key
            constraints. When these cycles are detected, the foreign keys
            of these tables are omitted from consideration in the sort.
            A warning is emitted when this condition occurs, which will be an
            exception raise in a future release.   Tables which are not part
            of the cycle will still be returned in dependency order.

            To resolve these cycles, the
            :paramref:`_schema.ForeignKeyConstraint.use_alter` parameter may be
            applied to those constraints which create a cycle.  Alternatively,
            the :func:`_schema.sort_tables_and_constraints` function will
            automatically return foreign key constraints in a separate
            collection when cycles are detected so that they may be applied
            to a schema separately.

            .. versionchanged:: 1.3.17 - a warning is emitted when
               :attr:`.MetaData.sorted_tables` cannot perform a proper sort
               due to cyclical dependencies.  This will be an exception in a
               future release.  Additionally, the sort will continue to return
               other tables not involved in the cycle in dependency order which
               was not the case previously.

        .. seealso::

            :func:`_schema.sort_tables`

            :func:`_schema.sort_tables_and_constraints`

            :attr:`_schema.MetaData.tables`

            :meth:`_reflection.Inspector.get_table_names`

            :meth:`_reflection.Inspector.get_sorted_table_and_fkc_names`


        c��|jSr'r�)r�s r"r�z(MetaData.sorted_tables.<locals>.<lambda>ls��q�u�r$r�)r�sort_tablesr�rsr�rLs r"�
sorted_tableszMetaData.sorted_tables8s9��f���4�;�%�%�'�'�_�_�=�=�=�
�
�	
r$Tc
�(�������|�t���}|���5}	d|	�||t��d�}
|
�|�����j����|
d<tj|j��|	������|r.��|j	�
|	�������!tj�fd��D����}n�}t�j�������fd�t�|��D��}n�tj
���r ����fd�t�|��D��}n]�fd	��D��}
|
r>�rd
�zpd}tjd|j�|�d
d�|
���d������fd��D��}|D]G}	t#|�fi|
���#tj$r$}tjd|�d|����Yd}~�@d}~wwxYw	ddd��dS#1swxYwYdS)a�
Load all available table definitions from the database.

        Automatically creates ``Table`` entries in this ``MetaData`` for any
        table available in the database but not yet present in the
        ``MetaData``.  May be called multiple times to pick up tables recently
        added to the database, however no special action is taken if a table
        in this ``MetaData`` no longer exists in the database.

        :param bind:
          A :class:`.Connectable` used to access the database; if None, uses
          the existing bind on this ``MetaData``, if any.

        :param schema:
          Optional, query and reflect tables from an alternate schema.
          If None, the schema associated with this :class:`_schema.MetaData`
          is used, if any.

        :param views:
          If True, also reflect views.

        :param only:
          Optional.  Load only a sub-set of available named tables.  May be
          specified as a sequence of names or a callable.

          If a sequence of names is provided, only those tables will be
          reflected.  An error is raised if a table is requested but not
          available.  Named tables already present in this ``MetaData`` are
          ignored.

          If a callable is provided, it will be used as a boolean predicate to
          filter the list of potential table names.  The callable is called
          with a table name and this ``MetaData`` instance as positional
          arguments and should return a true value for any table to reflect.

        :param extend_existing: Passed along to each :class:`_schema.Table` as
          :paramref:`_schema.Table.extend_existing`.

          .. versionadded:: 0.9.1

        :param autoload_replace: Passed along to each :class:`_schema.Table`
          as
          :paramref:`_schema.Table.autoload_replace`.

          .. versionadded:: 0.9.1

        :param resolve_fks: if True, reflect :class:`_schema.Table`
         objects linked
         to :class:`_schema.ForeignKey` objects located in each
         :class:`_schema.Table`.
         For :meth:`_schema.MetaData.reflect`,
         this has the effect of reflecting
         related tables that might otherwise not be in the list of tables
         being reflected, for example if the referenced table is in a
         different schema or is omitted via the
         :paramref:`.MetaData.reflect.only` parameter.  When False,
         :class:`_schema.ForeignKey` objects are not followed to the
         :class:`_schema.Table`
         in which they link, however if the related table is also part of the
         list of tables that would be reflected in any case, the
         :class:`_schema.ForeignKey` object will still resolve to its related
         :class:`_schema.Table` after the :meth:`_schema.MetaData.reflect`
         operation is
         complete.   Defaults to True.

         .. versionadded:: 1.3.0

         .. seealso::

            :paramref:`_schema.Table.resolve_fks`

        :param \**dialect_kwargs: Additional keyword arguments not mentioned
         above are dialect specific, and passed in the form
         ``<dialectname>_<argname>``.  See the documentation regarding an
         individual dialect at :ref:`dialect_toplevel` for detail on
         documented arguments.

          .. versionadded:: 0.9.2 - Added
             :paramref:`.MetaData.reflect.**dialect_kwargs` to support
             dialect-level reflection options for all :class:`_schema.Table`
             objects reflected.

        NT)r�r�rkr�r�r�r!)r�c���g|]	}��d|����
S)rr)r�r r!s  �r"r�z$MetaData.reflect.<locals>.<listcomp>�s$���D�D�D�$������-�D�D�Dr$c�&��g|]
\}}�s|�v�|��Srr)r�r �schname�currentrks   ��r"r�z$MetaData.reflect.<locals>.<listcomp>�s<������%��g�&��+2��*@�*@��*@�*@�*@r$c�>��g|]\}}�s|�v��|����|��Srr)r�r rrrk�onlyr=s   ����r"r�z$MetaData.reflect.<locals>.<listcomp>�sQ������%��g�'��,3�'�+A�+A���T�4�(�(�,B��+A�+A�+Ar$c���g|]}|�v�|��	Srr)r�r �	availables  �r"r�z$MetaData.reflect.<locals>.<listcomp>�s#���J�J�J�D�D�	�4I�4I�4�4I�4I�4Ir$z schema '%s'r�z7Could not reflect: requested table(s) not available in z: (r�r�c� ��g|]
}�s|�v�|��Srr)r�r rrks  ��r"r�z$MetaData.reflect.<locals>.<listcomp>s8�������&��+/�g�*=�*=��*=�*=�*=r$zSkipping table z: )r�connectr�r'r!r�
OrderedSet�engine�table_namesr��get_view_namesrsr�r�rrur�rf�UnreflectableTableErrorr)r=r�r!�viewsrrkr�r�r��conn�reflect_opts�available_w_schema�load�missing�sr �uerrrrs` ` ``           @@r"r�zMetaData.reflectoss��������z�<�!�$�'�'�D�
�\�\�^�^�A	F�t�!�!%�#2�$4�*�!�e�e�
��L�
����/�/�/��~�����!�)/��X�&�����'�'��4�'�@�@���I��
L�� � ���!<�!<�T�6�!J�!J�K�K�K��!�%)�_�D�D�D�D�)�D�D�D�&�&�"�"�&/�"��$�+�&�&�G��|������),�Y�8J�)K�)K������
��t�$�$�
��������),�Y�8J�)K�)K������K�J�J�J�D�J�J�J�����<�N�V�$;�B��A��1�1�+/�;�;����4�9�9�W�;M�;M�;M�;M�O��������� $������
F�
F��F��$��5�5��5�5�5�5���2�F�F�F��I�I����t�t�D�E�E�E�E�E�E�E�E�����F����
F�{A	F�A	F�A	F�A	F�A	F�A	F�A	F�A	F�A	F�A	F�A	F�A	F����A	F�A	F�A	F�A	F�A	F�A	Fs<�FH�4G�H�G6�G1�,H�1G6�6H�H�Hrgz�the :meth:`_schema.MetaData.append_ddl_listener` method is deprecated and will be removed in a future release.  Please refer to :class:`.DDLEvents`.c�l���fd�}tj|d|�dd��z|��dS)z1Append a DDL event listener to this ``MetaData``.c�@��|d}�t|||���dS)Nrs)rsr)r�r�r~rsr�s    �r"r�z4MetaData.append_ddl_listener.<locals>.adapt_listeners+�����\�F��H�U�F�J�v�>�>�>�>�>�>r$r�r�r�Nr�r�s  ` r"r�zMetaData.append_ddl_listenersM���	?�	?�	?�	?�	?�	��T�2�
� 2� 2�3�� <� <�<�n�M�M�M�M�Mr$c�n�|�t|��}|�tj|||���dS)ayCreate all tables stored in this metadata.

        Conditional by default, will not attempt to recreate tables already
        present in the target database.

        :param bind:
          A :class:`.Connectable` used to access the
          database; if None, uses the existing bind on this ``MetaData``, if
          any.

        :param tables:
          Optional list of ``Table`` objects, which is a subset of the total
          tables in the ``MetaData`` (others are ignored).

        :param checkfirst:
          Defaults to True, don't issue CREATEs for tables already present
          in the target database.

        N�rrsr�r=r�rsrs    r"�
create_allzMetaData.create_all"sI��(�<�!�$�'�'�D�������*�V�	�	
�	
�	
�	
�	
r$c�n�|�t|��}|�tj|||���dS)atDrop all tables stored in this metadata.

        Conditional by default, will not attempt to drop tables not present in
        the target database.

        :param bind:
          A :class:`.Connectable` used to access the
          database; if None, uses the existing bind on this ``MetaData``, if
          any.

        :param tables:
          Optional list of ``Table`` objects, which is a subset of the
          total tables in the ``MetaData`` (others are ignored).

        :param checkfirst:
          Defaults to True, only issue DROPs for tables confirmed to be
          present in the target database.

        Nr'rr(s    r"�drop_allzMetaData.drop_all<sI��(�<�!�$�'�'�D������t�
�6�	�	
�	
�	
�	
�	
r$)NFNNNN)NNFNFTT)NNT)r]r^r_r`rarr"r�rsrMrprxr|r�r�r�r�r�rrbrr�rr�rcr�r)r+rr$r"r�r��s��������0 �N��T��
���������
�B�B�B���B�H�F��"/�/�/�+�+�+�
&�&�&�
�
�
�
�
�
�+�+�+�&�&�&�
���(�T��.�/�/���0�/���8�D�(�#�#�D����5�5�5�
�4
�4
��X�4
�p���
����aF�aF�aF�aF�F�T�_�
�	���N�N���N�
�
�
�
�4
�
�
�
�
�
r$r�c���eZdZdZdZ�fd�Zd�Zejd��d���Z	e
ee	��Zd�Zd�Z�xZ
S)	�ThreadLocalMetaDataaA MetaData variant that presents a different ``bind`` in every thread.

    Makes the ``bind`` property of the MetaData a thread-local value, allowing
    this collection of tables to be bound to different ``Engine``
    implementations or connections in each thread.

    The ThreadLocalMetaData starts off bound to None in each thread.  Binds
    must be made explicitly by assigning to the ``bind`` property or using
    ``connect()``.  You can also re-bind dynamically multiple times per
    thread, just like a regular ``MetaData``.

    rc���tj���|_i|_tt|�����dS)z Construct a ThreadLocalMetaData.N)r�	threading�local�context�_ThreadLocalMetaData__enginesr�r-r�)r=r�s �r"r�zThreadLocalMetaData.__init__gsD����~�+�+�-�-������
�!�4�(�(�1�1�3�3�3�3�3r$c�.�t|jdd��S)z�The bound Engine or Connection for this thread.

        This property may be assigned an Engine or Connection, or assigned a
        string or URL to automatically create a basic Engine for this bind
        with ``create_engine()``.�_engineN)r�r1rLs r"r�zThreadLocalMetaData.bindns���t�|�Y��5�5�5r$r�c�4�t|tj|jfz��rU	|j||j_dS#t$r.tj	|��}||j|<||j_YdSwxYw||jvr
||j|<||j_dS)z-Bind to a Connectable in the caller's thread.N)
r(rr6rr2r1r4r�rr)r=rr�r�s    r"rzThreadLocalMetaData._bind_tows����d�D�-���
�:�;�;�	(�
)�'+�~�d�';���$�$�$���
)�
)�
)��,�T�2�2��'(���t�$�'(���$�$�$�$�
)�����4�>�)�)�'+���t�$�#'�D�L� � � s�>�4A6�5A6c�H�t|jd��o
|jjduS)z(True if there is a bind for this thread.r4N)r7r1r4rLs r"r�zThreadLocalMetaData.is_bound�s*��
�D�L�)�,�,�
1���$�D�0�	
r$c��|j���D]&}t|d��r|����'dS)z2Dispose all bound engines, in all thread contexts.�disposeN)r2r�r7r8)r=r�s  r"r8zThreadLocalMetaData.dispose�sK����&�&�(�(�	�	�A��q�)�$�$�
��	�	�����	�	r$)r]r^r_r`rar�r�rr�rrbr�r8r#r$s@r"r-r-Ws���������� �N�4�4�4�4�4�6�6�6��T��.�/�/�(�(�0�/�(�"�8�D�(�#�#�D�
�
�
�������r$r-c�R�eZdZdZdZejd��Zd�Ze	d���Z
dS)�_SchemaTranslateMapaProvide translation of schema names based on a mapping.

    Also provides helpers for producing cache keys and optimized
    access when no mapping is present.

    Used by the :paramref:`.Connection.execution_options.schema_translate_map`
    feature.

    .. versionadded:: 1.1


    )r[�__call__�hash_key�
is_defaultr!c�������_��P��fd�}|�_d��fd�t�t���D�����_d�_dSd�_�j�_d�_dS)Nc�^����|��}|�|���}|Sr')�_default_schema_getterr\)�objrZr[r=s  ��r"�schema_for_objectz7_SchemaTranslateMap.__init__.<locals>.schema_for_object�s:���#'�#>�#>�s�#C�#C� �#&�#8�#8�$�d�$�$� �(�'r$�;c3�2�K�|]}|�d�|��V��dS)r�Nr)r�r�r[s  �r"r�z/_SchemaTranslateMap.__init__.<locals>.<genexpr>�sC�����%�%�+,�1�1�1�d�1�g�g�&�%�%�%�%�%�%r$r�FrT)r[r;r�r�r�r<r=r@)r=r[rBs`` r"r�z_SchemaTranslateMap.__init__�s�������	���
(�
(�
(�
(�
(�
(�.�D�M��H�H�%�%�%�%�06�t��0E�0E�0E�%�%�%���D�M�$�D�O�O�O��D�M� �7�D�M�"�D�O�O�Or$c�`�|�tSt|t��r|St|��Sr')�_default_schema_mapr(r:)r}r[s  r"�_schema_getterz"_SchemaTranslateMap._schema_getter�s3���<�&�&�
��1�
2�
2�	-��K�&�t�,�,�,r$N)r]r^r_r`�	__slots__�operator�
attrgetterr@r�rjrGrr$r"r:r:�sb��������=�I�0�X�0��:�:��#�#�#�*�-�-��[�-�-�-r$r:c�X�eZdZdZdZeddd��dd���Zd�Zd	�Zdd
�Z	dS)riaDefines a generated column, i.e. "GENERATED ALWAYS AS" syntax.

    The :class:`.Computed` construct is an inline construct added to the
    argument list of a :class:`_schema.Column` object::

        from sqlalchemy import Computed

        Table('square', meta,
            Column('side', Float, nullable=False),
            Column('area', Float, Computed('side * side'))
        )

    See the linked documentation below for complete details.

    .. versionadded:: 1.3.11

    .. seealso::

        :ref:`computed_ddl`

    �computed_columnr�z:class:`.Computed`z:paramref:`.Computed.sqltext`Nc�N�t|d���|_||_d|_dS)aConstruct a GENERATED ALWAYS AS DDL construct to accompany a
        :class:`_schema.Column`.

        :param sqltext:
          A string containing the column generation expression, which will be
          used verbatim, or a SQL expression construct, such as a
          :func:`_expression.text`
          object.   If given as a string, the object is converted to a
          :func:`_expression.text` object.

        :param persisted:
          Optional, controls how this column should be persisted by the
          database.   Possible values are:

          * ``None``, the default, it will use the default persistence
            defined by the database.
          * ``True``, will render ``GENERATED ALWAYS AS ... STORED``, or the
            equivalent for the target database if supported.
          * ``False``, will render ``GENERATED ALWAYS AS ... VIRTUAL``, or
            the equivalent for the target database if supported.

          Specifying ``True`` or ``False`` may raise an error when the DDL
          is emitted to the target database if the database does not support
          that persistence option.   Leaving this parameter at its default
          of ``None`` is guaranteed to succeed for all databases that support
          ``GENERATED ALWAYS AS``.

        Tr�N)rr��	persistedr�)r=r�rNs   r"r�zComputed.__init__�s+��@(���M�M�M���"�������r$c��t|jtd��tf��r)t|jtd��tf��stjd���||_||_||j_||j_dS)NzPA generated column cannot specify a server_default or a server_onupdate argument)	r(r+r9rir,rr<r�r8r;s  r"r�zComputed._set_parents�����!�D��J�J��#9�
�
�	��F�2�T�$�Z�Z��4J�K�K�	��#�+���
�������&*���#�%)���"�"�"r$c��|Sr'rr�s  r"r>zComputed._as_for_updates���r$c��t|j|j�|jjnd|��}t	||j���}|�|��S)N)rN)r3r�r�r*rirNrW)r=r/r~r��gs     r"rTz
Computed.copysW��"��L�!%��!8�D�K���d��
�
��

�W���7�7�7���%�%�a�(�(�(r$r')
r]r^r_r`rar
r�r�r>rTrr$r"riri�s���������,'�N����'�)H���������B*�*�*����)�)�)�)�)�)r$ri)Er`�
__future__rr�rIrr�rrr�baserr	r
rr�rr
rrrrrrrwrrrrr�symbolrrqr#r3�_self_inspects�	Visitabler5rfr)rrrmr�r�r:rr;r=r?�deprecated_clsr3r6r@rBrDrlr�rr�rWrr�r�r�r-r:rFrGrirr$r"�<module>rYs_����.'�&�&�&�&�&������������������������������� � � � � � �"�"�"�"�"�"�������#�#�#�#�#�#�#�#�#�#�#�#�-�-�-�-�-�-�&�&�&�&�&�&�#�#�#�#�#�#�"�"�"�"�"�"�#�#�#�#�#�#�!�!�!�!�!�!� � � � � � �#�#�#�#�#�#����������������������������O�,�,�
��t�{���	�	��#�#�#�B�B�B�"��B<�B<�B<�B<�B<�"�H�$6�B<�B<���B<�JR-�R-�R-�R-�R-�M�:�{�R-�R-�R-�jt=�t=�t=�t=�t=�]�J��t=�t=�t=�nj-�j-�j-�j-�j-��
�j-�j-�j-�ZE�E�E�E�E�f�E�E�E�!�!�!�!�!��
�!�!�!�Ht1�t1�t1�t1�t1�$�t1�t1�t1�n2�2�2�2�2�f�2�2�2�jJ
�J
�J
�J
�J
�� 0�J
�J
�J
�Z��0'�0'�0'�0'�0'�?�$5�0'�0'���0'�f!P�!P�!P�!P�!P�L�!P�!P�!P�H���	�@���
1�1�1�1�1�]�1�1���
1�T$�T$�T$�T$�T$��
�T$�T$�T$�n������d&�d&�d&�d&�d&�F�d&�d&�d&�NW'�W'�W'�W'�W'�!6�
�W'�W'�W'�td)�d)�d)�d)�d)�0�d)�d)�d)�N`+�`+�`+�`+�`+�5�`+�`+�`+�F	V�V�V�V�V�5�V�V�V�r	)�	)�	)�	)�	)�1�	)�	)�	)�P
�P
�P
�P
�P
�M�0�*�P
�P
�P
�f/�D�.��6M�/N�O�O��v	
�v	
�v	
�v	
�v	
�z�v	
�v	
�v	
�r@�@�@�@�@�(�@�@�@�F.-�.-�.-�.-�.-�&�.-�.-�.-�b*�)�$�/�/��$�3��U)�U)�U)�U)�U)�|�Z�U)�U)�U)�U)�U)r$

Hacked By AnonymousFox1.0, Coded By AnonymousFox