AlkantarClanX12

Your IP : 3.16.70.99


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/ddl/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/ddl/__pycache__/mssql.cpython-311.pyc

�

�܋fN5���ddlmZddlZddlmZddlmZddlmZddlmZddlmZddl	m
Zdd	lm
Z
dd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#ddl$m%Z%ddl%m&Z&er6ddlm'Z'dd l(m)Z)dd!l(m*Z*dd"l+m,Z,dd#l-m.Z.dd$l-m/Z/dd%l0m1Z1dd&l2m3Z3dd'lm4Z4Gd(�d)e#��Z5Gd*�d+ee��Z6Gd,�d-ee��Z7e
e6d.��dFd4���Z8e
e7d.��dGd5���Z9e
ed.��dHd8���Z:dId;�Z;e
ed.��dJd=���Z<e
ed.��dKd?���Z=e
ed.��dLdA���Z>e
ed.��dMdC���Z?e
e!d.��dNdE���Z@dS)O�)�annotationsN)�Any)�List)�Optional)�
TYPE_CHECKING)�Union)�types)�compiles)�Column)�CreateIndex)�
Executable)�
ClauseElement�)�	AddColumn)�alter_column)�alter_table)�
ColumnDefault)�
ColumnName)�ColumnNullable)�
ColumnType)�format_column_name)�format_server_default)�format_table_name)�format_type)�RenameTable)�DefaultImpl�)�util)�sqla_compat)�Literal)�
MSDDLCompiler)�
MSSQLCompiler)�CursorResult)�Index)�Table)�TableClause)�
TypeEngine)�_ServerDefaultc���eZdZdZdZdZejddhfzZdZd1�fd	�Z	d2�fd
�Z
d1d�Zd1�fd�Z								d3d4�fd#�
Z
d5d&�Zd6�fd+�Z	d7d8�fd.�
Zd/�Z�fd0�Z�xZS)9�	MSSQLImpl�mssqlT�GO�VARCHAR�NVARCHAR)	�minvalue�maxvalue�
nominvalue�
nomaxvalue�cycle�cache�order�on_nullr5�return�Nonec���t��j|i|��|j�d|j��|_dS)N�mssql_batch_separator)�super�__init__�context_opts�get�batch_separator)�self�arg�kw�	__class__s   ��H/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/ddl/mssql.pyr<zMSSQLImpl.__init__AsH��������#�$��$�$�$�#�0�4�4�#�T�%9� 
� 
������	constructr�Optional[CursorResult]c���t��j|g|�Ri|��}|jr!|jr|�|j��|S�N)r;�_exec�as_sqlr?�
static_output)r@rF�argsrB�resultrCs     �rDrJzMSSQLImpl._execGsX��������y�6�4�6�6�6�2�6�6���;�	5�4�/�	5����t�3�4�4�4��
rEc�@�|�d|jz��dS)NzBEGIN TRANSACTION)rL�command_terminator)r@s rD�
emit_beginzMSSQLImpl.emit_beginMs%�����.��1H�H�I�I�I�I�IrEc���t�����|jr#|jr|�|j��dSdSdSrI)r;�emit_commitrKr?rL)r@rCs �rDrSzMSSQLImpl.emit_commitPs^���
���������;�	5�4�/�	5����t�3�4�4�4�4�4�	5�	5�	5�	5rENF�
table_name�str�column_name�nullable�Optional[bool]�server_default�/Optional[Union[_ServerDefault, Literal[False]]]�name�
Optional[str]�type_�Optional[TypeEngine]�schema�
existing_type�existing_server_default�Optional[_ServerDefault]�existing_nullablerBc	�B��|�|�|}d}n8|�tjd���n!|
�	|�|
}|}d}n|�tjd��d}tj||	��stj||	��rd}||d<|	|d<t
��j||f|||||
d�|��|durV|durR|	dus|�%|�t||d|����|�%t
���||||�	��|�'t
���||||�
��dSdS)NzhMS-SQL ALTER COLUMN operations with NULL or NOT NULL require the existing_type or a new type_ be passed.z�MS-SQL ALTER COLUMN operations that specify type_= should also specify a nullable= or existing_nullable= argument to avoid implicit conversion of NOT NULL columns to NULL.FTrYra)rWr]r_r`rc�sys.default_constraints)r_rY)r_r[)
r�CommandError�warnr�_server_default_is_identity�_server_default_is_computedr;rrJ�_ExecDropConstraint)r@rTrVrWrYr[r]r_r`rarcrB�used_defaultrCs             �rDrzMSSQLImpl.alter_columnUs����"��� �!&�
�����&��'�>����'��
*�u�/@�(�H�"�M��E�E�
�
��I�/�
�
�
����2��3�
�
�	D�
�
4��3�
�
�	D�
 �L�#1�B�� �,C�B�(�)��������		
����'�/�		
�		
��		
�		
�		
���&�&�<�5�+@�+@�&�e�3�3�~�7M��
�
�'�"�#�1��	������)����$�$���!�#1�	%�������G�G� � ��K��T�
!�
�
�
�
�
��rE�indexr$c� �|j�dd��pd}|j�J�|D]B}||jjvr2|j�t|tj�����C|�t|����dS)N�
mssql_include�)
�kwargsr>�table�c�
append_columnr�sqltypes�NullTyperJr)r@rlrn�cols    rD�create_indexzMSSQLImpl.create_index�s�����(�(��$�?�?�E�2�
��{�&�&�&� �	J�	J�C��%�+�-�'�'���)�)�&��h�6G�*H�*H�I�I�I���
�
�;�u�%�%�&�&�&�&�&rErq�Union[TableClause, Table]�rows�
List[dict]c�Z��|jr�|�d|jj�|��z��t��j||fi|��|�d|jj�|��z��dSt��j||fi|��dS)NzSET IDENTITY_INSERT %s ONzSET IDENTITY_INSERT %s OFF)rKrJ�dialect�identifier_preparer�format_tabler;�bulk_insert)r@rqryrBrCs    �rDrzMSSQLImpl.bulk_insert�s�����;�	3��J�J�+��,�2�?�?��F�F�G�
�
�
�
 �E�G�G���t�2�2�r�2�2�2��J�J�,��,�2�?�?��F�F�G�
�
�
�
�
�

 �E�G�G���t�2�2�r�2�2�2�2�2rE�column�Column[Any]c���|�dd��}|r%|�t||d|����|�dd��}|r%|�t||d|����|�dd��}|r$|�t|||����t	��j||fd|i|��dS)N�mssql_drop_defaultFre�mssql_drop_checkzsys.check_constraints�mssql_drop_foreign_keyr_)�poprJrj�_ExecDropFKConstraintr;�drop_column)	r@rTr�r_rB�drop_default�
drop_check�drop_fksrCs	        �rDr�zMSSQLImpl.drop_column�s����v�v�2�E�:�:���	��J�J�#���(A�6���
�
�
�
�V�V�.��6�6�
��	��J�J�#���(?����
�
�
�
�6�6�2�E�:�:���	J��J�J�,�Z���H�H�I�I�I������J��D�D�v�D��D�D�D�D�DrEc�n�|�tjdd|��}|�tjdd|��}||kS)Nz[\(\) \"\']�)�re�sub)r@�inspector_column�metadata_column�rendered_metadata_default�rendered_inspector_defaults     rD�compare_server_defaultz MSSQLImpl.compare_server_default�sV��%�0�(*����$=�)�)�%�&�1�*,����$>�*�*�&�*�-F�F�FrEc���t���||��\}}}|�|�|s|j�|jjrd}|||fS)NF)r;�_compare_identity_defaultr��primary_key)r@�metadata_identity�inspector_identity�diff�ignored�is_alterrCs      �rDr�z#MSSQLImpl._compare_identity_default�sj���"'�'�'�"C�"C��1�#
�#
���g�x�

�%�"�.��/�"�)�5�"�)�5�6�
�H��W�h�&�&rE)r7r8)rFrr7rG)NFNNNNNN)rTrUrVrUrWrXrYrZr[r\r]r^r_r\r`r^rarbrcrXrBrr7r8)rlr$r7r8)rqrxryrzrBrr7r8rI)rTrUr�r�r_r\r7r8)�__name__�
__module__�__qualname__�__dialect__�transactional_ddlr?r�
type_synonyms�identity_attrs_ignorer<rJrQrSrrwrr�r�r��
__classcell__)rCs@rDr*r*/s���������K����O��-�)�Z�1H�0J�J�M�
��
�
�
�
�
�
�������J�J�J�J�5�5�5�5�5�5�$(�
�"�&*� $�.2�<@�,0�W�W�W�W�W�W�W�r	'�	'�	'�	'�3�3�3�3�3�3�(!%�	E�E�E�E�E�E�E�4G�G�G�0'�'�'�'�'�'�'�'�'rEr*c��eZdZdZd
d�ZdS)rjF�tnamerU�colname�Union[Column[Any], str]r]r_r\r7r8c�>�||_||_||_||_dSrI)r�r�r]r_)r@r�r�r]r_s     rDr<z_ExecDropConstraint.__init__s$����
������
�����rEN)
r�rUr�r�r]rUr_r\r7r8�r�r�r��
inherit_cacher<rorErDrjrjs-�������M�
�
�
�
�
�
rErjc��eZdZdZdd
�ZdS)
r�Fr�rUr�r�r_r\r7r8c�0�||_||_||_dSrI)r�r�r_)r@r�r�r_s    rDr<z_ExecDropFKConstraint.__init__!s����
��������rEN)r�rUr�r�r_r\r7r8r�rorErDr�r�s-�������M������rEr�r+�element�compilerr"r7rUc	��|j|j|j|jf\}}}}d|||t	|||��|r|dzndd�zS)Nadeclare @const_name varchar(256)
select @const_name = QUOTENAME([name]) from %(type)s
where parent_object_id = object_id('%(schema_dot)s%(tname)s')
and col_name(parent_object_id, parent_column_id) = '%(colname)s'
exec('alter table %(tname_quoted)s drop constraint ' + @const_name)�.r�)�typer�r��tname_quoted�
schema_dot)r_r�r�r]r)r�r�rBr_r�r�r]s       rD�_exec_drop_col_constraintr�)sn��
	���
����
�	%�!�F�E�7�E�G�
���)�(�E�6�B�B�&,�4�f�s�l�l�"�J�J�	
�
rEc�l�|j|j|j}}}d||t|||��|r|dzndd�zS)Naydeclare @const_name varchar(256)
select @const_name = QUOTENAME([name]) from
sys.foreign_keys fk join sys.foreign_key_columns fkc
on fk.object_id=fkc.constraint_object_id
where fkc.parent_object_id = object_id('%(schema_dot)s%(tname)s')
and col_name(fkc.parent_object_id, fkc.parent_column_id) = '%(colname)s'
exec('alter table %(tname_quoted)s drop constraint ' + @const_name)r�r�)r�r�r�r�)r_r�r�r)r�r�rBr_r�r�s      rD�_exec_drop_col_fk_constraintr�BsZ��%�^�W�]�G�O�7�E�F�G���)�(�E�6�B�B�&,�4�f�s�l�l�"�	J�J�
�rErr!c�d�t||j|j���dt||jfi|����S�N� )rrTr_�mssql_add_columnr��r�r�rBs   rD�visit_add_columnr�VsB��	�H�g�0�'�.�A�A�A�A���7�>�8�8�R�8�8�8��rEr�r�c�$�d|j|fi|��zS)NzADD %s)�get_column_specification)r�r�rBs   rDr�r�^s%���7�h�7��E�E�"�E�E�E�ErErc��t||j|j���dt||j���dt||j���d|jrdnd��S)Nr��NULLzNOT NULL)rrTr_rrVrr`rWr�s   rD�visit_column_nullabler�dsf��
	�H�g�0�'�.�A�A�A�A��X�w�2�3�3�3�3��H�g�3�4�4�4�4��"�2���
�2�	�rErc��t||j|j���dt||j���dt||j����S)Nz
 ADD DEFAULT z FOR )rrTr_r�defaultrrVr�s   rD�visit_column_defaultr�psP��	�H�g�0�'�.�A�A�A�A��h���8�8�8�8��8�W�%8�9�9�9��rErc	��dt||j|j���dt||j���dt||j���d�S)N�EXEC sp_rename 'r��', z
, 'COLUMN')rrTr_rrV�newnamer�s   rD�visit_rename_columnr�}sU���
	�(�G�$6���G�G�G�G��8�W�%8�9�9�9�9��8�W�_�5�5�5�5��rErc��t||j|j���dt||j���dt||j����Sr�)rrTr_rrVrr]r�s   rD�visit_column_typer��sP��
	�H�g�0�'�.�A�A�A�A��X�w�2�3�3�3�3��H�g�m�,�,�,��rErc�l�dt||j|j���dt||jd����S)Nr�r�)rrTr_�new_table_namer�s   rD�visit_rename_tabler��s?���
	�(�G�$6���G�G�G�G��(�G�$:�D�A�A�A��rE)r�rjr�r"r7rU)r�r�r�r"r7rU)r�rr�r!r7rU)r�r!r�r�r7rU)r�rr�r!r7rU)r�rr�r!r7rU)r�rr�r!r7rU)r�rr�r!r7rU)r�rr�r!r7rU)A�
__future__rr��typingrrrrr�
sqlalchemyr	rt�sqlalchemy.ext.compilerr
�sqlalchemy.schemarr�sqlalchemy.sql.baser
�sqlalchemy.sql.elementsr�baserrrrrrrrrrrr�implrr�rrr �sqlalchemy.dialects.mssql.baser!r"�sqlalchemy.engine.cursorr#�sqlalchemy.sql.schemar$r%�sqlalchemy.sql.selectabler&�sqlalchemy.sql.type_apir'r(r*rjr�r�r�r�r�r�r�r�r�r�rorErD�<module>r�s���"�"�"�"�"�"�	�	�	�	������������������� � � � � � �������(�(�(�(�(�(�,�,�,�,�,�,�$�$�$�$�$�$�)�)�)�)�)�)�*�*�*�*�*�*�1�1�1�1�1�1������������������������������� � � � � � �������$�$�$�$�$�$�'�'�'�'�'�'�#�#�#�#�#�#��������������������������������%�������<�<�<�<�<�<�<�<�<�<�<�<�5�5�5�5�5�5�+�+�+�+�+�+�+�+�+�+�+�+�5�5�5�5�5�5�2�2�2�2�2�2�$�$�$�$�$�$�\'�\'�\'�\'�\'��\'�\'�\'�~
�
�
�
�
�*�m�
�
�
� �����J�
����
��
�w�'�'����(�'��0
��
��)�)����*�)��&
��)�W���������F�F�F�F�
��.�'�"�"����#�"��
��-��!�!�	�	�	�"�!�	�
��*�g���������
��*�g���������
��+�w������ ����rE