ó
®â0_c           @   sJ   d  d l  m Z d  d l m Z d  d l m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   checks(   t   BaseDatabaseValidation(   t   get_docs_versiont   DatabaseValidationc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         K   s2   t  t |  ƒ j |   } | j |  j |   ƒ | S(   N(   t   superR   t   checkt   extendt   _check_sql_mode(   t   selft   kwargst   issues(    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/db/backends/mysql/validation.pyR      s    c         K   sš   |  j  j ƒ    } | j d ƒ | j ƒ  } Wd  QXt | rM | d j d ƒ n d ƒ } | d d h @s– t j d |  j  j d d t	 ƒ  f d	 d
 ƒg Sg  S(   Ns   SELECT @@sql_modei    t   ,t   STRICT_TRANS_TABLESt   STRICT_ALL_TABLESs9   MySQL Strict Mode is not set for database connection '%s't   hints   MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/%s/ref/databases/#mysql-sql-modet   ids
   mysql.W002(    (
   t
   connectiont   cursort   executet   fetchonet   sett   splitR    t   Warningt   aliasR   (   R   R	   R   t   sql_modet   modes(    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/db/backends/mysql/validation.pyR      s    %
c            sç   t  t ˆ  ƒ j | |  } t | d d	 ƒ r1 | St ‡  f d †  | j j j Dƒ ƒ } | s` | S| j	 ˆ  j
 ƒ } | d	 k r‚ | S| j d ƒ rã | j rã | j d	 k s¾ t | j ƒ d k rã | j t j d d | d d ƒƒ n  | S(
   sÁ   
        MySQL has the following field length restriction:
        No character (varchar) fields can have a length exceeding 255
        characters if they have a unique index on them.
        t   remote_fieldc         3   s'   |  ] } t  ˆ  j j | t ƒ Vq d  S(   N(   t   getattrR   t   featurest   False(   t   .0t   feature(   R   (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/db/backends/mysql/validation.pys	   <genexpr>+   s   t   varchariÿ   sB   MySQL does not allow unique CharFields to have a max_length > 255.t   objR   s
   mysql.E001N(   R   R   t   check_fieldR   t   Nonet   allt   modelt   _metat   required_db_featurest   db_typeR   t
   startswitht   uniquet
   max_lengtht   intt   appendR    t   Error(   R   t   fieldR	   t   errorst!   db_supports_all_required_featurest
   field_type(    (   R   sE   /tmp/pip-unpacked-wheel-BAJOf3/django/db/backends/mysql/validation.pyR"      s&    $(   t   __name__t
   __module__R   R   R"   (    (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/db/backends/mysql/validation.pyR      s   		N(   t   django.coreR    t"   django.db.backends.base.validationR   t   django.utils.versionR   R   (    (    (    sE   /tmp/pip-unpacked-wheel-BAJOf3/django/db/backends/mysql/validation.pyt   <module>   s   