ó
¿b›]c           @   sÒ   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d	 l m	 Z
 d d
 l m Z d d l m Z d d l m Z e j d „  ƒ Z d e f d „  ƒ  YZ d S(   sã  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..
i   (   t   Connectablei   (   t   exc(   t
   inspection(   t   sql(   t   util(   t	   operators(   t   schema(   t
   TypeEngine(   t
   deprecated(   t   topologicalc         O   sª   | j  d d  ƒ } | d  k r1 |  | | | | Ž S|  j t d „  | Dƒ ƒ t d „  | j ƒ  Dƒ ƒ f } | j  | ƒ } | d  k r¦ |  | | | | Ž } | | | <n  | S(   Nt
   info_cachec         s   s'   |  ] } t  | t j ƒ r | Vq d  S(   N(   t
   isinstanceR   t   string_types(   t   .0t   a(    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pys	   <genexpr>/   s    c         s   sA   |  ]7 \ } } t  | t j t j t f ƒ r | | f Vq d  S(   N(   R   R   R   t	   int_typest   float(   R   t   kt   v(    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pys	   <genexpr>1   s   	(   t   gett   Nonet   __name__t   tuplet   items(   t   fnt   selft   cont   argst   kwR
   t   keyt   ret(    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyt   cache(   s    t	   Inspectorc           B   s¸  e  Z d  Z d „  Z e d „  ƒ Z e j e ƒ d „  ƒ Z	 e
 d „  ƒ Z d „  Z e j d d' ƒ d( d( d	 „ ƒ Z d( d
 „ Z d „  Z d „  Z d( d „ Z d( d „ Z d( d „ Z d( d „ Z e d d ƒ d( d „ ƒ Z d( d „ Z d( d „ Z d( d „ Z d( d „ Z d( d „ Z d( d „ Z d) e  d( d „ Z! d „  Z" d „  Z# d „  Z$ d „  Z% d e& j' f d  e& j( f d! e& j) f d" e& j* f g Z+ d# „  Z, d$ „  Z- d% „  Z. d& „  Z/ RS(*   sm  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:`.Inspector` object is usually created via the
    :func:`.inspect` function::

        from sqlalchemy import inspect, create_engine
        engine = create_engine('...')
        insp = inspect(engine)

    The inspection method above is equivalent to using the
    :meth:`.Inspector.from_engine` method, i.e.::

        engine = create_engine('...')
        insp = Inspector.from_engine(engine)

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

    c         C   sn   | |  _  t | d ƒ r' | j |  _ n	 | |  _ |  j | k rR | j ƒ  j ƒ  n  |  j j |  _ i  |  _ d S(   sj  Initialize a new :class:`.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:`.Inspector`, see
        :meth:`.Inspector.from_engine`

        t   engineN(   t   bindt   hasattrR!   t   connectt   closet   dialectR
   (   R   R"   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyt   __init__X   s    		c         C   s,   t  | j d ƒ r" | j j | ƒ St | ƒ S(   s‘  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:`.Inspector` in that the
        :class:`~sqlalchemy.engine.interfaces.Dialect` is given a chance to
        provide a dialect-specific :class:`.Inspector` instance, which may
        provide additional methods.

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

        t	   inspector(   R#   R&   R(   R    (   t   clsR"   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyt   from_enginet   s    c         C   s   t  j |  ƒ S(   N(   R    R*   (   R"   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyt   _insp‹   s    c         C   s
   |  j  j S(   sÏ   Return 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.

        (   R&   t   default_schema_name(   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR,      s    	c         C   s2   t  |  j d ƒ r. |  j j |  j d |  j ƒSg  S(   s!   Return all schema names.
        t   get_schema_namesR
   (   R#   R&   R-   R"   R
   (   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR-   š   s    	t   order_bys   1.0sþ   The :paramref:`get_table_names.order_by` parameter is deprecated and will be removed in a future release.  Please refer to :meth:`.Inspector.get_sorted_table_and_fkc_names` for a more comprehensive solution to resolving foreign key cycles between tables.c         C   sÑ   t  |  j d ƒ r6 |  j j |  j | d |  j ƒ} n |  j j | ƒ } | d k rÍ g  } xU | D]M } xD |  j | | ƒ D]0 } | | d k rz | j | d | f ƒ qz qz Wqa Wt	 t
 j | | ƒ ƒ } n  | S(   sÀ  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:`.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`.

        :param order_by: Optional, may be the string "foreign_key" to sort
         the result on foreign key dependencies.  Does not automatically
         resolve cycles, and will raise :class:`.CircularDependencyError`
         if cycles exist.

        .. seealso::

            :meth:`.Inspector.get_sorted_table_and_fkc_names`

            :attr:`.MetaData.sorted_tables`

        t   get_table_namesR
   t   foreign_keyt   referred_table(   R#   R&   R/   R"   R
   R!   t   table_namest   get_foreign_keyst   appendt   listR	   t   sort(   R   R   R.   t   tnamest   tuplest   tnamet   fkey(    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR/   ¤   s    %	"c            sµ  t  |  j d ƒ r6 |  j j |  j | d |  j ƒ} n |  j j | ƒ } t ƒ  } t ƒ  } i  } x‚ | D]z } |  j | | ƒ } t g  | D] } | d ^ q‰ ƒ | | <x8 | D]0 }	 | |	 d k r­ | j	 |	 d | f ƒ q­ q­ Wqg Wy t
 t j | | ƒ ƒ }
 Wnt t j k
 rw} xC | j D]8 ‰  | j ˆ  ƒ | j ‡  f d †  | ˆ  d Dƒ ƒ q Wt
 t j | | ƒ ƒ }
 n Xg  |
 D] } | | | j | ƒ f ^ qd t
 | ƒ f g S(   sx  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:`.Inspector.get_table_names`

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

        R/   R
   t   nameR1   c         3   s   |  ] } ˆ  d  | f Vq d S(   i   N(    (   R   t   fkc(   t   edge(    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pys	   <genexpr>  s    i   N(   R#   R&   R/   R"   R
   R!   R2   t   setR3   t   addR5   R	   R6   R   t   CircularDependencyErrort   edgest   removet   updatet
   differenceR   (   R   R   R7   R8   t   remaining_fkcst   fknames_for_tableR9   t   fkeyst   fkR:   t   candidate_sortt   err(    (   R=   s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyt   get_sorted_table_and_fkc_namesØ   s0    			'"#&c         C   s   |  j  j |  j d |  j ƒS(   sÊ   return 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

        R
   (   R&   t   get_temp_table_namesR"   R
   (   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRL     s    		c         C   s   |  j  j |  j d |  j ƒS(   sÉ   return 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

        R
   (   R&   t   get_temp_view_namesR"   R
   (   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRM     s    		c         K   s;   t  |  j d ƒ r7 |  j j |  j | | d |  j | Si  S(   sÑ  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`.

        t   get_table_optionsR
   (   R#   R&   RN   R"   R
   (   R   t
   table_nameR   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRN   *  s    	c         C   s   |  j  j |  j | d |  j ƒS(   s±   Return all view names in `schema`.

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

        R
   (   R&   t   get_view_namesR"   R
   (   R   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRP   >  s    	c         C   s"   |  j  j |  j | | d |  j ƒS(   s±   Return definition for `view_name`.

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

        R
   (   R&   t   get_view_definitionR"   R
   (   R   t	   view_nameR   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRQ   J  s    	c         K   se   |  j  j |  j | | d |  j | } x7 | D]/ } | d } t | t ƒ s. | ƒ  | d <q. q. W| S(   sä  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.

        * ``attrs``  - dict containing optional column attributes

        :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
   t   type(   R&   t   get_columnsR"   R
   R   R   (   R   RO   R   R   t   col_defst   col_deft   coltype(    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRT   V  s    	
s   0.7s§   The :meth:`.Inspector.get_primary_keys` method is deprecated and will be removed in a future release.  Please refer to the :meth:`.Inspector.get_pk_constraint` method.c         K   s)   |  j  j |  j | | d |  j | d S(   sÈ   Return information about primary keys in `table_name`.

        Given a string `table_name`, and an optional string `schema`, return
        primary key information as a list of column names.
        R
   t   constrained_columns(   R&   t   get_pk_constraintR"   R
   (   R   RO   R   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyt   get_primary_keys~  s    	c         K   s%   |  j  j |  j | | d |  j | S(   s˜  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
   (   R&   RY   R"   R
   (   R   RO   R   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRY     s    	c         K   s%   |  j  j |  j | | d |  j | S(   s—  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
   (   R&   R3   R"   R
   (   R   RO   R   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR3   §  s    	c         K   s%   |  j  j |  j | | d |  j | S(   sÝ  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``, ``nullsfirst``, ``nullslast``.

          .. 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
   (   R&   t   get_indexesR"   R
   (   R   RO   R   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR[   Ê  s    $	c         K   s%   |  j  j |  j | | d |  j | S(   so  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
   (   R&   t   get_unique_constraintsR"   R
   (   R   RO   R   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR\   ò  s    	c         K   s%   |  j  j |  j | | d |  j | S(   sˆ  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
   (   R&   t   get_table_commentR"   R
   (   R   RO   R   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR]     s    	c         K   s%   |  j  j |  j | | d |  j | S(   sK  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
   (   R&   t   get_check_constraintsR"   R
   (   R   RO   R   R   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR^     s    	c      	      s  | d k	 r, ˆ  | k r d S| j ˆ  ƒ n  |  j j } |  j j ˆ  ƒ } ˆ  j } t ‡  f d †  | j Dƒ ƒ }	 |  j | | ˆ  j	  }
 |
 r  ˆ  j
 |
 ƒ n  t j rô t | t ƒ rÍ | j | j ƒ } n  t | t ƒ rô | j | j ƒ } qô n  t } i  } x? |  j | | ˆ  j	  D]% } t } |  j ˆ  | | | | ƒ qW| s]t j ˆ  j ƒ ‚ n  |  j | | ˆ  | | ƒ |  j | | ˆ  | | | | |	 ƒ |  j | | ˆ  | | | |	 ƒ |  j | | ˆ  | | | |	 ƒ |  j | | ˆ  | | | |	 ƒ |  j | | ˆ  |	 ƒ d S(   s  Given a 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.engine.reflection import Inspector

            engine = create_engine('...')
            meta = MetaData()
            user_table = Table('user', meta)
            insp = Inspector.from_engine(engine)
            insp.reflecttable(user_table, None)

        :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   s6   |  ], } | ˆ  j  k r | ˆ  j  j | ƒ f Vq d  S(   N(   t   dialect_kwargsR   (   R   R   (   t   table(    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pys	   <genexpr>n  s   (   R   R?   R"   R&   t   schema_for_objectR;   t   dictt   reflection_optionsRN   R_   t   _validate_dialect_kwargsR   t   py2kR   t   strt   decodet   encodingt   FalseRT   t   Truet   _reflect_columnR   t   NoSuchTableErrort   _reflect_pkt   _reflect_fkt   _reflect_indexest   _reflect_unique_constraintst   _reflect_check_constraintst   _reflect_table_comment(   R   R`   t   include_columnst   exclude_columnst   resolve_fkst
   _extend_onR&   R   RO   Rc   t   tbl_optst   found_tablet   cols_by_orig_namet   col_d(    (   R`   s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyt   reflecttable@  sŠ    			c            s±  ˆ  d } | j  j |  | ˆ  ƒ ˆ  d } | r< | | k sN | rR | | k rR d  Sˆ  d } t ‡  f d †  d d d d d d	 g Dƒ ƒ }	 d
 ˆ  k rª |	 j ˆ  d
 ƒ n  g  }
 ˆ  j d ƒ d  k	 rCˆ  d } t | t j j	 ƒ rü t
 j | d t ƒ} n7 t | t
 j ƒ s3t
 j t j ˆ  d ƒ d t ƒ} n  |
 j | ƒ n  d ˆ  k rb|  j ˆ  |
 ƒ n  t
 j | | |
 |	 Ž | | <} | j | j k r t | _ n  | j | ƒ d  S(   NR;   RS   c         3   s+   |  ]! } | ˆ  k r | ˆ  | f Vq d  S(   N(    (   R   R   (   Rz   (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pys	   <genexpr>Ù  s   t   nullablet   autoincrementt   quotet   infoR   t   commentt   dialect_optionst   defaultt
   _reflectedt   sequence(   t   dispatcht   column_reflectRb   RC   R   R   R   R   t   elementst
   TextClauset	   sa_schemat   DefaultClauseRj   t   FetchedValuet   textR4   t   _reflect_col_sequencet   ColumnR   t   primary_keyt   append_column(   R   R`   Rz   Rs   Rt   Ry   t	   orig_nameR;   RW   t   col_kwt   colargsR‚   t   col(    (   Rz   s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRk   Æ  sB    



c         C   s{   d | k rw | d } t  j | d d d ƒ } d | k rK | d | _ n  d | k rg | d | _ n  | j | ƒ n  d  S(   NR„   R;   i   t   startt	   increment(   R‰   t   SequenceR•   R–   R4   (   R   Rz   R“   t   seqR„   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR   ÿ  s    
c   	      C   sƒ   |  j  | | | j  } | r g  | d D]( } | | k r) | | k r) | | ^ q) } | j d ƒ | j _ | j j | ƒ n  d  S(   NRX   R;   (   RY   R_   R   R   R;   t   _reload(	   R   RO   R   R`   Ry   Rt   t   pk_const   pkt   pk_cols(    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRm   
  s    (c	         C   sÙ  |  j  | | | j  }	 xº|	 D]²}
 |
 d } g  |
 d D]% } | | k rY | | j n | ^ q: } | r† t | ƒ j | ƒ r† q n  |
 d } |
 d } |
 d } g  } | d  k	 r#| rð t j | | j d t	 d | d |  j
 d	 | | n  xš | D]% } | j d
 j | | | g ƒ ƒ q÷ Wnj | r`t j | | j d t	 d |  j
 d t j d	 | | n  x* | D]" } | j d
 j | | g ƒ ƒ qgWd |
 k r¦|
 d } n i  } | j t j | | | d t	 | ƒ q Wd  S(   NR;   RX   t   referred_schemaR1   t   referred_columnst   autoloadR   t   autoload_withRv   t   .t   optionst   link_to_name(   R3   R_   R   R>   t   intersectionR   R‰   t   Tablet   metadataRj   R"   R4   t   joint   BLANK_SCHEMAt   append_constraintt   ForeignKeyConstraint(   R   RO   R   R`   Ry   Rt   Ru   Rv   Rc   RG   t   fkey_dt   connamet   cRX   R   R1   Rž   t   refspect   columnR¢   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRn     s^    
3	


		
 			
 t   asct   desct
   nullsfirstt	   nullslastc      
   C   sÓ  |  j  | | ƒ } xº| D]²}	 |	 d }
 |	 d } |	 j d i  ƒ } |	 d } |	 j d d ƒ } |	 j d i  ƒ } |	 j d ƒ } | rÄ t | ƒ j | ƒ rÄ t j d	 | d
 j | ƒ f ƒ q n  | rÐ q n  g  } xº | D]² } y' | | k rü | | n
 | j | } Wn. t k
 r:t j d | | | f ƒ qÝ n X| j | d ƒ } x2 |  j	 D]' \ } } | | k rW| | ƒ } qWqWW| j
 | ƒ qÝ Wt j |
 d | | t t | j ƒ  ƒ d | f g ƒ Žq Wd  S(   NR;   t   column_namest   column_sortingt   uniqueRS   t   indexR   t   duplicates_constraints5   Omitting %s key for (%s), key covers omitted columns.s   , s5   %s key '%s' was not located in columns for table '%s't   _table(    (   R[   R   R>   t   issubsetR   t   warnR§   R­   t   KeyErrort   _index_sort_exprsR4   R‰   t   IndexRb   R5   R   (   R   RO   R   R`   Ry   Rs   Rt   Rc   t   indexest   index_dR;   t   columnsRµ   R¶   t   flavorR   t
   duplicatest   idx_colsR­   t   idx_colt	   c_sortingR   t   op(    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRo   m  sF    


c         C   s=  y |  j  | | ƒ } Wn t k
 r* d  SXx| D]}	 |	 d }
 |	 d } |	 j d ƒ } | r— t | ƒ j | ƒ r— t j d d j | ƒ ƒ q2 n  | r£ q2 n  g  } xm | D]e } y' | | k rÏ | | n
 | j | } Wn( t	 k
 rt j d | | f ƒ q° X| j
 | ƒ q° W| j t j d |
 | Œ ƒ q2 Wd  S(   NR;   R´   t   duplicates_indexsD   Omitting unique constraint key for (%s), key covers omitted columns.s   , sD   unique constraint key '%s' was not located in columns for table '%s'(   R\   t   NotImplementedErrorR   R>   Rº   R   R»   R§   R­   R¼   R4   R©   R‰   t   UniqueConstraint(   R   RO   R   R`   Ry   Rs   Rt   Rc   t   constraintst   const_dR¬   RÁ   RÃ   t   constrained_colsR­   t   constrained_col(    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRp   §  s6    

c   
      C   sV   y |  j  | | ƒ } Wn t k
 r* d  SXx$ | D] }	 | j t j |	   ƒ q2 Wd  S(   N(   R^   RÉ   R©   R‰   t   CheckConstraint(
   R   RO   R   R`   Ry   Rs   Rt   Rc   RË   RÌ   (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRq   Ú  s    
c         C   sD   y |  j  | | ƒ } Wn t k
 r* d  SX| j d d  ƒ | _ d  S(   NRŒ   (   R]   RÉ   R   R   R€   (   R   RO   R   R`   Rc   t   comment_dict(    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyRr   í  s
    (   s   1.0sþ   The :paramref:`get_table_names.order_by` parameter is deprecated and will be removed in a future release.  Please refer to :meth:`.Inspector.get_sorted_table_and_fkc_names` for a more comprehensive solution to resolving foreign key cycles between tables.N(    (0   R   t
   __module__t   __doc__R'   t   classmethodR*   R   t	   _inspectsR    R+   t   propertyR,   R-   R   t   deprecated_paramsR   R/   RK   RL   RM   RN   RP   RQ   RT   R   RZ   RY   R3   R[   R\   R]   R^   Rj   R{   Rk   R   Rm   Rn   R   t   asc_opt   desc_opt   nullsfirst_opt   nullslast_opR½   Ro   Rp   Rq   Rr   (    (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyR    =   sT   		
	 *8		(#(%€	9			I	:	3	N(   RÒ   t   baseR    t    R   R   R   R   R   R   R‰   t   sql.type_apiR   R   R	   t	   decoratorR   t   objectR    (    (    (    s;   lib/python2.7/site-packages/sqlalchemy/engine/reflection.pyt   <module>   s   