
    Ii                       S SK Jr  S SKrS SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SK	J
r
  S S	K	Jr  S S
K	Jr  S SK	Jr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  \(       a6  S SKJr  S SKJr  S SKJr  S SKJr  S SKJ r   S SKJ!r!  S SKJ"r"  S SK#J$r$  SSK%J&r&   " S S\5      r'\" \S5            S!S  j5       r(g)"    )annotationsN)Any)Dict)Optional)TYPE_CHECKING)Union)cast)JSON)schema)sql   )alter_table)format_table_name)RenameTable)DefaultImpl   )util)compiles)	Inspector)DDLCompiler)Cast)ClauseElement)Column)
Constraint)Table)
TypeEngine)BatchOperationsImplc                     ^  \ rS rSrSrSr     SS jrSS jrSS jr          SS jr	    SS jr
        SS	 jr S     SU 4S
 jjjr        SS jrS rSrU =r$ )
SQLiteImpl&   sqliteFc                   UR                    H  nUS   S:X  a  US   S   n[        UR                  [        R                  5      (       a5  [        UR                  R
                  [        R                  5      (       a    g[        UR                  [        R                  R                  5      (       a  UR                  R                  (       a    gM  M  US   S;  d  M    g   g)zReturn True if the given :class:`.BatchOperationsImpl`
would need the table to be recreated and copied in order to
proceed.

Normally, only returns True on SQLite when operations other
than add_column are present.

r   
add_columnr   T)create_index
drop_indexF)batch
isinstanceserver_defaultr   DefaultClauseargr   r   r   sqla_compatComputed	persisted)selfbatch_opopcols       8/venv/lib/python3.13/site-packages/alembic/ddl/sqlite.pyrequires_recreate_in_batch%SQLiteImpl.requires_recreate_in_batch.   s     ..B!u$eAh&&(<(<  !3!3!7!79J9JKKs1143C3C3L3LMM**44 5 N A<< !     c                    UR                   c  [        S5      eUR                  U 5      (       a  [        R                  " S5        g g )NNo support for ALTER of constraints in SQLite dialect. Please refer to the batch mode feature which allows for SQLite migrations using a copy-and-move strategy.zSkipping unsupported ALTER for creation of implicit constraint. Please refer to the batch mode feature which allows for SQLite migrations using a copy-and-move strategy.)_create_ruleNotImplementedErrorr   warnr.   consts     r2   add_constraintSQLiteImpl.add_constraintJ   sM     %%D 
 %%IID &r5   c                4    UR                   c  [        S5      eg )Nr7   )r8   r9   r;   s     r2   drop_constraintSQLiteImpl.drop_constraint[   s&    %%D  &r5   c                    Ub0  [         R                  " SSU5      n[         R                  " SSU5      nUb0  [         R                  " SSU5      n[         R                  " SSU5      nXC:g  $ )Nz
^\((.+)\)$z\1z^\"?'(.+)'\"?$)resub)r.   inspector_columnmetadata_columnrendered_metadata_defaultrendered_inspector_defaults        r2   compare_server_default!SQLiteImpl.compare_server_defaultc   s}     %0(*u&?)% )+!5*C)% &1)+u&@*& *,!5*D*& *FFr5   c                    U(       d  g[         R                  " SU5      (       a  g[         R                  " SU5      (       a  g[         R                  " SU5      (       a  gg)zDetermine if a server default is a SQL expression or a constant.

There are too many assertions that expect server defaults to round-trip
identically without parenthesis added so we will add parens only in
very specific cases.

Fz	^[0-9\.]$z^'.+'$z^\(.+\)$T)rC   match)r.   exprs     r2   -_guess_if_default_is_unparenthesized_sql_expr8SQLiteImpl._guess_if_default_is_unparenthesized_sql_expr~   sI     XXlD))XXi&&XXk4((r5   c                l    U R                  UR                  SS 5      5      (       a  SUS   < S3US'   g g )Ndefault())rN   get)r.   	inspectortablecolumn_infos       r2   autogen_column_reflect!SQLiteImpl.autogen_column_reflect   s>     ==OOIt,
 
 0;9/E%GK	"
r5   c                v   > [         TU ]  " U4SU0UD6nU(       a  U R                  U5      (       a  SU< S3nU$ )Nis_server_defaultrR   rS   )superrender_ddl_sql_exprrN   )r.   rM   r[   kwstr_expr	__class__s        r2   r]   SQLiteImpl.render_ddl_sql_expr   sJ    
 7.
$5
9;

 BB8LL!)+Hr5   c                    UR                   R                  UR                  La)  [        U[        5      (       d  [	        US   U5      US'   g g g )NrM   )type_type_affinityr'   r
   r	   )r.   existingexisting_transfernew_types       r2   cast_for_batch_migrate!SQLiteImpl.cast_for_batch_migrate   sN     MM((0G0GGx..(,!&)8)f% / Hr5   c                &    U R                  XB5        g )N)_skip_functional_indexes)r.   conn_unique_constraintsconn_indexesmetadata_unique_constraintsmetadata_indexess        r2   correct_for_autogen_constraints*SQLiteImpl.correct_for_autogen_constraints   s     	%%&6Er5    )r/   r   returnbool)r<   r   )
rE   Column[Any]rF   ru   rG   Optional[str]rH   rv   rs   rt   )rM   rv   rs   rt   )rU   r   rV   r   rW   zDict[str, Any]rs   None)F)rM   r   r[   rt   rs   str)re   ru   rf   z"Dict[str, Union[TypeEngine, Cast]]rg   r   rs   rw   )__name__
__module____qualname____firstlineno____dialect__transactional_ddlr3   r=   r@   rI   rN   rX   r]   rh   rp   __static_attributes____classcell__)r`   s   @r2   r   r   &   s   K+	8"G%G %G $1	G
 %2G 
G6!	*HH H $	H
 
H >C!6:	   > 	
 
F Fr5   r   r!   c                x    [        XR                  U R                  5      < S[        XR                  S 5      < 3$ )Nz RENAME TO )r   
table_namer   r   new_table_name)elementcompilerr^   s      r2   visit_rename_tabler      s2    
 	H00'..A($:$:DA r5   )r   r   r   r   rs   rx   ))
__future__r   rC   typingr   r   r   r   r   
sqlalchemyr	   r
   r   r   baser   r   r   implr    r   util.sqla_compatr   sqlalchemy.engine.reflectionr   sqlalchemy.sql.compilerr   sqlalchemy.sql.elementsr   r   sqlalchemy.sql.schemar   r   r   sqlalchemy.sql.type_apir   operations.batchr   r   r   rr   r5   r2   <module>r      s    # 	            #    '63,5,0+26_F _FD 
+x $/ !r5   