bgddlmZddlZddlmZddlmZddlmZddlmZddlmZddl m Z dd l m Z dd l m Z dd l m Z dd lmZd dlmZd dlmZd dlmZd dlmZddlmZer6ddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$ddl%m&Z&GddeZ'eedd'd&Z(dS)() annotationsN)Any)Dict)Optional) TYPE_CHECKING)Union)cast)JSON)schema)sql)compiles) alter_table)format_table_name) RenameTable) DefaultImpl)util) Inspector) DDLCompiler)Cast) ClauseElement)Column) Constraint)Table) TypeEngine)BatchOperationsImplcleZdZdZdZ d(dZd)d Zd)d Zd*dZd+dZ d,dZ d-d.fd Z d/d&Z d'Z xZS)0 SQLiteImplsqliteFbatch_oprreturnboolc\|jD]}|ddkr|dd}t|jtjr't|jjt jrdSt|jtj j r|jj rdS|ddvrdSdS)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_columnrT) create_index drop_indexF) batch isinstanceserver_defaultr DefaultClauseargr rr sqla_compatComputed persisted)selfr!opcols I/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/ddl/sqlite.pyrequires_recreate_in_batchz%SQLiteImpl.requires_recreate_in_batch+s.  B!u $$eAh&(<  !3!79JKK  44s143C3LMM *4  44A<<<tt=5constrc|jtd||rtjddSdS)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_ruleNotImplementedErrorrwarnr0r6s r3add_constraintzSQLiteImpl.add_constraintGsk   %%D     % %  ID       r5c2|jtddS)Nr8)r9r:r<s r3drop_constraintzSQLiteImpl.drop_constraintXs+   %%D  & %r5inspector_column Column[Any]metadata_columnrendered_metadata_default Optional[str]rendered_inspector_defaultc|,tjdd|}tjdd|}|,tjdd|}tjdd|}||kS)Nz ^\((.+)\)$z\1z^\"?'(.+)'\"?$)resub)r0r@rBrCrEs r3compare_server_defaultz!SQLiteImpl.compare_server_default`s % 0(*u&?)) %)+!5*C)) % & 1)+u&@** &*,!5*D** &*-FFFr5exprc|sdStjd|rdStjd|rdStjd|rdSdS)aDetermine 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)rGmatch)r0rJs r3-_guess_if_default_is_unparenthesized_sql_exprz8SQLiteImpl._guess_if_default_is_unparenthesized_sql_expr|sa 5 XlD ) ) 5 Xi & & 5 Xk4 ( ( 54r5 inspectorrtabler column_infoDict[str, Any]Nonecz||ddrd|dd|d<dSdS)Ndefault())rMget)r0rNrOrPs r3autogen_column_reflectz!SQLiteImpl.autogen_column_reflects`  = = OOIt , ,   H H0;9/E/E/E%GK " " " H Hr5ris_server_defaultstrc ztj|fd|i|}|r||rd|d}|S)NrYrUrV)superrender_ddl_sql_exprrM)r0rJrYkwstr_expr __class__s r3r]zSQLiteImpl.render_ddl_sql_exprsm /577.   $5 9;    ,BB8LL , ,"*+Hr5existingexisting_transfer"Dict[str, Union[TypeEngine, Cast]]new_typerc|jj|jur0t|tst |d||d<dSdSdS)NrJ)type_type_affinityr)r r )r0rarbrds r3cast_for_batch_migratez!SQLiteImpl.cast_for_batch_migratesi M (* + +x.. +)-!&)8)) f % % %  + + + +r5c2|||dS)N)_skip_functional_indexes)r0conn_unique_constraints conn_indexesmetadata_unique_constraintsmetadata_indexess r3correct_for_autogen_constraintsz*SQLiteImpl.correct_for_autogen_constraintss! %%&6 EEEEEr5)r!rr"r#)r6r) r@rArBrArCrDrErDr"r#)rJrDr"r#)rNrrOrrPrQr"rR)F)rJrrYr#r"rZ)rarArbrcrdrr"rR)__name__ __module__ __qualname__ __dialect__transactional_ddlr4r=r?rIrMrXr]rhro __classcell__)r`s@r3rr#sK8"GGGG8* H H H H>C    FFFFFFFr5rr elementrcompilerrr"rZc jt||j|jdt||jdS)Nz RENAME TO )r table_namer rnew_table_name)rvrwr^s r3visit_rename_tabler{s= Hg0'.AAAA(G$:DAAA r5)rvrrwrr"rZ)) __future__rrGtypingrrrrr sqlalchemyr r r r sqlalchemy.ext.compilerr baserrrimplrrsqlalchemy.engine.reflectionrsqlalchemy.sql.compilerrsqlalchemy.sql.elementsrrsqlalchemy.sql.schemarrrsqlalchemy.sql.type_apiroperations.batchrrr{r5r3rsJ""""""  ,,,,,,###### 7666666333333,,,,,,555555,,,,,,000000++++++222222666666bFbFbFbFbFbFbFbFJ +x  ! r5