o
    "hw&                    @  s  d Z ddlmZ ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	l
mZ dd
l
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z# dd l$m%Z% dd!l&m'Z' dd"l&m(Z( dd#l)m*Z* dd$l+m,Z, dd%l m-Z- dd&l.m/Z/ erdd'l0m1Z1 dd(l0m2Z2 dd)l0m3Z3 dd*l0m4Z4 dd+l0m5Z5 dd,l0m6Z6 dd-l0m7Z7 dd.l0m8Z8 dd/l0m9Z9 ed0Z:e j;dLd;d<Z<dMd@dAZ=e	G dBdC dCeZ>e	G dDdE dEeZ?ej@G dFdG dGejAdG ZBe/G dHdI dIZCeG dJdK dKZDdS )Na  Provides an abstraction for obtaining database schema information.

Usage Notes:

Here are some general conventions when accessing the low level inspector
methods such as get_table_names, get_columns, etc.

1. Inspector methods return lists of dicts in most cases for the following
   reasons:

   * They're both standard types that can be serialized.
   * Using a dict instead of a tuple allows easy expansion of attributes.
   * Using a list for the outer structure maintains order and is easy to work
     with (e.g. list comprehension [d['name'] for d in cols]).

2. Records that contain a name, such as the column name in a column record
   use the key 'name'. So for most return values, each record will have a
   'name' attribute..
    )annotationsN)	dataclass)auto)Flag)unique)Any)Callable)
Collection)Dict)	Generator)Iterable)List)Optional)Sequence)Set)Tuple)TYPE_CHECKING)TypeVar)Union   )
Connection)Engine   )exc)
inspection)sql)util)	operators)schema)_ad_hoc_cache_key_from_args)quoted_name)
TextClause)
TypeEngine)InternalTraversal)topological)final)Dialect)ReflectedCheckConstraint)ReflectedColumn)ReflectedForeignKeyConstraint)ReflectedIndex)ReflectedPrimaryKeyConstraint)ReflectedTableComment)ReflectedUniqueConstraint)TableKey_RfnCallable[..., _R]selfr&   conr   argsr   kwreturnc                   s   | dd }|d u r| ||g|R i |S ddh | jtdd |D t fdd| D f}| |}|d u rK| ||g|R i |}|||< |S )N
info_cacheunreflectablec                 s  s6    | ]}t |trt |trt||jfn|V  qd S N)
isinstancestrr    quote).0a r?   q/var/www/project2/testadmin.ninositsolution.com/venv/lib/python3.10/site-packages/sqlalchemy/engine/reflection.py	<genexpr>]   s    
zcache.<locals>.<genexpr>c                 3  s<    | ]\}}| vr|t |trt||jfn|fV  qd S r9   )r:   r    r;   r<   )r=   kvexcluder?   r@   rA   b   s    )get__name__tupleitemsr0   r2   r3   r4   r5   r7   keyretr?   rD   r@   cacheO   s"   
rM   traverse_argsTuple[str, InternalTraversal]0Callable[[Callable[..., _R]], Callable[..., _R]]c                    s   t jd fdd}|S )Nr0   r1   r2   r&   r3   r   r4   r   r5   r6   r/   c                   sr   | dd }|d u r| ||g|R i |S t| jf |}| |}|d u r7| ||g|R i |}|||< |S )Nr7   )rF   r   rG   rJ   rN   r?   r@   gor   s   
zflexi_cache.<locals>.gor0   r1   r2   r&   r3   r   r4   r   r5   r   r6   r/   )r   	decorator)rN   rR   r?   rQ   r@   flexi_cacheo   s   rU   c                   @  s>   e Zd ZdZe Z	 e Z	 e Z	 eeB Z	 eeB eB Z	dS )
ObjectKinda  Enumerator that indicates which kind of object to return when calling
    the ``get_multi`` methods.

    This is a Flag enum, so custom combinations can be passed. For example,
    to reflect tables and plain views ``ObjectKind.TABLE | ObjectKind.VIEW``
    may be used.

    .. note::
      Not all dialect may support all kind of object. If a dialect does
      not support a particular object an empty dict is returned.
      In case a dialect supports an object, but the requested method
      is not applicable for the specified kind the default value
      will be returned for each reflected object. For example reflecting
      check constraints of view return a dict with all the views with
      empty lists as values.
    N)
rG   
__module____qualname____doc__r   TABLEVIEWMATERIALIZED_VIEWANY_VIEWANYr?   r?   r?   r@   rV      s    rV   c                   @  s(   e Zd ZdZe Z	 e Z	 eeB ZdS )ObjectScopez]Enumerator that indicates which scope to use when calling
    the ``get_multi`` methods.
    N)rG   rW   rX   rY   r   DEFAULT	TEMPORARYr^   r?   r?   r?   r@   r_      s    r_   c                   @  sh  e Zd ZU dZded< ded< ded< ded	< d
ed< edddddZedddZ	dddZ
dddZdddZdddZeedd dd!d"Zeedd#d$Zeedd%d&Zejdd(d)Zejdd+d,Zedd.d/Zdd3d4Z	5dIdd7d8Z	5dIdd;d<Z	5dIdd>d?Z	5dIddAdBZddDdEZ 	5dIddGdHZ!	IdddMdNZ"ddOdPZ#ddQdRZ$	5dIddTdUZ%d5d5e&j'e(j)fdd]d^Z*	5dIdd_d`Z+	5dIddadbZ,	5dIddcddZ-	5dIddfdgZ.	5dIddidjZ/ddmdnZ0d5d5e&j'e(j)fddpdqZ1	5dIddsdtZ2d5d5e&j'e(j)fddvdwZ3	5dIddydzZ4d5d5e&j'e(j)fdd|d}Z5	5dIdddZ6d5d5e&j'e(j)fdddZ7	5dIdddZ8d5d5e&j'e(j)fdddZ9	5dIdddZ:d5d5e&j'e(j)fdddZ;	5dIdddZ<d5d5e&j'e(j)fdddZ=			5	5ddddZ>dddZ?dddZ@dddZAeBjCeBjDeBjEeBjFdZGdddZHdddZIdddZJdddZK	5	5	5	5ddddZLd5S )	Inspectora=  Performs database schema inspection.

    The Inspector acts as a proxy to the reflection methods of the
    :class:`~sqlalchemy.engine.interfaces.Dialect`, providing a
    consistent interface as well as caching support for previously
    fetched metadata.

    A :class:`_reflection.Inspector` object is usually created via the
    :func:`_sa.inspect` function, which may be passed an
    :class:`_engine.Engine`
    or a :class:`_engine.Connection`::

        from sqlalchemy import inspect, create_engine

        engine = create_engine("...")
        insp = inspect(engine)

    Where above, the :class:`~sqlalchemy.engine.interfaces.Dialect` associated
    with the engine may opt to return an :class:`_reflection.Inspector`
    subclass that
    provides additional methods specific to the dialect's target database.

    Union[Engine, Connection]bindr   enginebool_op_context_requires_connectr&   dialectzDict[Any, Any]r7   z1.4a  The __init__() method on :class:`_reflection.Inspector` is deprecated and will be removed in a future release.  Please use the :func:`.sqlalchemy.inspect` function on an :class:`_engine.Engine` or :class:`_engine.Connection` in order to acquire an :class:`_reflection.Inspector`.c                 C  s   |  | dS )a  Initialize a new :class:`_reflection.Inspector`.

        :param bind: a :class:`~sqlalchemy.engine.Connection`,
          which is typically an instance of
          :class:`~sqlalchemy.engine.Engine` or
          :class:`~sqlalchemy.engine.Connection`.

        For a dialect-specific instance of :class:`_reflection.Inspector`, see
        :meth:`_reflection.Inspector.from_engine`

        N)_init_legacyr2   rd   r?   r?   r@   __init__   s   zInspector.__init__initCallable[..., Any]r6   c                 C  s,   t |jdr
|jj} | | }||| |S )N	inspector)hasattrrh   rn   __new__)clsrl   rd   r2   r?   r?   r@   
_construct   s
   

zInspector._constructNonec                 C  s&   t |dr| | d S | | d S )Nexec_driver_sql)ro   _init_connection_init_enginerj   r?   r?   r@   ri      s   
zInspector._init_legacyc                 C  s2   | | _ | _|   d| _| jj| _i | _d S )NT)rd   re   connectcloserg   rh   r7   )r2   re   r?   r?   r@   rv      s
   

zInspector._init_engine
connectionr   c                 C  s(   || _ |j| _d| _| jj| _i | _d S )NF)rd   re   rg   rh   r7   )r2   ry   r?   r?   r@   ru     s
   

zInspector._init_connectionc                 C  s   | j   dS )zreset the cache for this :class:`.Inspector`.

        Inspection methods that have data cached will emit SQL queries
        when next called to get new data.

        .. versionadded:: 2.0

        N)r7   clearr2   r?   r?   r@   clear_cache  s   	zInspector.clear_cachea  The from_engine() method on :class:`_reflection.Inspector` is deprecated and will be removed in a future release.  Please use the :func:`.sqlalchemy.inspect` function on an :class:`_engine.Engine` or :class:`_engine.Connection` in order to acquire an :class:`_reflection.Inspector`.c                 C  s   |  | j|S )aZ  Construct a new dialect-specific Inspector object from the given
        engine or connection.

        :param bind: a :class:`~sqlalchemy.engine.Connection`
         or :class:`~sqlalchemy.engine.Engine`.

        This method differs from direct a direct constructor call of
        :class:`_reflection.Inspector` in that the
        :class:`~sqlalchemy.engine.interfaces.Dialect` is given a chance to
        provide a dialect-specific :class:`_reflection.Inspector` instance,
        which may
        provide additional methods.

        See the example at :class:`_reflection.Inspector`.

        )rr   ri   )rq   rd   r?   r?   r@   from_engine  s   zInspector.from_enginec                 C     t t j| S r9   )rb   rr   rv   rd   r?   r?   r@   _engine_insp7     zInspector._engine_inspc                 C  r~   r9   )rb   rr   ru   r   r?   r?   r@   _connection_insp;  r   zInspector._connection_insp!Generator[Connection, None, None]c                 c  sL    | j r
| j }n| j}z|V  W | j r|  dS dS | j r%|  w w )a  Return a context that optimizes for multiple operations on a single
        transaction.

        This essentially allows connect()/close() to be called if we detected
        that we're against an :class:`_engine.Engine` and not a
        :class:`_engine.Connection`.

        N)rg   rd   rw   rx   )r2   connr?   r?   r@   _operation_context?  s   

zInspector._operation_context Generator[Inspector, None, None]c                 c  sN    |   }| | jj|}| j|_|V  W d   dS 1 s w   Y  dS )zReturn an :class:`_reflection.Inspector`
        from this one that will run all
        operations on a single connection.

        N)r   rr   	__class__ru   r7   )r2   r   sub_inspr?   r?   r@   _inspection_contextT  s   
"zInspector._inspection_contextOptional[str]c                 C  s   | j jS )zReturn the default schema name presented by the dialect
        for the current engine's database user.

        E.g. this is typically ``public`` for PostgreSQL and ``dbo``
        for SQL Server.

        )rh   default_schema_namer{   r?   r?   r@   r   a  s   	zInspector.default_schema_namer5   r   	List[str]c                 K  F   |   }| jj|fd| ji|W  d   S 1 sw   Y  dS )zReturn all schema names.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.
        r7   N)r   rh   get_schema_namesr7   r2   r5   r   r?   r?   r@   r   l  s   
$zInspector.get_schema_namesNr   c                 K  H   |   }| jj||fd| ji|W  d   S 1 sw   Y  dS )a  Return all table names within a particular schema.

        The names are expected to be real tables only, not views.
        Views are instead returned using the
        :meth:`_reflection.Inspector.get_view_names` and/or
        :meth:`_reflection.Inspector.get_materialized_view_names`
        methods.

        :param schema: Schema name. If ``schema`` is left at ``None``, the
         database's default schema is
         used, else the named schema is searched.  If the database does not
         support named schemas, behavior is undefined if ``schema`` is not
         passed as ``None``.  For special quoting, use :class:`.quoted_name`.
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        .. seealso::

            :meth:`_reflection.Inspector.get_sorted_table_and_fkc_names`

            :attr:`_schema.MetaData.sorted_tables`

        r7   N)r   rh   get_table_namesr7   r2   r   r5   r   r?   r?   r@   r   y  s   
$zInspector.get_table_names
table_namer;   c                 K  J   |   }| jj|||fd| ji|W  d   S 1 sw   Y  dS )a  Return True if the backend has a table, view, or temporary
        table of the given name.

        :param table_name: name of the table to check
        :param schema: schema name to query, if not the default schema.
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        .. versionadded:: 1.4 - the :meth:`.Inspector.has_table` method
           replaces the :meth:`_engine.Engine.has_table` method.

        .. versionchanged:: 2.0:: :meth:`.Inspector.has_table` now formally
           supports checking for additional table-like objects:

           * any type of views (plain or materialized)
           * temporary tables of any kind

           Previously, these two checks were not formally specified and
           different dialects would vary in their behavior.   The dialect
           testing suite now includes tests for all of these object types
           and should be supported by all SQLAlchemy-included dialects.
           Support among third party dialects may be lagging, however.

        r7   N)r   rh   	has_tabler7   r2   r   r   r5   r   r?   r?   r@   r     s   
$zInspector.has_tablesequence_namec                 K  r   )a  Return True if the backend has a sequence with the given name.

        :param sequence_name: name of the sequence to check
        :param schema: schema name to query, if not the default schema.
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        .. versionadded:: 1.4

        r7   N)r   rh   has_sequencer7   )r2   r   r   r5   r   r?   r?   r@   r     s   
$zInspector.has_sequence
index_namec                 K  sL   |   }| jj||||fd| ji|W  d   S 1 sw   Y  dS )a  Check the existence of a particular index name in the database.

        :param table_name: the name of the table the index belongs to
        :param index_name: the name of the index to check
        :param schema: schema name to query, if not the default schema.
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        .. versionadded:: 2.0

        r7   N)r   rh   	has_indexr7   )r2   r   r   r   r5   r   r?   r?   r@   r     s   
$zInspector.has_indexschema_namec                 K  r   )aT  Return True if the backend has a schema with the given name.

        :param schema_name: name of the schema to check
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        .. versionadded:: 2.0

        r7   N)r   rh   
has_schemar7   )r2   r   r5   r   r?   r?   r@   r     s   
$zInspector.has_schema;List[Tuple[Optional[str], List[Tuple[str, Optional[str]]]]]c                 K  s   dd | j |fdD S )ag  Return dependency-sorted table and foreign key constraint names in
        referred to within a particular schema.

        This will yield 2-tuples of
        ``(tablename, [(tname, fkname), (tname, fkname), ...])``
        consisting of table names in CREATE order grouped with the foreign key
        constraint names that are not detected as belonging to a cycle.
        The final element
        will be ``(None, [(tname, fkname), (tname, fkname), ..])``
        which will consist of remaining
        foreign key constraint names that would require a separate CREATE
        step after-the-fact, based on dependencies between tables.

        :param schema: schema name to query, if not the default schema.
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        .. seealso::

            :meth:`_reflection.Inspector.get_table_names`

            :func:`.sort_tables_and_constraints` - similar method which works
            with an already-given :class:`_schema.MetaData`.

        c                 S  s.   g | ]\}}|r|d  nddd |D fqS )r   Nc                 S  s   g | ]
\\}}}||fqS r?   r?   )r=   _tnamefksr?   r?   r@   
<listcomp>  s    zGInspector.get_sorted_table_and_fkc_names.<locals>.<listcomp>.<listcomp>r?   )r=   	table_keyfk_collectionr?   r?   r@   r     s    z<Inspector.get_sorted_table_and_fkc_names.<locals>.<listcomp>)consider_schemas)%sort_tables_on_foreign_key_dependency)r2   r   r5   r?   r?   r@   get_sorted_table_and_fkc_names  s
    z(Inspector.get_sorted_table_and_fkc_namesr9   r   Collection[Optional[str]]gList[Tuple[Optional[Tuple[Optional[str], str]], List[Tuple[Tuple[Optional[str], str], Optional[str]]]]]c              
     s^  t tt tf }t }t i g }|D ]F}| j|fi |}|| | D ]1\\}}	}
dd |
D ||	f< |
D ]}|	|d ksI||d krX||d |d f||	ff q;q(qz
tt	
||}W n6 tjy } z)|jD ] |   fdd d  D  qqtt	
||}W Y d}~nd}~ww fd	d
|D }|dtfg S )a  Return dependency-sorted table and foreign key constraint names
        referred to within multiple schemas.

        This method may be compared to
        :meth:`.Inspector.get_sorted_table_and_fkc_names`, which
        works on one schema at a time; here, the method is a generalization
        that will consider multiple schemas at once including that it will
        resolve for cross-schema foreign keys.

        .. versionadded:: 2.0

        c                 S  s   h | ]}|d  qS )namer?   r=   fkr?   r?   r@   	<setcomp>I  s    zBInspector.sort_tables_on_foreign_key_dependency.<locals>.<setcomp>referred_tablereferred_schemac                 3  s    | ]	} d  |fV  qdS )r   Nr?   )r=   fkc)edger?   r@   rA   `  s    
zBInspector.sort_tables_on_foreign_key_dependency.<locals>.<genexpr>r   Nc                   sD   g | ]\  f fd d f  dd D D fqS )c                   s   g | ]} f|fqS r?   r?   r   schnamer   r?   r@   r   k  s    
zNInspector.sort_tables_on_foreign_key_dependency.<locals>.<listcomp>.<listcomp>c                 s  s    | ]\}}|V  qd S r9   r?   )r=   r   r   r?   r?   r@   rA   m  s    
zMInspector.sort_tables_on_foreign_key_dependency.<locals>.<listcomp>.<genexpr>)
difference)r=   )fknames_for_tableremaining_fkcsr   r@   r   h  s    
zCInspector.sort_tables_on_foreign_key_dependency.<locals>.<listcomp>)r   r   r;   setget_multi_foreign_keysextendrI   addlistr$   sortr   CircularDependencyErroredgesremoveupdate)r2   r   r5   	SchemaTabtuplestnamesr   schema_fkeysr   r   fkeysfkeycandidate_sorterrrL   r?   )r   r   r   r@   r   (  sP   





z/Inspector.sort_tables_on_foreign_key_dependencyc                 K  r   )a  Return a list of temporary table names for the current bind.

        This method is unsupported by most dialects; currently
        only Oracle Database, PostgreSQL and SQLite implements it.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        r7   N)r   rh   get_temp_table_namesr7   r   r?   r?   r@   r   v  s   
$zInspector.get_temp_table_namesc                 K  r   )an  Return a list of temporary view names for the current bind.

        This method is unsupported by most dialects; currently
        only PostgreSQL and SQLite implements it.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        r7   N)r   rh   get_temp_view_namesr7   r   r?   r?   r@   r     s   
$zInspector.get_temp_view_namesDict[str, Any]c                 K  r   )az  Return a dictionary of options specified when the table of the
        given name was created.

        This currently includes some options that apply to MySQL and Oracle
        Database tables.

        :param table_name: string name of the table.  For special quoting,
         use :class:`.quoted_name`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dict with the table options. The returned keys depend on the
         dialect in use. Each one is prefixed with the dialect name.

        .. seealso:: :meth:`Inspector.get_multi_table_options`

        r7   N)r   rh   get_table_optionsr7   r   r?   r?   r@   r        
$zInspector.get_table_optionsfilter_namesOptional[Sequence[str]]kindrV   scoper_   Dict[TableKey, Dict[str, Any]]c              	   K  sV   |   }| jj|f||||| jd|}t|W  d   S 1 s$w   Y  dS )a  Return a dictionary of options specified when the tables in the
        given schema were created.

        The tables can be filtered by passing the names to use to
        ``filter_names``.

        This currently includes some options that apply to MySQL and Oracle
        tables.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param filter_names: optionally return information only for the
         objects listed here.

        :param kind: a :class:`.ObjectKind` that specifies the type of objects
         to reflect. Defaults to ``ObjectKind.TABLE``.

        :param scope: a :class:`.ObjectScope` that specifies if options of
         default, temporary or any tables should be reflected.
         Defaults to ``ObjectScope.DEFAULT``.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary where the keys are two-tuple schema,table-name
         and the values are dictionaries with the table options.
         The returned keys in each dict depend on the
         dialect in use. Each one is prefixed with the dialect name.
         The schema is ``None`` if no schema is provided.

        .. versionadded:: 2.0

        .. seealso:: :meth:`Inspector.get_table_options`
        r   r   r   r   r7   N)r   rh   get_multi_table_optionsr7   dict)r2   r   r   r   r   r5   r   resr?   r?   r@   r     s   
-	$z!Inspector.get_multi_table_optionsc                 K  r   )a  Return all non-materialized view names in `schema`.

        :param schema: Optional, retrieve names from a non-default schema.
         For special quoting, use :class:`.quoted_name`.
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.


        .. versionchanged:: 2.0  For those dialects that previously included
           the names of materialized views in this list (currently PostgreSQL),
           this method no longer returns the names of materialized views.
           the :meth:`.Inspector.get_materialized_view_names` method should
           be used instead.

        .. seealso::

            :meth:`.Inspector.get_materialized_view_names`

        r7   N)r   rh   get_view_namesr7   r   r?   r?   r@   r     s   
$zInspector.get_view_namesc                 K  r   )a  Return all materialized view names in `schema`.

        :param schema: Optional, retrieve names from a non-default schema.
         For special quoting, use :class:`.quoted_name`.
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        .. versionadded:: 2.0

        .. seealso::

            :meth:`.Inspector.get_view_names`

        r7   N)r   rh   get_materialized_view_namesr7   r   r?   r?   r@   r     s   
$z%Inspector.get_materialized_view_namesc                 K  r   )ak  Return all sequence names in `schema`.

        :param schema: Optional, retrieve names from a non-default schema.
         For special quoting, use :class:`.quoted_name`.
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        r7   N)r   rh   get_sequence_namesr7   r   r?   r?   r@   r   $  s   
$zInspector.get_sequence_names	view_namec                 K  r   )a  Return definition for the plain or materialized view called
        ``view_name``.

        :param view_name: Name of the view.
        :param schema: Optional, retrieve names from a non-default schema.
         For special quoting, use :class:`.quoted_name`.
        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        r7   N)r   rh   get_view_definitionr7   )r2   r   r   r5   r   r?   r?   r@   r   6  s   
$zInspector.get_view_definitionList[ReflectedColumn]c                 K  sZ   |   }| jj|||fd| ji|}W d   n1 sw   Y  |r+| |g |S )aJ  Return information about columns in ``table_name``.

        Given a string ``table_name`` and an optional string ``schema``,
        return column information as a list of :class:`.ReflectedColumn`.

        :param table_name: string name of the table.  For special quoting,
         use :class:`.quoted_name`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: list of dictionaries, each representing the definition of
         a database column.

        .. seealso:: :meth:`Inspector.get_multi_columns`.

        r7   N)r   rh   get_columnsr7   _instantiate_types)r2   r   r   r5   r   col_defsr?   r?   r@   r   J  s   
zInspector.get_columnsdataIterable[List[ReflectedColumn]]c                 C  s4   |D ]}|D ]}|d }t |ts| |d< qqd S )Ntype)r:   r"   )r2   r   r   col_defcoltyper?   r?   r@   r   l  s   

zInspector._instantiate_types%Dict[TableKey, List[ReflectedColumn]]c              
   K  s`   |   }t| jj|f||||| jd|}W d   n1 s"w   Y  | |  |S )aW  Return information about columns in all objects in the given
        schema.

        The objects can be filtered by passing the names to use to
        ``filter_names``.

        For each table the value is a list of :class:`.ReflectedColumn`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param filter_names: optionally return information only for the
         objects listed here.

        :param kind: a :class:`.ObjectKind` that specifies the type of objects
         to reflect. Defaults to ``ObjectKind.TABLE``.

        :param scope: a :class:`.ObjectScope` that specifies if columns of
         default, temporary or any tables should be reflected.
         Defaults to ``ObjectScope.DEFAULT``.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary where the keys are two-tuple schema,table-name
         and the values are list of dictionaries, each representing the
         definition of a database column.
         The schema is ``None`` if no schema is provided.

        .. versionadded:: 2.0

        .. seealso:: :meth:`Inspector.get_columns`
        r   N)r   r   rh   get_multi_columnsr7   r   values)r2   r   r   r   r   r5   r   table_col_defsr?   r?   r@   r   v  s"   
,zInspector.get_multi_columnsr+   c                 K  r   )a`  Return information about primary key constraint in ``table_name``.

        Given a string ``table_name``, and an optional string `schema`, return
        primary key information as a :class:`.ReflectedPrimaryKeyConstraint`.

        :param table_name: string name of the table.  For special quoting,
         use :class:`.quoted_name`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary representing the definition of
         a primary key constraint.

        .. seealso:: :meth:`Inspector.get_multi_pk_constraint`
        r7   N)r   rh   get_pk_constraintr7   r   r?   r?   r@   r     s   
$zInspector.get_pk_constraint-Dict[TableKey, ReflectedPrimaryKeyConstraint]c              
   K  R   |   }t| jj|f||||| jd|W  d   S 1 s"w   Y  dS )au  Return information about primary key constraints in
        all tables in the given schema.

        The tables can be filtered by passing the names to use to
        ``filter_names``.

        For each table the value is a :class:`.ReflectedPrimaryKeyConstraint`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param filter_names: optionally return information only for the
         objects listed here.

        :param kind: a :class:`.ObjectKind` that specifies the type of objects
         to reflect. Defaults to ``ObjectKind.TABLE``.

        :param scope: a :class:`.ObjectScope` that specifies if primary keys of
         default, temporary or any tables should be reflected.
         Defaults to ``ObjectScope.DEFAULT``.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary where the keys are two-tuple schema,table-name
         and the values are dictionaries, each representing the
         definition of a primary key constraint.
         The schema is ``None`` if no schema is provided.

        .. versionadded:: 2.0

        .. seealso:: :meth:`Inspector.get_pk_constraint`
        r   N)r   r   rh   get_multi_pk_constraintr7   r2   r   r   r   r   r5   r   r?   r?   r@   r     s   
+$z!Inspector.get_multi_pk_constraint#List[ReflectedForeignKeyConstraint]c                 K  r   )ag  Return information about foreign_keys in ``table_name``.

        Given a string ``table_name``, and an optional string `schema`, return
        foreign key information as a list of
        :class:`.ReflectedForeignKeyConstraint`.

        :param table_name: string name of the table.  For special quoting,
         use :class:`.quoted_name`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a list of dictionaries, each representing the
         a foreign key definition.

        .. seealso:: :meth:`Inspector.get_multi_foreign_keys`
        r7   N)r   rh   get_foreign_keysr7   r   r?   r?   r@   r     r   zInspector.get_foreign_keys3Dict[TableKey, List[ReflectedForeignKeyConstraint]]c              
   K  r   )ao  Return information about foreign_keys in all tables
        in the given schema.

        The tables can be filtered by passing the names to use to
        ``filter_names``.

        For each table the value is a list of
        :class:`.ReflectedForeignKeyConstraint`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param filter_names: optionally return information only for the
         objects listed here.

        :param kind: a :class:`.ObjectKind` that specifies the type of objects
         to reflect. Defaults to ``ObjectKind.TABLE``.

        :param scope: a :class:`.ObjectScope` that specifies if foreign keys of
         default, temporary or any tables should be reflected.
         Defaults to ``ObjectScope.DEFAULT``.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary where the keys are two-tuple schema,table-name
         and the values are list of dictionaries, each representing
         a foreign key definition.
         The schema is ``None`` if no schema is provided.

        .. versionadded:: 2.0

        .. seealso:: :meth:`Inspector.get_foreign_keys`
        r   N)r   r   rh   r   r7   r   r?   r?   r@   r   %     
-$z Inspector.get_multi_foreign_keysList[ReflectedIndex]c                 K  r   )a=  Return information about indexes in ``table_name``.

        Given a string ``table_name`` and an optional string `schema`, return
        index information as a list of :class:`.ReflectedIndex`.

        :param table_name: string name of the table.  For special quoting,
         use :class:`.quoted_name`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a list of dictionaries, each representing the
         definition of an index.

        .. seealso:: :meth:`Inspector.get_multi_indexes`
        r7   N)r   rh   get_indexesr7   r   r?   r?   r@   r   _  s   
$zInspector.get_indexes$Dict[TableKey, List[ReflectedIndex]]c              
   K  r   )aP  Return information about indexes in in all objects
        in the given schema.

        The objects can be filtered by passing the names to use to
        ``filter_names``.

        For each table the value is a list of :class:`.ReflectedIndex`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param filter_names: optionally return information only for the
         objects listed here.

        :param kind: a :class:`.ObjectKind` that specifies the type of objects
         to reflect. Defaults to ``ObjectKind.TABLE``.

        :param scope: a :class:`.ObjectScope` that specifies if indexes of
         default, temporary or any tables should be reflected.
         Defaults to ``ObjectScope.DEFAULT``.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary where the keys are two-tuple schema,table-name
         and the values are list of dictionaries, each representing the
         definition of an index.
         The schema is ``None`` if no schema is provided.

        .. versionadded:: 2.0

        .. seealso:: :meth:`Inspector.get_indexes`
        r   N)r   r   rh   get_multi_indexesr7   r   r?   r?   r@   r   }  s   
,$zInspector.get_multi_indexesList[ReflectedUniqueConstraint]c                 K  r   )a~  Return information about unique constraints in ``table_name``.

        Given a string ``table_name`` and an optional string `schema`, return
        unique constraint information as a list of
        :class:`.ReflectedUniqueConstraint`.

        :param table_name: string name of the table.  For special quoting,
         use :class:`.quoted_name`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a list of dictionaries, each representing the
         definition of an unique constraint.

        .. seealso:: :meth:`Inspector.get_multi_unique_constraints`
        r7   N)r   rh   get_unique_constraintsr7   r   r?   r?   r@   r     r   z Inspector.get_unique_constraints/Dict[TableKey, List[ReflectedUniqueConstraint]]c              
   K  r   )a  Return information about unique constraints in all tables
        in the given schema.

        The tables can be filtered by passing the names to use to
        ``filter_names``.

        For each table the value is a list of
        :class:`.ReflectedUniqueConstraint`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param filter_names: optionally return information only for the
         objects listed here.

        :param kind: a :class:`.ObjectKind` that specifies the type of objects
         to reflect. Defaults to ``ObjectKind.TABLE``.

        :param scope: a :class:`.ObjectScope` that specifies if constraints of
         default, temporary or any tables should be reflected.
         Defaults to ``ObjectScope.DEFAULT``.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary where the keys are two-tuple schema,table-name
         and the values are list of dictionaries, each representing the
         definition of an unique constraint.
         The schema is ``None`` if no schema is provided.

        .. versionadded:: 2.0

        .. seealso:: :meth:`Inspector.get_unique_constraints`
        r   N)r   r   rh   get_multi_unique_constraintsr7   r   r?   r?   r@   r     r   z&Inspector.get_multi_unique_constraintsr,   c                 K  r   )a  Return information about the table comment for ``table_name``.

        Given a string ``table_name`` and an optional string ``schema``,
        return table comment information as a :class:`.ReflectedTableComment`.

        Raises ``NotImplementedError`` for a dialect that does not support
        comments.

        :param table_name: string name of the table.  For special quoting,
         use :class:`.quoted_name`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary, with the table comment.

        .. versionadded:: 1.2

        .. seealso:: :meth:`Inspector.get_multi_table_comment`
        r7   N)r   rh   get_table_commentr7   r   r?   r?   r@   r     s   
$zInspector.get_table_comment%Dict[TableKey, ReflectedTableComment]c              
   K  r   )a  Return information about the table comment in all objects
        in the given schema.

        The objects can be filtered by passing the names to use to
        ``filter_names``.

        For each table the value is a :class:`.ReflectedTableComment`.

        Raises ``NotImplementedError`` for a dialect that does not support
        comments.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param filter_names: optionally return information only for the
         objects listed here.

        :param kind: a :class:`.ObjectKind` that specifies the type of objects
         to reflect. Defaults to ``ObjectKind.TABLE``.

        :param scope: a :class:`.ObjectScope` that specifies if comments of
         default, temporary or any tables should be reflected.
         Defaults to ``ObjectScope.DEFAULT``.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary where the keys are two-tuple schema,table-name
         and the values are dictionaries, representing the
         table comments.
         The schema is ``None`` if no schema is provided.

        .. versionadded:: 2.0

        .. seealso:: :meth:`Inspector.get_table_comment`
        r   N)r   r   rh   get_multi_table_commentr7   r   r?   r?   r@   r   1  s   
/$z!Inspector.get_multi_table_commentList[ReflectedCheckConstraint]c                 K  r   )ay  Return information about check constraints in ``table_name``.

        Given a string ``table_name`` and an optional string `schema`, return
        check constraint information as a list of
        :class:`.ReflectedCheckConstraint`.

        :param table_name: string name of the table.  For special quoting,
         use :class:`.quoted_name`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a list of dictionaries, each representing the
         definition of a check constraints.

        .. seealso:: :meth:`Inspector.get_multi_check_constraints`
        r7   N)r   rh   get_check_constraintsr7   r   r?   r?   r@   r   m  r   zInspector.get_check_constraints.Dict[TableKey, List[ReflectedCheckConstraint]]c              
   K  r   )a  Return information about check constraints in all tables
        in the given schema.

        The tables can be filtered by passing the names to use to
        ``filter_names``.

        For each table the value is a list of
        :class:`.ReflectedCheckConstraint`.

        :param schema: string schema name; if omitted, uses the default schema
         of the database connection.  For special quoting,
         use :class:`.quoted_name`.

        :param filter_names: optionally return information only for the
         objects listed here.

        :param kind: a :class:`.ObjectKind` that specifies the type of objects
         to reflect. Defaults to ``ObjectKind.TABLE``.

        :param scope: a :class:`.ObjectScope` that specifies if constraints of
         default, temporary or any tables should be reflected.
         Defaults to ``ObjectScope.DEFAULT``.

        :param \**kw: Additional keyword argument to pass to the dialect
         specific implementation. See the documentation of the dialect
         in use for more information.

        :return: a dictionary where the keys are two-tuple schema,table-name
         and the values are list of dictionaries, each representing the
         definition of a check constraints.
         The schema is ``None`` if no schema is provided.

        .. versionadded:: 2.0

        .. seealso:: :meth:`Inspector.get_check_constraints`
        r   N)r   r   rh   get_multi_check_constraintsr7   r   r?   r?   r@   r     r   z%Inspector.get_multi_check_constraintsr?   Ttablesa_schema.Tableinclude_columnsOptional[Collection[str]]exclude_columnsCollection[str]resolve_fks
_extend_onOptional[Set[sa_schema.Table]]_reflect_infoOptional[_ReflectionInfo]c                   s  |dur |v r
dS |   | jj}|  }| }	W d   n1 s'w   Y   j}
 fdd|jD }|	|
f}|du sF||jvrX| j|	f|
gt	j
tj
|d j}||jv rb|j| ||jvrlt|
|jr||j|}|r| | d}i }|j| D ]}d}|  |||| q|s| |
|	st|
| || || | || ||||||	 | || |||| | || |||| | || |||| | || | dS )aZ  Given a :class:`_schema.Table` object, load its internal
        constructs based on introspection.

        This is the underlying method used by most dialects to produce
        table reflection.  Direct usage is like::

            from sqlalchemy import create_engine, MetaData, Table
            from sqlalchemy import inspect

            engine = create_engine("...")
            meta = MetaData()
            user_table = Table("user", meta)
            insp = inspect(engine)
            insp.reflect_table(user_table, None)

        .. versionchanged:: 1.4 Renamed from ``reflecttable`` to
           ``reflect_table``

        :param table: a :class:`~sqlalchemy.schema.Table` instance.
        :param include_columns: a list of string column names to include
          in the reflection process.  If ``None``, all columns are reflected.

        Nc                   s$   i | ]}| j v r| j |qS r?   )dialect_kwargsrF   r=   rB   r   r?   r@   
<dictcomp>  s
    
z+Inspector.reflect_table.<locals>.<dictcomp>)r   r   r   r	  FT)r   rd   rh   r   schema_for_objectr   reflection_optionscolumns_get_reflection_inforV   r^   r_   r  r8   r   NoSuchTableErrortable_optionsrF   _validate_dialect_kwargs_reflect_columnr   _reflect_pk_reflect_fk_reflect_indexes_reflect_unique_constraints_reflect_check_constraints_reflect_table_comment)r2   r   r  r  r  r  r	  rh   r   r   r   r  r   tbl_optsfound_tablecols_by_orig_namecol_dr?   r  r@   reflect_table  s   !







	




zInspector.reflect_tabler   r(   r   Dict[str, sa_schema.Column[Any]]c                   s   d }|j j| |  |j| |   d }|r||vs%|r'||v r'd S  d } fdddD }	d v r?|	 d  g }
 dd urw d }|d usRJ t|tr_tj|dd	}nt|tj	sptjt
|dd	}n|}|
| d
 v rtjdi  d
 }|
| d v rtjdi  d }|
| tj||g|
R i |	 ||< }|j|jv rd|_|j|dd d S )Nr   r   c                   s   i | ]}| v r| | qS r?   r?   r  r   r?   r@   r  t  s
    	z-Inspector._reflect_column.<locals>.<dictcomp>)nullableautoincrementr<   inforK   commentdialect_optionsdefaultT)
_reflectedcomputedidentity)replace_existingr?   )metadatadispatchcolumn_reflectr   rF   r:   r!   	sa_schemaDefaultClauseFetchedValuer   textappendComputedIdentityColumnrK   primary_keyappend_column)r2   r   r   r  r  r  	orig_namer   r   col_kwcolargsdefault_textr)  r+  r,  colr?   r#  r@   r  ]  sZ   





zInspector._reflect_column_ReflectionInfor   r.   c                   sZ   |j |}|r+ fdd|d D }|d|j_|dd |j_|j| d S d S )Nc                   s$   g | ]}| v r|vr | qS r?   r?   )r=   pkr  r  r?   r@   r     s
    z)Inspector._reflect_pk.<locals>.<listcomp>constrained_columnsr   r'  )pk_constraintrF   r9  r   r'  _reload)r2   r	  r   r   r  r  pk_conspk_colsr?   rB  r@   r    s   zInspector._reflect_pkr  c
                   s  |j |g }
|
D ]}|d } fdd|d D }|r#t||s,|r-t||r-q	|d }|d }|d }g }|d urc|rRtj||jf|| j||d|	 |D ]}|	d	
|||g qTn#|rwtj||jf| jtj||d
|	 |D ]}|	d	
||g qyd|v r|d }ni }z|tj|||fd|dd| W q	 tjy   td|j d| dd
| d Y q	w d S )Nr   c                   s"   g | ]}| v r | j n|qS r?   )rK   )r=   cr  r?   r@   r     s    z)Inspector._reflect_fk.<locals>.<listcomp>rC  r   r   referred_columns)r   autoload_withr  r	  .)rK  r   r  r	  optionsTr'  )link_to_namer'  zOn reflected table z0, skipping reflection of foreign key constraint z-; one or more subject columns within name(s) z, z are not present in the table)foreign_keysrF   r   intersectionr   r1  Tabler.  rd   r5  joinBLANK_SCHEMAappend_constraintForeignKeyConstraintr   ConstraintColumnNotFoundErrorr   warnr   )r2   r	  r   r   r  r  r  r  r  r  r   fkey_dconnamerC  r   r   rJ  refspeccolumnrM  r?   rI  r@   r    s   
		


zInspector._reflect_fk)ascdescnulls_first
nulls_lastc                 C  s  |j |g }|D ]}	|	d }
|	d }|	d}|	di }|	d }|	dd}|	di }|	d	}|r=t||s=q	|r@q	g }t|D ]i\}}|d u rk|sctd
| d|
d|d  d  n\t|| }n?z||v ru|| }n|j	| }W n t
y   t| d|d|j Y qFw ||dD ]}|| jv r| j| }||}q|| qFtj|
g|R ||d| q	d S )Nr   column_namesexpressionscolumn_sortingr   r   indexr(  duplicates_constraintz	Skipping  z because key r   z5 reflected as None but no 'expressions' were returnedz key z& was not located in columns for table r?   )_tabler   )indexesrF   r   issubset	enumerater   rW  r   r4  rH  KeyErrorr   _index_sort_exprsr5  r1  Index)r2   r	  r   r   r  r  r  r  rg  index_dr   r  ra  rb  r   flavorr(  
duplicatesidx_elementsrc  rH  idx_elementoptionopr?   r?   r@   r    sp   





zInspector._reflect_indexesc              
   C  s   |j |g }|D ]d}	|	d }
|	d }|	d}|	d}|	di }|r-t||s-q	|r0q	g }|D ]*}z||v r?|| n|j| }W n tyX   td||jf  Y q4w |	| q4|
tj||
|d| q	d S )Nr   r`  r'  duplicates_indexr(  zDunique constraint key '%s' was not located in columns for table '%s')r   r'  )unique_constraintsrF   r   rh  rH  rj  r   rW  r   r5  rT  r1  UniqueConstraint)r2   r	  r   r   r  r  r  r  constraintsconst_drY  r  r'  ro  r(  constrained_colsrH  constrained_colr?   r?   r@   r  _  sH   


z%Inspector._reflect_unique_constraintsc           
      C  s2   |j |g }|D ]}	|tjdi |	 q	d S )Nr?   )check_constraintsrF   rT  r1  CheckConstraint)
r2   r	  r   r   r  r  r  r  rw  rx  r?   r?   r@   r    s   
z$Inspector._reflect_check_constraintsc                 C  s"   |j |}|r|d |_d S d S Nr4  )table_commentrF   r'  )r2   r	  r   r   r  comment_dictr?   r?   r@   r    s   z Inspector._reflect_table_comment	availablec           	        s   |d<  r|rt  dkrt  t | nd i  d< }ddddd fdd}t|jdd|j|j|j|jdd|jdd|jdd|j	dd|d	}|rh|
| |S |S )Nr   d   r8   TF)optionalcheck_filter_names_from_methmethr   r  rf   r  r6   c                  s   d u sdksj | js }nd }zr/| dd|i}|r)|s,dW |S W |S W |S i }W |S  tyB   |s= i }Y |S w )Ng      ?r   Fr?   )rh   _overrides_defaultrG   NotImplementedError)r  r  r  _fnr   r   fraction
has_resultr5   r2   r?   r@   run  s0   

z+Inspector._get_reflection_info.<locals>.run)r  )r  )	r  rD  rO  rg  ru  r~  r{  r  r8   )r  r   r  rf   r  rf   r6   r   )lenr@  r   r   r   r   r   r   r   r   r   )	r2   r   r   r  r	  r5   r8   r  r&  r?   r  r@   r    s<   #
zInspector._get_reflection_info)rd   rc   )rl   rm   rd   rc   r6   rb   )rd   rc   r6   rs   )re   r   r6   rs   )ry   r   r6   rs   )r6   rs   )rd   r   r6   rb   )rd   r   r6   rb   )r6   r   )r6   r   )r6   r   )r5   r   r6   r   )r   r   r5   r   r6   r   )r   r;   r   r   r5   r   r6   rf   )r   r;   r   r   r5   r   r6   rf   )
r   r;   r   r;   r   r   r5   r   r6   rf   )r   r;   r5   r   r6   rf   )r   r   r5   r   r6   r   )r9   )r   r   r5   r   r6   r   )r   r;   r   r   r5   r   r6   r   )r   r   r   r   r   rV   r   r_   r5   r   r6   r   )r   r;   r   r   r5   r   r6   r;   )r   r;   r   r   r5   r   r6   r   )r   r   r6   rs   )r   r   r   r   r   rV   r   r_   r5   r   r6   r   )r   r;   r   r   r5   r   r6   r+   )r   r   r   r   r   rV   r   r_   r5   r   r6   r   )r   r;   r   r   r5   r   r6   r   )r   r   r   r   r   rV   r   r_   r5   r   r6   r   )r   r;   r   r   r5   r   r6   r   )r   r   r   r   r   rV   r   r_   r5   r   r6   r   )r   r;   r   r   r5   r   r6   r   )r   r   r   r   r   rV   r   r_   r5   r   r6   r   )r   r;   r   r   r5   r   r6   r,   )r   r   r   r   r   rV   r   r_   r5   r   r6   r   )r   r;   r   r   r5   r   r6   r   )r   r   r   r   r   rV   r   r_   r5   r   r6   r   )r?   TNN)r   r  r  r  r  r  r  rf   r  r  r	  r
  r6   rs   )r   r  r   r(   r  r  r  r  r  r"  r6   rs   )r	  r@  r   r.   r   r  r  r"  r  r  r6   rs   )r	  r@  r   r.   r   r  r  r"  r  r  r  r  r  rf   r  r  r  r   r6   rs   )r	  r@  r   r.   r   r  r  r"  r  r  r  r  r  r   r6   rs   )
r	  r@  r   r.   r   r  r  r   r6   rs   )NNNN)r   r   r   r  r  r  r	  r
  r5   r   r6   r@  )MrG   rW   rX   rY   __annotations__r   
deprecatedrk   classmethodrr   ri   rv   ru   r|   r}   r   	_inspectsr   r   r   r   
contextlibcontextmanagerr   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   rV   rZ   r_   r`   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r!  r  r  r  r   asc_opdesc_opnulls_first_opnulls_last_oprk  r  r  r  r  r  r?   r?   r?   r@   rb      s  
 






""
/
N
!:
"<9!; :!;$=!> 

H
Z

B
0
rb   c                   @  s   e Zd ZdZedddZedddZedd
dZedddZed ddZ	ed!ddZ
ed"ddZed#ddZdS )$ReflectionDefaultsz5provides blank default values for reflection methods.r6   r   c                 C     g S r9   r?   rq   r?   r?   r@   r       zReflectionDefaults.columnsr+   c                 C  s
   d g dS )N)r   rC  r?   r  r?   r?   r@   rD    s   z ReflectionDefaults.pk_constraintr   c                 C  r  r9   r?   r  r?   r?   r@   rO    r  zReflectionDefaults.foreign_keysr   c                 C  r  r9   r?   r  r?   r?   r@   rg  
  r  zReflectionDefaults.indexesr   c                 C  r  r9   r?   r  r?   r?   r@   ru    r  z%ReflectionDefaults.unique_constraintsr   c                 C  r  r9   r?   r  r?   r?   r@   r{    r  z$ReflectionDefaults.check_constraintsr   c                 C  s   i S r9   r?   r  r?   r?   r@   r    r  z ReflectionDefaults.table_optionsr,   c                 C  s   dd iS r}  r?   r  r?   r?   r@   r~    s   z ReflectionDefaults.table_commentN)r6   r   )r6   r+   )r6   r   )r6   r   )r6   r   )r6   r   )r6   r   )r6   r,   )rG   rW   rX   rY   r  r  rD  rO  rg  ru  r{  r  r~  r?   r?   r?   r@   r    s$    r  c                   @  s`   e Zd ZU ded< ded< ded< ded< d	ed
< ded< ded< ded< ded< dddZdS )r@  r   r  z7Dict[TableKey, Optional[ReflectedPrimaryKeyConstraint]]rD  r   rO  r   rg  r   ru  z/Dict[TableKey, Optional[ReflectedTableComment]]r~  r   r{  r   r  z+Dict[TableKey, exc.UnreflectableTableError]r8   otherr6   rs   c                 C  sJ   | j  D ]\}}t||}|d ur"|d u rt| || q|| qd S r9   )__dict__rI   getattrsetattrr   )r2   r  rB   rC   ovr?   r?   r@   r   ,  s   

z_ReflectionInfo.updateN)r  r@  r6   rs   )rG   rW   rX   r  r   r?   r?   r?   r@   r@    s   
 r@  rS   )rN   rO   r6   rP   )ErY   
__future__r   r  dataclassesr   enumr   r   r   typingr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   baser   r    r   r   r   r   r   r   r1  sql.cache_keyr   sql.elementsr    r!   sql.type_apir"   sql.visitorsr#   r$   util.typingr%   
interfacesr&   r'   r(   r)   r*   r+   r,   r-   r.   r/   rT   rM   rU   rV   r_   _self_inspectsInspectablerb   r  r@  r?   r?   r?   r@   <module>   s   
              O'