
    +h                         d 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 e
j"                  d        Zej&                   G d de             Zy)a  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..
    N   )Connectable)
Connection)Engine   )exc)
inspection)sql)util)	operators)schema)
TypeEngine)topologicalc                    |j                  dd       }| | ||g|i |S | j                  t        d |D              t        d |j                         D              f}|j                  |      }| | ||g|i |}|||<   |S )N
info_cachec              3   V   K   | ]!  }t        |t        j                        s| # y wN)
isinstancer   string_types).0as     O/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/engine/reflection.py	<genexpr>zcache.<locals>.<genexpr>2   s     BAAt/@/@!AaBs   ))c              3   6   K   | ]  \  }}|d k7  s||f  yw)r   N )r   kvs      r   r   zcache.<locals>.<genexpr>3   s     AAqL/@q!fAs   	)get__name__tupleitems)fnselfconargskwr   keyrets           r   cacher)   +   s    d+J$)d)b))
BBBAAAC
 ..
C
{s(T(R(
3J    c                      e Zd ZdZ ej
                  dd      d        Zed        Zd Z	d Z
d Ze ej
                  dd	      d
               Z ej                  e      d        Z ej                  e      d        Z ej                  e      d        Zej,                  d        Zej,                  d        Zed        Zd Zd4dZd4dZd4dZd4dZd Z d Z!d4dZ"d4dZ#d4dZ$d4dZ%d4dZ&d4dZ'd4dZ(d4d Z)d4d!Z*d4d"Z+d4d#Z, ejZ                  d$d%      d&        Z.	 	 	 d5d'Z/d( Z0d) Z1d* Z2d+ Z3d,e4jj                  fd-e4jl                  fd.e4jn                  fd/e4jp                  fgZ9d0 Z:d1 Z;d2 Z<d3 Z=y)6	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.

    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                 $    | j                  |      S )a  Initialize a new :class:`_reflection.Inspector`.

        :param bind: a :class:`~sqlalchemy.engine.Connectable`,
          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`

        )_init_legacyr#   binds     r   __init__zInspector.__init__U   s    .   &&r*   c                     t        |j                  d      r|j                  j                  } | j                  |       } |||       |S )N	inspector)hasattrdialectr3   __new__)clsinitr0   r#   s       r   
_constructzInspector._constructn   s>     4<<-,,((C{{3T4r*   c                 b    t        |d      r| j                  |       y | j                  |       y )Nexec_driver_sql)r4   _init_connection_init_enginer/   s     r   r.   zInspector._init_legacyx   s)    4*+!!$'d#r*   c                     |x| _         | _        |j                         j                          d| _        | j                  j
                  | _        i | _        y )NT)r0   engineconnectclose_op_context_requires_connectr5   r   )r#   r?   s     r   r=   zInspector._init_engine~   sC    "((	DK ,0){{**r*   c                     || _         |j                  | _        d| _        | j                  j                  | _        i | _        y )NF)r0   r?   rB   r5   r   )r#   
connections     r   r<   zInspector._init_connection   s6    	 '',1){{**r*   a  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                 :    | j                  | j                  |      S )a  Construct a new dialect-specific Inspector object from the given
        engine or connection.

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

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

        )r9   r.   )r7   r0   s     r   from_enginezInspector.from_engine   s    > ~~c..55r*   c                 J    t         j                  t         j                  |       S r   )r,   r9   r.   r0   s    r   _connectable_inspzInspector._connectable_insp   s    
 ##I$:$:DAAr*   c                 J    t         j                  t         j                  |       S r   )r,   r9   r=   rH   s    r   _engine_inspzInspector._engine_insp   s    ##I$:$:DAAr*   c                 J    t         j                  t         j                  |       S r   )r,   r9   r<   rH   s    r   _connection_inspzInspector._connection_insp   s    ##I$>$>EEr*   c              #      K   | j                   r| j                  j                         }n| j                  }	 | | j                   r|j                          yy# | j                   r|j                          w w xY 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)rB   r0   r@   rA   r#   conns     r   _operation_contextzInspector._operation_context   sd      ,,99$$&D99D	J00

 1t00

 1s   4A;A A;A88A;c              #      K   | j                         5 }| j                  | j                  j                  |      }| j                  |_        | ddd       y# 1 sw Y   yxY ww)zReturn an :class:`_reflection.Inspector`
        from this one that will run all
        operations on a single connection.

        N)rQ   r9   	__class__r<   r   )r#   rP   sub_insps      r   _inspection_contextzInspector._inspection_context   sU      $$& 	$t~~'F'FMH"&//HN	 	 	s   A$<A	A$A!A$c                 .    | 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.

        )r5   default_schema_name)r#   s    r   rW   zInspector.default_schema_name   s     ||///r*   c                     t        | j                  d      rA| j                         5 }| j                  j                  || j                        cddd       S g S # 1 sw Y   g S xY w)zReturn all schema names.get_schema_namesr   N)r4   r5   rQ   rY   r   rO   s     r   rY   zInspector.get_schema_names   sd     4<<!34((* d||44T__ 5   		 	s   'AA$Nc                     | j                         5 }| j                  j                  ||| j                        cddd       S # 1 sw Y   yxY w)a  Return all table names in referred to 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`
        method.


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

        .. seealso::

            :meth:`_reflection.Inspector.get_sorted_table_and_fkc_names`

            :attr:`_schema.MetaData.sorted_tables`

        rZ   N)rQ   r5   get_table_namesr   r#   r   rP   s      r   r\   zInspector.get_table_names   sI    . $$& 	$<<//f 0 	 	 	   (AAc                     | j                         5 }| j                  j                  |||      cddd       S # 1 sw Y   yxY w)aM  Return True if the backend has a 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.

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

        N)rQ   r5   	has_table)r#   
table_namer   rP   s       r   r`   zInspector.has_table  sA     $$& 	D$<<))$
FC	D 	D 	D	   8Ac                     | j                         5 }| j                  j                  |||      cddd       S # 1 sw Y   yxY w)zReturn True if the backend has a table of the given name.

        :param sequence_name: name of the table to check
        :param schema: schema name to query, if not the default schema.

        .. versionadded:: 1.4

        N)rQ   r5   has_sequence)r#   sequence_namer   rP   s       r   rd   zInspector.has_sequence  sA     $$& 	J$<<,,T=&I	J 	J 	Jrb   c                 B   | j                         5 }| j                  j                  ||| j                        }ddd       t	               }t	               }i }D ]Y  }| j                  ||      }t	        |D 	cg c]  }	|	d   	 c}	      ||<   |D ]!  }
||
d   k7  s|j                  |
d   |f       # [ 	 t        t        j                  ||            }|D cg c]  }|||   j                  |      f c}dt        |      fgz   S # 1 sw Y   xY wc c}	w # t        j                  $ rk}|j                  D ]3  |j                         |j                  fd|d      D               5 t        t        j                  ||            }Y d}~d}~ww xY wc c}w )a  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.

        .. versionadded:: 1.0.-

        .. seealso::

            :meth:`_reflection.Inspector.get_table_names`

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

        rZ   Nnamereferred_tablec              3   ,   K   | ]  }d    |f  yw)r   Nr   )r   fkcedges     r   r   z;Inspector.get_sorted_table_and_fkc_names.<locals>.<genexpr>W  s      &'*T!WcN&s   r   )rQ   r5   r\   r   setget_foreign_keysaddlistr   sortr   CircularDependencyErroredgesremoveupdate
difference)r#   r   rP   tnamestuplesremaining_fkcsfknames_for_tabletnamefkeysfkfkeycandidate_sorterrrk   s                @r   get_sorted_table_and_fkc_namesz(Inspector.get_sorted_table_and_fkc_names*  s   2 $$& 	$\\11f 2 F	
  	@E))%8E'*+G2BvJ+G'He$ @D!122JJ%5 6>?@	@		D!+"2"266"BCN (
 %e,77GH
 D()*+ 	+3	 	 ,H ** 	D		 d#%% &.?Q.H&  "+"2"266"BCN	D
s0   )D
9D
8D F
DF.A!FFc                     | j                         5 }| j                  j                  || j                        cddd       S # 1 sw Y   yxY w)zReturn a list of temporary table names for the current bind.

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

        .. versionadded:: 1.0.0

        rZ   N)rQ   r5   get_temp_table_namesr   rO   s     r   r   zInspector.get_temp_table_namesa  sG     $$& 	$<<44 5 	 	 	   'AAc                     | j                         5 }| j                  j                  || j                        cddd       S # 1 sw Y   yxY w)zReturn a list of temporary view names for the current bind.

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

        .. versionadded:: 1.0.0

        rZ   N)rQ   r5   get_temp_view_namesr   rO   s     r   r   zInspector.get_temp_view_namesp  sG     $$& 	$<<33 4 	 	 	r   c                     t        | j                  d      rE| j                         5 } | j                  j                  |||fd| j                  i|cddd       S i S # 1 sw Y   i S xY w)a  Return a dictionary of options specified when the table of the
        given name was created.

        This currently includes some options that apply to MySQL 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`.

        get_table_optionsr   N)r4   r5   rQ   r   r   r#   ra   r   r&   rP   s        r   r   zInspector.get_table_options~  ss     4<<!45((* d5t||55*f9=LN  		 	s   +AA(c                     | j                         5 }| j                  j                  ||| j                        cddd       S # 1 sw Y   yxY w)zReturn all view names in `schema`.

        :param schema: Optional, retrieve names from a non-default schema.
         For special quoting, use :class:`.quoted_name`.

        rZ   N)rQ   r5   get_view_namesr   r]   s      r   r   zInspector.get_view_names  sI     $$& 	$<<..f / 	 	 	r^   c                     | j                         5 }| j                  j                  ||| j                        cddd       S # 1 sw Y   yxY w)zReturn all sequence names in `schema`.

        :param schema: Optional, retrieve names from a non-default schema.
         For special quoting, use :class:`.quoted_name`.

        rZ   N)rQ   r5   get_sequence_namesr   r]   s      r   r   zInspector.get_sequence_names  sI     $$& 	$<<22f 3 	 	 	r^   c                     | j                         5 }| j                  j                  |||| j                        cddd       S # 1 sw Y   yxY w)zReturn definition for `view_name`.

        :param schema: Optional, retrieve names from a non-default schema.
         For special quoting, use :class:`.quoted_name`.

        rZ   N)rQ   r5   get_view_definitionr   )r#   	view_namer   rP   s       r   r   zInspector.get_view_definition  sK     $$& 	$<<33iDOO 4 	 	 	s   )AAc                     | j                         5 } | j                  j                  |||fd| j                  i|}ddd       D ]"  }|d   }t	        |t
              r |       |d<   $ |S # 1 sw Y   2xY w)a  Return information about columns in `table_name`.

        Given a string `table_name` and an optional string `schema`, return
        column information as a list of dicts with these keys:

        * ``name`` - the column's name

        * ``type`` - the type of this column; an instance of
          :class:`~sqlalchemy.types.TypeEngine`

        * ``nullable`` - boolean flag if the column is NULL or NOT NULL

        * ``default`` - the column's server default value - this is returned
          as a string SQL expression.

        * ``autoincrement`` - indicates that the column is auto incremented -
          this is returned as a boolean or 'auto'

        * ``comment`` - (optional) the comment on the column. Only some
          dialects return this key

        * ``computed`` - (optional) when present it indicates that this column
          is computed by the database. Only some dialects return this key.
          Returned as a dict with the keys:

          * ``sqltext`` - the expression used to generate this column returned
            as a string SQL expression

          * ``persisted`` - (optional) boolean that indicates if the column is
            stored in the table

          .. versionadded:: 1.3.16 - added support for computed reflection.

        * ``identity`` - (optional) when present it indicates that this column
          is a generated always column. Only some dialects return this key.
          For a list of keywords on this dict see :class:`_schema.Identity`.

          .. versionadded:: 1.4 - added support for identity column reflection.

        * ``dialect_options`` - (optional) a dict with dialect specific options

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

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

        r   Ntype)rQ   r5   get_columnsr   r   r   )r#   ra   r   r&   rP   col_defscol_defcoltypes           r   r   zInspector.get_columns  s    l $$& 	$/t||//j&59__HJH	   	,GfoGgz2"))		,
 	 	s   ,A..A7c                     | j                         5 } | j                  j                  |||fd| j                  i|cddd       S # 1 sw Y   yxY w)a  Return information about primary key constraint on `table_name`.

        Given a string `table_name`, and an optional string `schema`, return
        primary key information as a dictionary with these keys:

        * ``constrained_columns`` -
          a list of column names that make up the primary key

        * ``name`` -
          optional name of the primary key constraint.

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

        r   N)rQ   r5   get_pk_constraintr   r   s        r   r   zInspector.get_pk_constraint  sV    ( $$& 	$14<<11j&59__HJ	 	 	   +AAc                     | j                         5 } | j                  j                  |||fd| j                  i|cddd       S # 1 sw Y   yxY w)a  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 dicts with these keys:

        * ``constrained_columns`` -
          a list of column names that make up the foreign key

        * ``referred_schema`` -
          the name of the referred schema

        * ``referred_table`` -
          the name of the referred table

        * ``referred_columns`` -
          a list of column names in the referred table that correspond to
          constrained_columns

        * ``name`` -
          optional name of the foreign key constraint.

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

        r   N)rQ   r5   rm   r   r   s        r   rm   zInspector.get_foreign_keys  sV    > $$& 	$04<<00j&59__HJ	 	 	r   c                     | j                         5 } | j                  j                  |||fd| j                  i|cddd       S # 1 sw Y   yxY w)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 dicts with these keys:

        * ``name`` -
          the index's name

        * ``column_names`` -
          list of column names in order

        * ``unique`` -
          boolean

        * ``column_sorting`` -
          optional dict mapping column names to tuple of sort keywords,
          which may include ``asc``, ``desc``, ``nulls_first``, ``nulls_last``.

          .. versionadded:: 1.3.5

        * ``dialect_options`` -
          dict of dialect-specific index options.  May not be present
          for all dialects.

          .. versionadded:: 1.0.0

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

        r   N)rQ   r5   get_indexesr   r   s        r   r   zInspector.get_indexes8  sW    H $$& 	$+4<<++j&59__HJ	 	 	r   c                     | j                         5 } | j                  j                  |||fd| j                  i|cddd       S # 1 sw Y   yxY w)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 dicts with these keys:

        * ``name`` -
          the unique constraint's name

        * ``column_names`` -
          list of column names in order

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

        r   N)rQ   r5   get_unique_constraintsr   r   s        r   r   z Inspector.get_unique_constraintsa  sV    * $$& 	$64<<66j&59__HJ	 	 	r   c                     | j                         5 } | j                  j                  |||fd| j                  i|cddd       S # 1 sw Y   yxY w)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 dictionary with these keys:

        * ``text`` -
            text of the comment.

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

        .. versionadded:: 1.2

        r   N)rQ   r5   get_table_commentr   r   s        r   r   zInspector.get_table_comment{  sV      $$& 	$14<<11j&59__HJ	 	 	r   c                     | j                         5 } | j                  j                  |||fd| j                  i|cddd       S # 1 sw Y   yxY w)ac  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 dicts with these keys:

        * ``name`` -
          the check constraint's name

        * ``sqltext`` -
          the check constraint's SQL expression

        * ``dialect_options`` -
          may or may not be present; a dictionary with additional
          dialect-specific options for this CHECK constraint

          .. versionadded:: 1.3.8

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

        .. versionadded:: 1.1.0

        r   N)rQ   r5   get_check_constraintsr   r   s        r   r   zInspector.get_check_constraints  sV    : $$& 	$54<<55j&59__HJ	 	 	r   z*:meth:`_reflection.Inspector.reflecttable`zThe :meth:`_reflection.Inspector.reflecttable` method was renamed to :meth:`_reflection.Inspector.reflect_table`. This deprecated alias will be removed in a future release.c                 &     | j                   |i |S )z1See reflect_table. This method name is deprecated)reflect_table)r#   r%   kwargss      r   reflecttablezInspector.reflecttable  s     "t!!42622r*   c                 .   ||v ry|j                         | j                  j                  }| j                         5 }|j	                        }ddd       j
                  }	t        fd|j                  D              }
 | j                  |	fi j                  }|rj                  |       t        j                  rVt        |t              r|j                  |j                         }t        |	t              r|	j                  |j                         }	d}i } | j"                  |	|fi j                  D ]  }d}| j%                  ||||        |s'| j'                  |	|      st)        j*                  |	      | j-                  |	|||       | j/                  |	|||||||
	       | j1                  |	|||||
       | j3                  |	|||||
       | j5                  |	|||||
       | j7                  |	||
       y# 1 sw Y   xY w)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              3   t   K   | ]/  }|j                   v r|j                   j                  |      f 1 y wr   )dialect_kwargsr   )r   r   tables     r   r   z*Inspector.reflect_table.<locals>.<genexpr>  s=      "
E((( $$((+,"
s   58FT)rn   r0   r5   rQ   schema_for_objectrg   dictreflection_optionsr   r   _validate_dialect_kwargsr   py2kr   strdecodeencodingr   _reflect_columnr`   r   NoSuchTableError_reflect_pk_reflect_fk_reflect_indexes_reflect_unique_constraints_reflect_check_constraints_reflect_table_comment)r#   r   include_columnsexclude_columnsresolve_fks
_extend_onr5   rP   r   ra   r   tbl_optsfound_tablecols_by_orig_namecol_ds    `             r   r   zInspector.reflect_table  sa   @ !
"u%))##$$& 	3$++E2F	3 ZZ
 " "
//"
 
 *4))
"'"6"6
  **8499&#&w'7'78*c*'..w/?/?@
%T%%
"'"6"6
 	E K  !	 4>>*f#E&&z22'8/	
 	
	
 		
 	((	
 	''	
 	##'9	
A	3 	3s    H

Hc                    d   }|j                   j                  j                  | |       |j                  j                  | |       d   }|r||vs|r||v ry d   }t        fddD              }	dv r|	j	                  d          g }
j                  d      d   }t        |t        j                  j                        rt        j                  |d      }nGt        |t        j                        s-t        j                  t        j                  d         d      }|
j                  |       d	v r)t        j                  di d	   }|
j                  |       d
v r)t        j                   di d
   }|
j                  |       dv r| j#                  |
       t        j$                  ||g|
i |	x||<   }|j&                  |j(                  v rd|_        |j+                  |d       y )Nrg   r   c              3   4   K   | ]  }|v r	||   f  y wr   r   )r   r   r   s     r   r   z,Inspector._reflect_column.<locals>.<genexpr>\  s*      
 Ez aM
s   )nullableautoincrementquoteinfor'   commentdialect_optionsdefaultT)
_reflectedcomputedidentitysequence)replace_existingr   )metadatadispatchcolumn_reflectr   rt   r   r   r
   elements
TextClause	sa_schemaDefaultClauseFetchedValuetextappendComputedIdentity_reflect_col_sequenceColumnr'   primary_keyappend_column)r#   r   r   r   r   r   	orig_namerg   r   col_kwcolargsr   r   cols     `           r   r   zInspector._reflect_columnI  s    &M	..tUEB%%dE59 V}O ; 7- 

 
 %MM% 12399Y+I&G'3<<#:#:;#11'dK)?)?@#11HHU9-.4 NN7# ))>E*,=>HNN8$ ))>E*,=>HNN8$&&ug6-6-=-='.
#.
'-.
 	
)$s 77e'''"COC$7r*   c                     d|v rM|d   }t        j                  |d   dd      }d|v r
|d   |_        d|v r
|d   |_        |j	                  |       y y )Nr   rg   r   start	increment)r   Sequencer   r   r   )r#   r   r   seqr   s        r   r   zInspector._reflect_col_sequence  sd    
#C ))#f+q!<H#~!$Wc!%(%5"NN8$ r*   c                      | j                   ||fi |j                  }|rY|d   D cg c]  }||v r	||vr||    }}|j                  d      |j                  _        |j                  j                  |       y y c c}w )Nconstrained_columnsrg   )r   r   r   r   rg   _reload)	r#   ra   r   r   r   r   pk_conspkpk_colss	            r   r   zInspector._reflect_pk  s     )$((
"'"6"6
  ""78**r/H ""%G  &-[[%8E" %%g. s   A;c
           	      :    | j                   ||fi |j                  }
|
D ]r  }|d   }|d   D cg c]  }||v r||   j                  n| }}|rt        |      j	                  |      s|rt        |      j                  |      rg|d   }|d   }|d   }g }|\|r/t        j                  ||j                  f|| j                  |d|	 |D ]%  }|j                  dj                  |||g             ' nh|r=t        j                  ||j                  f| j                  t        j                  |d|	 |D ]$  }|j                  dj                  ||g             & d	|v r|d	   }ni }|j                  t        j                  |||fd
di|       u y c c}w )Nrg   r   referred_schemarh   referred_columns)r   autoload_withr   .)r   r   r   optionslink_to_nameT)rm   r   r'   rl   intersectionru   r   Tabler   r0   r   joinBLANK_SCHEMAappend_constraintForeignKeyConstraint)r#   ra   r   r   r   r   r   r   r   r   r{   fkey_dconnamecr   r   rh   r   refspeccolumnr   s                        r   r   zInspector._reflect_fk  s    &%%
"'"6"6
  >	FVnG
   56# -.1B,B!!$((I# #  +,99/J#/0;;OL $%67O#$45N%&89G*OO&  /&*ii#- - / FNN/>6!JK
 OO& '+ii(55#- - / GFNN388^V,D#EFGF" +##..' "&	
 m>	#s   Fascdescnulls_first
nulls_lastc                 $   | j                  ||      }|D ]K  }	|	d   }
|	d   }|	j                  di       }|	d   }|	j                  dd      }|	j                  di       }|	j                  d      }|rFt        |      j                  |      s,t	        j
                  d	|d
dj                  |      d       |rg }|D ]_  }	 ||v r||   n|j                  |   }|j                  |d      }| j                  D ]  \  }}||v s ||      } |j                  |       a t        j                  |
g|d|it        t        |j                               d|fgz          N y # t        $ r! t	        j
                  |d|d|d       Y w xY w)Nrg   column_namescolumn_sortinguniquer   indexr   duplicates_constraintz	Omitting z
 key for (, z), key covers omitted columns.z key '(' was not located in columns for table ''r   _table)r   r   rl   issubsetr   warnr   r   KeyError_index_sort_exprsr   r   Indexr   ro   r!   )r#   ra   r   r   r   r   r   r   indexesindex_drg   columnsr  r  flavorr   
duplicatesidx_colsr   idx_col	c_sortingr   ops                          r   r   zInspector._reflect_indexes   s    "":v6 ,	G6?Dn-G$[[)92>NX&F[[1F%kk*;R@O %<=Js7|'<'<_'M		tyy13  H )  11 *!,"WWQZ  +..q"5	!33 .EArI~"$W+. (#)& OO  tO113468J7KKL	O,	6   II4:AzK s   E%%'FFc           
         	 | j                  ||      }|D ]  }	|	d   }
|	d   }|	j                  d      }|rBt        |      j	                  |      s(t        j                  ddj                  |      z         b|reg }|D ],  }	 ||v r||   n|j                  |   }|j                  |       . |j                  t        j                  |d|
i        y # t        $ r Y y w xY w# t        $ r t        j                  d|d|d       Y w xY w)	Nrg   r  duplicates_indexzDOmitting unique constraint key for (%s), key covers omitted columns.r  zunique constraint key 'r  r  )r   NotImplementedErrorr   rl   r  r   r  r   r   r   r  r   r   UniqueConstraint)r#   ra   r   r   r   r   r   r   constraintsconst_dr   r  r  constrained_colsr   constrained_cols                   r   r   z%Inspector._reflect_unique_constraints:  s>   	55j&IK
 # 	GfoGn-G %78Js7|'<'<_'M		248IIg4FG   " ==  11 *!,"WWQZ $ %++O<= ##**,<K7K;		 # 		4   II45zCs#   C C$	C! C!$%DDc                     	 | j                  ||      }|D ]&  }	|j                  t        j                  di |	       ( y # t        $ r Y y w xY w)Nr   )r   r  r   r   CheckConstraint)
r#   ra   r   r   r   r   r   r   r!  r"  s
             r   r   z$Inspector._reflect_check_constraintsm  s\    	44ZHK
 # 	JG##I$=$=$H$HI	J	 # 		s   A   	AAc                 v    	 | j                  ||      }|j                  dd       |_        y # t        $ r Y y w xY w)Nr   )r   r   r   r  )r#   ra   r   r   r   comment_dicts         r   r   z Inspector._reflect_table_comment  sC    	;11*fEL ),,VT:EM # 		s   , 	88r   )r   TN)>r   
__module____qualname____doc__r   
deprecatedr1   classmethodr9   r.   r=   r<   rF   r	   	_inspectsr   rI   r   rK   r   rM   
contextlibcontextmanagerrQ   rU   propertyrW   rY   r\   r`   rd   r   r   r   r   r   r   r   r   r   rm   r   r   r   r   deprecated_20r   r   r   r   r   r   r   asc_opdesc_opnulls_first_opnulls_last_opr  r   r   r   r   r   r*   r   r,   r,   <   s>   . T__	5
'
'  $ T__	5
6
 6* Z+&B 'B Z&!B "B Z*%F &F  & 
 
 0 08DJ5+n*?B2"H'R4* D T4	/33 J
X@8D	%/(M` 
	  !	""#		001	y../	8t1fJ&;r*   r,   )r+  r/  baser   r   r    r   r	   r
   r   r   r   r   sql.type_apir   r   	decoratorr)   _self_inspectsobjectr,   r   r*   r   <module>r=     sl   (          % %     K; K; K;r*   