Repository URL to install this package:
| 
      
        
        
        Version: 
        
         
          
          4.2.64  ▾
        
         | 
ó
U
bc           @   sË   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 e  Z d
   Z d d d  Z d S(
   iÿÿÿÿ(   t	   exception(   t   utils(   t   log(   t   OperationalError(   t   MetaData(   t   Table(   t   NullType(   t   api(   t   _c   
      C   s  t    } |  | _ t | | d t } t t j | | d t } d   | j D } d   | j D } x¿ t | j    D]« \ } } | | k rÁ t	 j
 t d  i | d 6| j d 6  n  | | }	 t
 |	 j t | j   s| t	 j
 t d  i | d 6| j d 6| j d 6|	 j d	 6  q| q| WxY t | j    D]E \ } } | | k r>t	 j
 t d
  i | d 6| j d 6  q>q>Wt S(   sl   This method checks that table with ``table_name`` and
    corresponding shadow table have same columns.
    t   autoloadc         S   s   i  |  ] } | | j   q S(    (   t   name(   t   .0t   c(    (    s=   /usr/lib/python2.7/dist-packages/dmapi/db/sqlalchemy/utils.pys
   <dictcomp>   s   	 c         S   s   i  |  ] } | | j   q S(    (   R
   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/dmapi/db/sqlalchemy/utils.pys
   <dictcomp>    s   	 s3   Missing column %(table)s.%(column)s in shadow tablet   columnt   tablesV   Different types in %(table)s.%(column)s and shadow table: %(c_type)s %(shadow_c_type)st   c_typet
   shadow_c_types1   Extra column %(table)s.%(column)s in shadow table(   R   t   bindR   t   Truet   dbt   _SHADOW_TABLE_PREFIXt   columnst   listt   itemsR    t   ContegoExceptionR   R
   t
   isinstancet   type(
   t   migrate_enginet
   table_namet   metaR   t   shadow_tableR   t   shadow_columnsR
   R
   t
   shadow_column(    (    s=   /usr/lib/python2.7/dist-packages/dmapi/db/sqlalchemy/utils.pyt   check_shadow_table   s2    				
	
	"c   
      K   s´  t  d |   } | d	 k r? | d	 k r? t j t d    n  | d	 k pT | d	 k so t j t d    n  | d	 k r t | | d t } n  g  } x[ | j D]P } t | j	 t
  rà t j | | j
  } | j |  q£ | j | j    q£ Wt j | j
 } t | | d d | }	 y |	 j   |	 SWn| t j t f k
 rt j t |	   t j d  t j d |   n1 t k
 r¯t j t |	   t j d  n Xd	 S(
   s  This method create shadow table for table with name ``table_name``
    or table instance ``table``.
    :param table_name: Autoload table with this name and create shadow table
    :param table: Autoloaded table, so just create corresponding shadow table.
    :param col_name_col_instance:   contains pair column_name=column_instance.
    column_instance is instance of Column. These params are required only for
    columns that have unsupported types by sqlite. For example BigInteger.
    :returns: The created shadow_table object.
    R   s%   Specify `table_name` or `table` params+   Specify only one param `table_name` `table`R	   t   mysql_enginet   InnoDBs   Exception while creating table.R
   N(   R   t   NoneR    R   R   R   R   R   R   R   R   t   oslodbutilst   _get_not_supported_columnR
   t   appendt   copyR   R   t   createt   db_exct   DBErrorR   t   LOGt   infot   reprt   ShadowTableExistst	   Exception(
   R   R   R   t   col_name_col_instanceR   R   R
   t
   new_columnt   shadow_table_nameR   (    (    s=   /usr/lib/python2.7/dist-packages/dmapi/db/sqlalchemy/utils.pyt   create_shadow_table9   s6    
N(   t   oslo_dbR    R*   t   oslo_db.sqlalchemyR   R%   t   oslo_logR   t   loggingt   sqlalchemy.excR   t
   sqlalchemyR   R   t   sqlalchemy.typesR   t   dmapi.db.sqlalchemyR   R   t   dmapit
   dmapi.i18nR   t	   getLoggert   __name__R,   R!   R$   R4   (    (    (    s=   /usr/lib/python2.7/dist-packages/dmapi/db/sqlalchemy/utils.pyt   <module>   s   	%