
    ]j                    F    d dl mZ d dlZddlmZmZmZmZ  G d de      Zy)    )annotationsN   )BaseAnalyserCheck	CheckMode	CheckTypec            	          e Zd ZU  edd dej
                  ej                         edd dej                  ej                         edd	 d
ej                  ej                        gZ	de
d<   edd       Zy)SqliteAnalyserRENAME_TABLEc                F    t        j                  d|       xr
 d| vxr d| vS )NALTER TABLE .* RENAME TO__oldnew__research)sqlkws     U/root/env/lib/python3.12/site-packages/django_migration_linter/sql_analyser/sqlite.py<lambda>zSqliteAnalyser.<lambda>   s/    +Es!K "#s""#s"     zRENAMING tables)codefnmessagemodetype
DROP_TABLEc                P    t        d | D              xr t        d | D               S )Nc              3  >   K   | ]  }|j                  d         yw)z
DROP TABLEN
startswith.0r   s     r   	<genexpr>z*SqliteAnalyser.<lambda>.<locals>.<genexpr>   s      014|,0   c              3  >   K   | ]  }|j                  d         yw)zCREATE TABLENr    r"   s     r   r$   z*SqliteAnalyser.<lambda>.<locals>.<genexpr>   s     Q3~6Qr%   anysql_statementsr   s     r   r   zSqliteAnalyser.<lambda>   s4    C 08F0 - -R Q.QQQ r   zDROPPING tableNOT_NULLc                N    t        d | D              xr t        d | D              S )Nc              3  H   K   | ]  }t        j                  d |        yw)z NOT NULL(?! PRIMARY)(?! DEFAULT)Nr   r"   s     r   r$   z*SqliteAnalyser.<lambda>.<locals>.<genexpr>    s$      0 		<cB0s    "c              3  `   K   | ]&  }t        j                  d |      xr
 d|v xs d|v  ( yw)r   r   r   Nr   r"   s     r   r$   z*SqliteAnalyser.<lambda>.<locals>.<genexpr>$   s@        		4c: 7^5w#~7s   ,.r'   r)   s     r   r   zSqliteAnalyser.<lambda>    s9    C 0)0 - -   * 	 r   zNOT NULL constraint on columnszlist[Check]migration_checksc                   t        | t              rpt        j                  d| t        j                        }|r|j                  d      S t        j                  d| t        j                        }|r|j                  d      S y )NzTABLE [`"'](.*?)[`"']r   zON [`"'](.*?)[`"'])
isinstancestrr   r   
IGNORECASEgroup)r   regex_results     r   detect_tablezSqliteAnalyser.detect_table/   se    c399%>R]]SL#))!,,99%;S"--PL#))!,,r   N)r   zlist[str] | strreturnz
str | None)__name__
__module____qualname__r   r   	ONE_LINERr   ERRORTRANSACTIONr/   __annotations__staticmethodr6    r   r   r
   r
      s    # &$$	
 	R %&&
	
 	 5&&	
+$%k $L  r   r
   )	
__future__r   r   baser   r   r   r   r
   r@   r   r   <module>rC      s    " 	 ; ;0\ 0r   