Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.117.105.195
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : statement.cpython-312.pyc
�

%fO����dZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
dd	lmZdd
lmZmZmZGd�de�Zd
�Zd>d�Zd>d�Zd>d�Zd>d�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Z Gd�de�Z!Gd�de�Z"Gd �d!e�Z#Gd"�d#e�Z$Gd$�d%e�Z%Gd&�d'e�Z&Gd(�d)e�Z'Gd*�d+e�Z(Gd,�d-e�Z)Gd.�d/e�Z*Gd0�d1e�Z+Gd2�d3e+�Z,Gd4�d5e�Z-Gd6�d7e�Z.Gd8�d9e.�Z/Gd:�d;e/�Z0Gd<�d=e�Z1y)?zImplementation of Statements.�N�)�ProgrammingError)�
ExprParser)�STRING_TYPES)�
Algorithms�
Securities)�DbDoc)�mysqlx_crud_pb2)�	SqlResult�Result�
ColumnTypec��eZdZd�Zy)�Exprc��||_y�N)�expr)�selfrs  �G/usr/local/python-3.12/lib/python3.12/site-packages/mysqlx/statement.py�__init__z
Expr.__init__&s	����	�N)�__name__�
__module__�__qualname__r�rrrr%s��rrc�^�t|�dk(rt|dttf�r|dS|S)Nrr)�len�
isinstance�list�tuple)�valuess r�flexible_paramsr!*s.��
�6�{�a��J�v�a�y�4��.�A��a�y���Mrc�z�d|vr&|ddk(xr|ddk(xs|ddk(xr|ddk(S|ddk(xr|ddk(S)z�Check if the given identifier is quoted.

    Args:
        identifier (string): Identifier to check.
        sql_mode (Optional[string]): SQL mode.

    Returns:
        `True` if the identifier has backtick quotes, and False otherwise.
    �ANSI_QUOTESr�`����"r��
identifier�sql_modes  r�is_quoted_identifierr*0sk���� ��A��#�%�?�*�R�.�C�*?�A��A��#�%�?�*�R�.�C�*?�	B��!�}��#�=�
�2��#�(=�=rc��t||�r|Sd|vr!dj|jdd��Sdj|jdd��S)a�Quote the given identifier with backticks, converting backticks (`) in
    the identifier name with the correct escape sequence (``) unless the
    identifier is quoted (") as in sql_mode set to ANSI_QUOTES.

    Args:
        identifier (string): Identifier to quote.
        sql_mode (Optional[string]): SQL mode.

    Returns:
        A string with the identifier quoted with backticks.
    r#z"{0}"r&z""z`{0}`r$z``)r*�format�replacer's  r�quote_identifierr.AsT���J��1����� ��~�~�j�0�0��d�;�<�<��~�~�j�0�0��d�;�<�<rc	�^�dj|D�cgc]}t||���c}�Scc}w)aQuote the given multi-part identifier with backticks.

    Args:
        identifiers (iterable): List of identifiers to quote.
        sql_mode (Optional[string]): SQL mode.

    Returns:
        A string with the multi-part identifier quoted with backticks.
    �.)�joinr.)�identifiersr)r(s   r�quote_multipart_identifierr3Us7���8�8�'2�4�#�&�j�(�;�4�5�5��4s�*c���d|vrdnd}||vrdj|�nd}|j|d�}t|�dur|n|dj|�|dj|�fS)	Nr#r&r$z.{0}r0rrr%)r,�splitr�strip)�default_schema�
table_namer)�quote�	delimiter�temps      r�parse_table_namer<cso�� �H�,�C�#�E�(-��(;��
�
�e�$��I����I�q�)�D�!�$�i�1�n�N�$�q�'�-�-��2F���H�N�N�5�!�$�$rc�>�eZdZdZdd�Zed��Zed��Zd�Zy)�	Statementa	Provides base functionality for statement objects.

    Args:
        target (object): The target database object, it can be
                         :class:`mysqlx.Collection` or :class:`mysqlx.Table`.
        doc_based (bool): `True` if it is document based.
    c�V�||_||_|r|j|_yd|_yr)�_target�
_doc_based�_connection)r�target�	doc_baseds   rrzStatement.__init__ss'�����#���17�6�-�-���T��rc��|jS)z,object: The database object target.
        )r@�rs rrCzStatement.targetxs���|�|�rc�.�|jjS)z3:class:`mysqlx.Schema`: The Schema object.
        )r@�schemarFs rrHzStatement.schema~s���|�|�"�"�"rc��t��zqExecute the statement.

        Raises:
           NotImplementedError: This method must be implemented.
        ��NotImplementedErrorrFs r�executezStatement.execute��
��"�!rN)T)	rrr�__doc__r�propertyrCrHrMrrrr>r>ks:���B�
����
�#��#�
"rr>c�\��eZdZdZd�fd�	Zd�Zd�Zd
d�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
�xZS)�FilterableStatementa�A statement to be used with filterable statements.

    Args:
        target (object): The target database object, it can be
                         :class:`mysqlx.Collection` or :class:`mysqlx.Table`.
        doc_based (Optional[bool]): `True` if it is document based
                                    (default: `True`).
        condition (Optional[str]): Sets the search condition to filter
                                   documents or records.
    c����tt|�||��d|_d|_d|_d|_d|_d|_d|_	i|_
g|_|�|j|�yy)N�rCrDF)
�superrRr�_has_projection�
_has_where�
_has_limit�	_has_sort�
_has_group_by�_has_having�
_has_bindings�_binding_map�	_bindings�where)rrCrD�	condition�	__class__s    �rrzFilterableStatement.__init__�sy���
�!�4�1��<E�	2�	G�$������������"��� ���"���������� ��J�J�y�!�!rc��d|_||_t||j�}|j	�|_|j|_|S)aSets the search condition to filter.

        Args:
            condition (str): Sets the search condition to filter documents or
                             records.

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.
        T)rW�_whererrAr�_where_expr�placeholder_name_to_positionr])rr`rs   rr_zFilterableStatement.where�sF���������)����%8�9���9�9�;��� �=�=����rc��t|�}d|_dj|�|_t	|j|j
�j
�|_|S�NT�,)r!rVr1�_projection_strrrA�parse_table_select_projection�_projection_expr�r�fieldss  r�_projectionzFilterableStatement._projection�sU�� �&�)��#���"�x�x��/��� *�4�+?�+?�����!!�!>�!>�!@�	
���rc�0�d|_||_||_|S)aESets the maximum number of records or documents to be returned.

        Args:
            row_count (int): The maximum number of records or documents.
            offset (Optional[int]) The number of records or documents to skip.

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.
        T)rX�
_limit_offset�_limit_row_count)r�	row_count�offsets   r�limitzFilterableStatement.limit�s �����#��� )����rc��t|�}d|_dj|�|_t	|j|j
�j
�|_|S)z�Sets the sorting criteria.

        Args:
            *sort_clauses: The expression strings defining the sort criteria.

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.
        Trh)r!rYr1�	_sort_strrrA�parse_order_spec�
_sort_expr)r�sort_clausess  r�sortzFilterableStatement.sort�sR��'��5��������,�/���$�T�^�^�)-���%8�:�:J�:J�:L�	
���rc��t|�}d|_dj|�|_t	|j|j
�j
�|_yrg)r!rZr1�
_grouping_strrrA�parse_expr_list�	_groupingrls  r�	_group_byzFilterableStatement._group_by�sN�� �&�)��!��� �X�X�f�-���#�D�$6�$6�(,���$7�9�9H��9J�	
�rc�f�d|_t||j�j�|_y�NT)r[rrAr�_having�rr`s  rr�zFilterableStatement._having�s(�����!�)����-@�A�F�F�H��rc���d|_t|�}|dk(r|j|d�|S|dkDrtd��|jj|d|dd��|S)a�Binds a value to a specific placeholder.

        Args:
            *args: The name of the placeholder and the value to bind.
                   A :class:`mysqlx.DbDoc` object or a JSON string
                   representation can be used.

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.

        Raises:
            ProgrammingError: If the number of arguments is invalid.
        Trr�z#Invalid number of arguments to bind)�name�value)r\r�_bind_singlerr^�append)r�args�counts   r�bindzFilterableStatement.bind�sn��"����D�	���A�:����d�1�g�&�
��	�Q�Y�"�#H�I�I��N�N�!�!�4��7�T�!�W�"E�F��rc��t|t�r|jt|��yt|t�r@tj|�}|j�D]}|j|||��yyr)rr	r��strr�json�loads�keys)r�object�dict�keys    rr�z FilterableStatement._bind_singles`���f�e�$��I�I�c�&�k�"�
���
-��:�:�f�%�D��y�y�{�
*���	�	�#�t�C�y�)�
*�.rc��t�rJrKrFs rrMzFilterableStatement.execute
rNr)TN)r)rrrrOrr_rnrtrzrr�r�r�rM�
__classcell__�ras@rrRrR�s<���	�
"��"�
�� K�I��0*�"rrRc�(��eZdZdZ�fd�Zd�Z�xZS)�SqlStatementz�A statement for SQL execution.

    Args:
        connection (mysqlx.connection.Connection): Connection object.
        sql (string): The sql statement to be executed.
    c�L��tt|�dd��||_||_y�NFrT)rUr�rrB�_sql)r�
connection�sqlras   �rrzSqlStatement.__init__s&���
�l�D�*�$�%�*�H�%�����	rc�v�|jj|j�t|j�S)zaExecute the statement.

        Returns:
            mysqlx.SqlResult: SqlResult object.
        )rB�send_sqlr�rrFs rrMzSqlStatement.executes-��	
���!�!�$�)�)�,���)�)�*�*r�rrrrOrrMr�r�s@rr�r�s�����
+rr�c�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�AddStatementz�A statement for document addition on a collection.

    Args:
        collection (mysqlx.Collection): The Collection object.
    c�J��tt|�|��g|_g|_y�N)rC)rUr�r�_values�_ids�r�
collectionras  �rrzAddStatement.__init__/s#���
�l�D�*�*�*�=������	rc��t|�D]R}t|t�r|jj	|��/|jj	t|���T|S)z�Adds a list of documents into a collection.

        Args:
            *values: The documents to be added into the collection.

        Returns:
            mysqlx.AddStatement: AddStatement object.
        )r!rr	r�r�)rr �vals   r�addzAddStatement.add4sQ��#�F�+�	0�C��#�u�%����#�#�C�(����#�#�E�#�J�/�		0�
�rc���t|j�dk(r
t�S|jD]+}|jj	|j���-|jj|�S)�[Execute the statement.

        Returns:
            mysqlx.Result: Result object.
        r)rr�rr�r��	ensure_idrB�send_insert)r�docs  rrMzAddStatement.executeDs`���t�|�|���!��8�O��<�<�	.�C��I�I���S�]�]�_�-�	.����+�+�D�1�1r)rrrrOrr�rMr�r�s@rr�r�)s����
�
� 2rr�c��eZdZdd�Zd�Zy)�
UpdateSpecNc�4�|tjjk(r|j||�y||_||_t
|�dkDr|ddk(r
|dd|_t|j
d�j�j|_||_
y)Nr�$rF)�
MySQLxCrud�UpdateOperation�SET�
_table_set�update_type�sourcerr�document_fieldr(r�)rr�r�r�s    rrzUpdateSpec.__init__Ts����*�4�4�8�8�8��O�O�F�E�*�*�D�� �D�K��6�{�Q��6�!�9��#3�$�Q�R�j���$�T�[�[�%*�,�,:�N�,<�Z�Z�
�K��D�Jrc��tjj|_t	|d�j�|_||_yr�)r�r�r�r�r�parse_table_update_fieldr�r�)rr�r�s   rr�zUpdateSpec._table_set`s4��%�5�5�9�9��� ���.�G�G�I�����
rr)rrrrr�rrrr�r�Ss��
�rr�c�H��eZdZdZd	�fd�	Zd�Zd�Zd�Zd�Zd�Z	d�Z
�xZS)
�ModifyStatementaA statement for document update operations on a Collection.

    Args:
        collection (mysqlx.Collection): The Collection object.
        condition (Optional[str]): Sets the search condition to identify the
                                   documents to be updated.
    c�>��tt|�||��g|_y)N)rCr`)rUr�r�_update_ops�rr�r`ras   �rrzModifyStatement.__init__ns%���
�o�t�-�Z�8A�	.�	C���rc��|jjttjj
||��|S)a2Sets or updates attributes on documents in a collection.

        Args:
            doc_path (string): The document path of the item to be set.
            value (string): The value to be set on the specified attribute.

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.
        )r�r�r�r�r��ITEM_SET�r�doc_pathr�s   r�setzModifyStatement.setss6��	
������z�1�1�:�:�H�e�L�	N��rc��|jjttjj
||��|S)ajAdd an update to the statement setting the field, if it exists at
        the document path, to the given value.

        Args:
            doc_path (string): The document path of the item to be set.
            value (object): The value to be set on the specified attribute.

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.
        )r�r�r�r�r��ITEM_REPLACEr�s   r�changezModifyStatement.change�s:��	
������z�1�1�>�>���
�	��rc	��|jjt|�D�cgc]&}ttj
j|���(c}�|Scc}w)aRemoves attributes from documents in a collection.

        Args:
            doc_path (string): The document path of the attribute to be
                               removed.

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.
        )r��extendr!r�r�r��ITEM_REMOVE)r�	doc_paths�xs   r�unsetzModifyStatement.unset�sR��	
�����$�i�0�!2��
�z�1�1�=�=�q�A�!2�	3����!2s�+Ac��|jjttjj
||��|S)a�Insert a value into the specified array in documents of a
        collection.

        Args:
            field (string): A document path that identifies the array attribute
                            and position where the value will be inserted.
            value (object): The value to be inserted.

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.
        )r�r�r�r�r��ARRAY_INSERT�r�fieldr�s   r�array_insertzModifyStatement.array_insert�s6��	
������z�1�1�>�>��u�M�	O��rc��|jjttjj
||��|S)a�Inserts a value into a specific position in an array attribute in
        documents of a collection.

        Args:
            doc_path (string): A document path that identifies the array
                               attribute and position where the value will be
                               inserted.
            value (object): The value to be inserted.

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.
        )r�r�r�r�r��ARRAY_APPENDr�s   r�array_appendzModifyStatement.array_append�s:��	
������z�1�1�>�>���
�	��rc�8�|jj|�S�r��rB�updaterFs rrMzModifyStatement.execute�������&�&�t�,�,rr)rrrrOrr�r�r�r�r�rMr�r�s@rr�r�fs+�����
�� 
�� �$-rr�c�<��eZdZdZd�fd�	Zd�Zd�Zd�Zd�Z�xZ	S)�
FindStatementa�A statement document selection on a Collection.

    Args:
        collection (mysqlx.Collection): The Collection object.
        condition (Optional[str]): An optional expression to identify the
                                   documents to be retrieved. If not specified
                                   all the documents will be included on the
                                   result unless a limit is set.
    c�0��tt|�|d|�yr�)rUr�rr�s   �rrzFindStatement.__init__�s���
�m�T�+�J��i�Hrc� �|j|�S)z�Sets a document field filter.

        Args:
            *fields: The string expressions identifying the fields to be
                     extracted.

        Returns:
            mysqlx.FindStatement: FindStatement object.
        )rnrls  rrmzFindStatement.fields�s�� �t����(�(rc�$�|j|�|S)z�Sets a grouping criteria for the resultset.

        Args:
            *fields: The string expressions identifying the grouping criteria.

        Returns:
            mysqlx.FindStatement: FindStatement object.
        �rrls  r�group_byzFindStatement.group_by����	�������rc�(�|j|�|S)a=Sets a condition for records to be considered in agregate function
        operations.

        Args:
            condition (string): A condition on the agregate functions used on
                                the grouping criteria.

        Returns:
            mysqlx.FindStatement: FindStatement object.
        �r�r�s  r�havingzFindStatement.having����	
���Y���rc�8�|jj|�S)zaExecute the statement.

        Returns:
            mysqlx.DocResult: DocResult object.
        �rB�findrFs rrMzFindStatement.execute�������$�$�T�*�*rr)
rrrrOrrmr�r�rMr�r�s@rr�r��s"����I�
)�
��+rr�c�:��eZdZdZ�fd�Zd�Zd�Zd�Zd�Z�xZ	S)�SelectStatementz�A statement for record retrieval operations on a Table.

    Args:
        table (mysqlx.Table): The Table object.
        *fields: The fields to be retrieved.
    c�L��tt|�|d�|j|�y�NF)rUr�rrn�r�tablermras   �rrzSelectStatement.__init__s$���
�o�t�-�e�U�;�����&�!rc�$�|j|�|S)z�Sets a grouping criteria for the resultset.

        Args:
            *fields: The fields identifying the grouping criteria.

        Returns:
            mysqlx.SelectStatement: SelectStatement object.
        r�rls  rr�zSelectStatement.group_byr�rc�(�|j|�|S)a;Sets a condition for records to be considered in agregate function
        operations.

        Args:
            condition (str): A condition on the agregate functions used on the
                             grouping criteria.

        Returns:
            mysqlx.SelectStatement: SelectStatement object.
        r�r�s  rr�zSelectStatement.havingr�rc�8�|jj|�S)zaExecute the statement.

        Returns:
            mysqlx.RowResult: RowResult object.
        r�rFs rrMzSelectStatement.execute,r�rc
�N�|jrdj|j�nd}|jrdj|j�nd}|j
rdj|j�nd}|jrdj|j�nd}|jr&dj|j|j�nd}djt|dd	�|jj|jj|||||�
�}|S)Nz
 WHERE {0}�z
 GROUP BY {0}z HAVING {0}z
 ORDER BY {0}z LIMIT {0} OFFSET {1}zISELECT {select} FROM {schema}.{table}{where}{group}{having}{order}{limit}ri�*)�selectrHr�rtr_�groupr��order)rWr,rcrZr|r[r�rYrvrXrqrp�getattrrHr�rC)rr_r�r��order_byrt�stmts       r�get_sqlzSelectStatement.get_sql4s��48�O�O��#�#�D�K�K�0������#�)�)�$�*<�*<�=�$&�	�7;�7G�7G��%�%�d�l�l�3�R��=A�^�^�?�)�)�$�.�.�9��	�$(�?�?�(�.�.�t�/D�/D���� �8:�	�!�!'���t�%6��<��{�{�'�'�t�{�{�/?�/?�u��8�F�(�"(�"L�	
��r)
rrrrOrr�r�rMrr�r�s@rr�r�s!����"�
��+�rr�c�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�InsertStatementz�A statement for insert operations on Table.

    Args:
        table (mysqlx.Table): The Table object.
        *fields: The fields to be inserted.
    c�X��tt|�|d��t|�|_g|_yr�)rUrrr!�_fieldsr�r�s   �rrzInsertStatement.__init__Ms*���
�o�t�-�U�e�-�L�&��/�����rc�Z�|jjtt|���|S)z�Set the values to be inserted.

        Args:
            *values: The values of the columns to be inserted.

        Returns:
            mysqlx.InsertStatement: InsertStatement object.
        )r�r�rr!�rr s  rr zInsertStatement.valuesRs%��	
�����D��&�!9�:�;��rc�8�|jj|�Sr�)rBr�rFs rrMzInsertStatement.execute^s�����+�+�D�1�1r)rrrrOrr rMr�r�s@rrrFs�����

�2rrc�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�UpdateStatementz�A statement for record update operations on a Table.

    Args:
        table (mysqlx.Table): The Table object.
        *fields: The fields to be updated.
    c�>��tt|�|d��g|_yr�)rUr
rr�r�s   �rrzUpdateStatement.__init__ns���
�o�t�-�U�e�-�L���rc��|jjttjj
||��|S)aUpdates the column value on records in a table.

        Args:
            field (string): The column name to be updated.
            value (object): The value to be set on the specified column.

        Returns:
            mysqlx.UpdateStatement: UpdateStatement object.
        )r�r�r�r�r�r�r�s   rr�zUpdateStatement.setrs6��	
������z�1�1�5�5�u�e�D�	F��rc�8�|jj|�S)zZExecute the statement.

        Returns:
            mysqlx.Result: Result object
        r�rFs rrMzUpdateStatement.execute�r�r)rrrrOrr�rMr�r�s@rr
r
gs������-rr
c�(��eZdZdZ�fd�Zd�Z�xZS)�RemoveStatementz�A statement for document removal from a collection.

    Args:
        collection (mysqlx.Collection): The Collection object.
    c�.��tt|�|��yr�)rUrrr�s  �rrzRemoveStatement.__init__�s���
�o�t�-�Z�-�@rc�8�|jj|�Sr��rB�deleterFs rrMzRemoveStatement.execute�r�rr�r�s@rrr�s����
A�-rrc�*��eZdZdZd�fd�	Zd�Z�xZS)�DeleteStatementz�A statement that drops a table.

    Args:
        table (mysqlx.Table): The Table object.
        condition (Optional[str]): The string with the filter expression of
                                   the rows to be deleted.
    c�2��tt|�||d��y)NF)rCr`rD)rUrr)rr�r`ras   �rrzDeleteStatement.__init__�s���
�o�t�-�U�8A�8=�	.�	?rc�8�|jj|�Sr�rrFs rrMzDeleteStatement.execute�r�rrr�r�s@rrr�s����?�
-rrc�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�CreateCollectionIndexStatementz�A statement that creates an index on a collection.

    Args:
        collection (mysqlx.Collection): Collection.
        index_name (string): Index name.
        is_unique (bool): `True` if the index is unique.
    c�X��tt|�|��||_||_g|_yr�)rUrr�_index_name�
_is_uniquer)rr��
index_name�	is_uniqueras    �rrz'CreateCollectionIndexStatement.__init__�s,���
�,�d�<�J�<�O�%���#�����rc�B�|jj|||f�|S)a�Add the field specification to this index creation statement.

        Args:
            document_path (string): The document path.
            column_type (string): The column type.
            is_required (bool): `True` if the field is required.

        Returns:
            mysqlx.CreateCollectionIndexStatement:                                    CreateCollectionIndexStatement object.
        )rr�)r�
document_path�column_type�is_requireds    rr�z$CreateCollectionIndexStatement.field�s"��	
�����]�K��F�G��rc	�$�|jD��cgc]}|D]}|���
}}}|jjddd|jjj
|jj
|j|jg|���Scc}}w)r��xplugin�create_collection_indexT)rrB�execute_nonqueryr@rHr�rr)r�sublist�itemrms    rrMz&CreateCollectionIndexStatement.execute�s���'+�l�l�G�7�w�G�t�$�G�$�G��G�0�t���0�0��0�$��L�L���$�$�d�l�l�&7�&7��9I�9I��O�O�&�%�&�	&��Hs�B)rrrrOrr�rMr�r�s@rrr�s�����
�
&rrc�(��eZdZdZ�fd�Zd�Z�xZS)�DropCollectionIndexStatementz�A statement that drops an index on a collection.

    Args:
        collection (mysqlx.Collection): The Collection object.
        index_name (string): The index name.
    c�<��tt|�|��||_yr�)rUr*rr)rr�rras   �rrz%DropCollectionIndexStatement.__init__�s���
�*�D�:�*�:�M�%��rc��|jjddd|jjj|jj|j
�S)r�r$�drop_collection_indexT)rBr&r@rHr�rrFs rrMz$DropCollectionIndexStatement.execute�sN�����0�0��.���L�L���$�$�d�l�l�&7�&7��9I�9I�K�	Krr�r�s@rr*r*�s����&�Krr*c� �eZdZdZdZd�Zd�Zy)�
TableIndexrr�c�.�||_||_||_yr)�_name�_index_type�_columns)rr��
index_type�columnss    rrzTableIndex.__init__�s����
�%�����
rc��d}|jtjur|dz
}|dz
}|j|jdj|j��S)Nr�zUNIQUE zINDEX {0} ({1})rh)r2r/�UNIQUE_INDEXr,r1r1r3)rrs  rrzTableIndex.get_sql�sR�������z�6�6�6��I��D��!�!���{�{�4�:�:�s�x�x��
�
�'>�?�?rN)rrrr7�INDEXrrrrrr/r/�s���L�
�E� �
@rr/c�N��eZdZdZd
�fd�	Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Z�xZS)�CreateViewStatementz�A statement for creating views.

    Args:
        view (mysqlx.View): The View object.
        replace (Optional[bool]): `True` to add replace.
    c���tt|�|d��||_|j|_|j|_||_g|_	tj|_tj|_d|_d|_d|_yr�)rUr:r�_viewrH�_schemar�r1�_replacer3r�	UNDEFINED�
_algorithmr�DEFINER�	_security�_definer�_defined_as�
_check_option)r�viewr-ras   �rrzCreateViewStatement.__init__st���
�!�4�1���1�O���
��{�{����Y�Y��
���
���
�$�.�.���#�+�+�����
����!��rc�L�|D�cgc]
}t|���c}|_|Scc}w)z�Sets the column names.

        Args:
            columns (list): The list of column names.

        Returns:
            mysqlx.CreateViewStatement: CreateViewStatement object.
        )r.r3)rr5�cols   rr5zCreateViewStatement.columnss(��;B�B�3�)�#�.�B��
����Cs�!c��||_|S)z�Sets the algorithm.

        Args:
            mysqlx.constants.ALGORITHMS: The algorithm.

        Returns:
            mysqlx.CreateViewStatement: CreateViewStatement object.
        )r@)r�	algorithms  rrJzCreateViewStatement.algorithm!���$����rc��||_|S)z�Sets the SQL security mode.

        Args:
            mysqlx.constants.SECURITIES: The SQL security mode.

        Returns:
            mysqlx.CreateViewStatement: CreateViewStatement object.
        )rB)r�securitys  rrMzCreateViewStatement.security-s��"����rc��||_|S)z�Sets the definer.

        Args:
            definer (string): The definer.

        Returns:
            mysqlx.CreateViewStatement: CreateViewStatement object.
        )rC)r�definers  rrOzCreateViewStatement.definer9��� ��
��rc��||_|S)z�Sets the SelectStatement statement for describing the view.

        Args:
            mysqlx.SelectStatement: SelectStatement object.

        Returns:
            mysqlx.CreateViewStatement: CreateViewStatement object.
        )rD)r�	statements  r�
defined_aszCreateViewStatement.defined_asEs��%����rc��||_|S)z�Sets the check option.

        Args:
            mysqlx.constants.CHECK_OPTIONS: The check option.

        Returns:
            mysqlx.CreateViewStatement: CreateViewStatement object.
        )rE)r�check_options  r�with_check_optionz%CreateViewStatement.with_check_optionQs��*����rc
�J�|jrdnd}|jrdj|j�nd}|jr*djdj	|j��nd}t|jj|jf�}|jrdj|j�nd}dj||j||j|||j|��}|jjd	|�|jS)
zhExecute the statement to create a view.

        Returns:
            mysqlx.View: View object.
        z OR REPLACEr�� DEFINER = {0}� ({0})�, � WITH {0} CHECK OPTIONz�CREATE{replace} ALGORITHM = {algorithm}{definer} SQL SECURITY {security} VIEW {view_name}{columns} AS {defined_as}{check_option})r-rJrOrM�	view_namer5rSrUr�)r>rCr,r3r1r3r=r�r1rEr@rBrDrBr&r<)rr-rOr5r\rUr�s       rrMzCreateViewStatement.execute]s��$(�=�=�-�b���]�]�#�)�)�$�-�-�8�(*�	��]�]��/�/�$�)�)�D�M�M�":�;�(*�	�.����0A�0A�4�:�:�/N�O�	��,�,�0�6�6�t�7I�7I�J�24�	���&��D�O�O�!(�4�>�>�#,�g�$(�$4�$4�&2�	�4�	�	
���)�)�%��5��z�z�r)F)
rrrrOrr5rJrMrOrSrVrMr�r�s@rr:r:s0����"�
�
�
�
�
�
�rr:c�(��eZdZdZ�fd�Zd�Z�xZS)�AlterViewStatementzYA statement for alter views.

    Args:
        view (mysqlx.View): The View object.
    c�,��tt|�|�yr)rUr^r)rrFras  �rrzAlterViewStatement.__init__~s���
� �$�0��6rc	�(�|jrdj|j�nd}|jr*djdj|j��nd}t	|j
j|jf�}|jrdj|j�nd}dj|j||j|||j|��}|jjd|�|jS)	zgExecute the statement to alter a view.

        Returns:
            mysqlx.View: View object.
        rXr�rYrZr[zvALTER ALGORITHM = {algorithm}{definer} SQL SECURITY {security} VIEW {view_name}{columns} AS {defined_as}{check_option})rJrOrMr\r5rSrUr�)rCr,r3r1r3r=r�r1rEr@rBrDrBr&r<)rrOr5r\rUr�s      rrMzAlterViewStatement.execute�s����]�]�#�)�)�$�-�-�8�(*�	��]�]��/�/�$�)�)�D�M�M�":�;�(*�	�.����0A�0A�4�:�:�/N�O�	��,�,�0�6�6�t�7I�7I�J�24�	���&�4�?�?�G�"&�.�.�I�!(�T�5E�5E�&2��4�	�	
���)�)�%��5��z�z�rr�r�s@rr^r^xs����
7�rr^c����eZdZdZej
dej�Z�fd�Ze	d��Z
d�Zd�Zd�Z
d�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�CreateTableStatementz�A statement that creates a new table if it doesn't exist already.

    Args:
        collection (mysqlx.Schema): The Schema object.
        table_name (string): The name for the new table.
    z$(from\s+)([`\"].+[`\"]|[^\.]+)(\s|$)c�>��tt|�|�d|_d|_d|_d|_d|_d|_g|_	g|_
g|_g|_g|_
d|_||_dj!|j"j%��|_y)NFrz
\1{0}.\2\3)rUrbr�_charset�
_collation�_comment�_as�_like�_tempr3�_f_keys�_indices�_p_keys�
_u_indices�	_auto_incr1r,rH�get_name�	_tbl_repl)rrHr8ras   �rrzCreateTableStatement.__init__�s����
�"�D�2�6�:���
������
������
���
���
������
������������
�&�-�-�d�k�k�.B�.B�.D�E��rc�h�tt|jj|j��S)z7string: The fully qualified name of the Table.
        )r3r<rHr�r1rFs rr8zCreateTableStatement.table_name�s,��*�*:��K�K���d�j�j�+*�+�	+rc�r�g}|jd�|jr|jd�|jr|jd�|jr|jd�dj	|�}|j|j|j|j|j��S)NzAUTO_INCREMENT = {inc}z!DEFAULT CHARACTER SET = {charset}zDEFAULT COLLATE = {collation}zCOMMENT = '{comment}'rh)�inc�charset�	collation�comment)r�rdrerfr1r,rn)r�options�
table_optss   r�_get_table_optsz$CreateTableStatement._get_table_opts�s��������/�0��=�=��N�N�>�?��?�?��N�N�:�;��=�=��N�N�2�3��X�X�g�&�
�� � �T�^�^�T�]�]��o�o�t�}�}�!�>�	>rc�2�g}|jr9|jdjdj|j���|jD]!}|j|j���#|jD]!}|j|j���#|jD]!}|j|j���#|jD]!}|j|j���#dj|�S)NzPRIMARY KEY ({0})rh)	rlr�r,r1r3rrjrkrm)r�defsrHr��indexs     r�_get_create_defz$CreateTableStatement._get_create_def�s������<�<��K�K�+�2�2�3�8�8�D�L�L�3I�J�K��=�=�	'�C��K�K����
�&�	'��<�<�	'�C��K�K����
�&�	'��]�]�	)�E��K�K��
�
��(�	)��_�_�	)�E��K�K��
�
��(�	)��x�x��~�rc�b�tt|jj|��|_|S)z�Create table with the definition of another existing Table.

        Args:
            table_name (string): Name of the source table.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        )r3r<rHr�rh)rr8s  r�likezCreateTableStatement.like�s)��0��T�[�[�-�-�z�:�<��
��rc���t|t�r1tjj	|j
|�|_|St|t�r|j�|_|S)a.Create the Table and fill it with values from a Select Statement.

        Args:
            select (object): Select Statement. Can be a string or an instance of
            :class`mysqlx.SelectStatement`.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        )	rrrb�tbl_frmt�subrprgr�r)rr�s  r�	as_selectzCreateTableStatement.as_select�sR���f�l�+�+�4�4�8�8�����P�D�H������
0��~�~�'�D�H��rc��|j|jj��|jj	|�|S)z�Add a Column to the Table.

        Args:
            column_def (MySQLx.ColumnDef): Column Definition object.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        )�
set_schemarHror3r�)r�
column_defs  r�
add_columnzCreateTableStatement.add_column�s6��	���d�k�k�2�2�4�5��
�
���Z�(��rc�L�t|�}|jj|�|S)z�Add multiple Primary Keys to the Table.

        Args:
            *keys: Fields to be used as Primary Keys.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        )r!rlr�)rr�s  r�add_primary_keyz$CreateTableStatement.add_primary_keys%����%�������D�!��rc	�z�|jjt|tjt	|���|S)z�Adds an Index to the Table.

        Args:
            index_name (string): Name of the Index.
            *cols: Fields to be used as an Index.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        )rkr�r/r8r!�rr�colss   r�	add_indexzCreateTableStatement.add_indexs4��	
�
�
���Z�
�J�4D�4D��T�"�$�	%��rc	�z�|jjt|tjt	|���|S)aAdds a Unique Index to the Table.

        Args:
            index_name (string): Name of the Unique Index.
            *cols: Fields to be used as a Unique Index.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        )rmr�r/r7r!r�s   r�add_unique_indexz%CreateTableStatement.add_unique_indexs4��	
�����z�*�j�6M�6M��T�"� $�	%��rc��|j|jj��|j|�|jj|�|S)z�Adds a Foreign Key to the Table.

        Args:
            key (MySQLx.ForeignKeyDef): The Foreign Key Definition object.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        )r�rHro�set_namerjr�)rr�r�s   r�add_foreign_keyz$CreateTableStatement.add_foreign_key*s@��	���t�{�{�+�+�-�.����T�������C� ��rc��||_|S)z�Set the initial Auto Increment value for the table.

        Args:
            inc (int): The initial AUTO_INCREMENT value for the table.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        �rn)rrss  r�set_initial_auto_incrementz/CreateTableStatement.set_initial_auto_increment8s������rc��||_|S)z�Sets the default Charset type for the Table.

        Args:
            charset (string): Charset type.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        �rd�rrts  r�set_default_charsetz(CreateTableStatement.set_default_charsetDrPrc��||_|S)z�Sets the default Collation type for the Table.

        Args:
            collation (string): Collation type.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        �re�rrus  r�set_default_collationz*CreateTableStatement.set_default_collationPrKrc��||_|S)z�Add a comment to the Table.

        Args:
            comment (string): Comment to be added to the Table.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        �rf�rrvs  r�set_commentz CreateTableStatement.set_comment\rPrc��d|_|S)zSet the Table to be Temporary.

        Returns:
            mysqlx.CreateTableStatement: CreateTableStatement object.
        T)rirFs r�	temporaryzCreateTableStatement.temporaryhs����
��rc��dj|j|jrdnd��}|jrd}nd}|j||jxs|jxsd|j�|j
���}|jjd	|d
�|jj|j�S)zYExecute the statement.

        Returns:
            mysqlx.Table: Table object.
        zCREATE {table_type} {name}zTEMPORARY TABLE�TABLE)r��
table_typez{create} LIKE {query}z,{create} ({create_def}) {table_opts} {query}r�)�create�query�
create_defrxr�F)r,r8rirhrgr}ryrBr&rH�	get_tabler1)rr�rs   rrMzCreateTableStatement.executeqs���.�4�4�$�/�/�,0�J�J�(�G�5�E���:�:�*�D�A�D��{�{���*�*�.����.�B��+�+�-��+�+�-�	�/��	
���)�)�%��u�=��{�{�$�$�T�Z�Z�0�0r)rrrrO�re�compile�
IGNORECASEr�rrPr8ryr}rr�r�r�r�r�r�r�r�r�r�r�rMr�r�s@rrbrb�s������r�z�z�A�2�=�=�Q�H�F�$�+��+�>�
��� �����
�
�
�
��1rrbc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�
ColumnDefBasez�A Base class defining the basic parameters required to define a column.

    Args:
        name (string): Name of the column.
        type (MySQLx.ColumnType): Type of the column.
        size (int): Size of the column.
    c�t�d|_d|_d|_d|_||_||_d|_||_y)NFr�)�_default_schema�	_not_null�_p_key�_u_indexr1�_sizerf�_type)rr��type�sizes    rrzColumnDefBase.__init__�s;��#�����������
���
���
���
���
rc��d|_|S)zwDisable NULL values for this column.

        Returns:
            mysqlx.ColumnDefBase: ColumnDefBase object.
        T)r�rFs r�not_nullzColumnDefBase.not_null��������rc��d|_|S)zwSet current column as a Unique Index.

        Returns:
            mysqlx.ColumnDefBase: ColumnDefBase object.
       T)r�rFs r�unique_indexzColumnDefBase.unique_index�s����
��rc��||_|S)z�Add a comment to the column.

        Args:
            comment (string): Comment to be added to the column.

        Returns:
            mysqlx.ColumnDefBase: ColumnDefBase object.
        r�r�s  rrvzColumnDefBase.comment�rPrc��d|_|S)ztSets the Column as a Primary Key.

        Returns:
            mysqlx.ColumnDefBase: ColumnDefBase object.
        T)r�rFs r�primaryzColumnDefBase.primary�s������rc��||_yr�r��rrHs  rr�zColumnDefBase.set_schema��
��%��rN)
rrrrOrr�r�rvr�r�rrrr�r��s%������
��&rr�c�l��eZdZdZd�fd�	Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Z�xZS)�	ColumnDefz�Class containing the complete definition of the Column.

    Args:
        name (string): Name of the column.
        type (MySQL.ColumnType): Type of the column.
        size (int): Size of the column.
    c����tt|�|||�d|_d|_d|_d|_d|_d|_d|_	g|_
g|_d|_d|_
yr�)rUr�r�_ref�_default�	_decimals�
_ref_table�_binaryrn�	_unsignedr��_ref_fieldsrdre)rr�r�r�ras    �rrzColumnDef.__init__�sd���
�i��'��d�D�9���	���
������������������������
���rc��d}|jrytj|j�s>tj|j�stj
|j�rdj
|j�}n�tj|j�r7|jr+dj
|j|jxsd�}nItj|j�r*dj
dj|j��}|jrdj
|�}|jrdj
|�}|jrdj
||j�}|jrd	j
||j�}d
j
tj |j�|�S)Nr�z({0})z
({0}, {1})rrhz{0} UNSIGNEDz
{0} BINARYz{0} CHARACTER SET {1}z{0} COLLATE {1}�{0} {1})r�r
�
is_numericr��is_char�	is_binaryr,�is_decimalsr��
is_finite_setr1r�r�r�rdre�	to_string)r�type_defs  r�
_data_typezColumnDef._data_type�sB�����:�:�:�0�0����<����t�z�z�*�j�.B�.B�4�:�:�.N��~�~�d�j�j�1�H�
�
#�
#�D�J�J�
/�D�J�J�#�*�*�4�:�:�t�~�~�7J��K�H�
�
%�
%�d�j�j�
1��~�~�c�h�h�t�|�|�&<�=�H��>�>�%�,�,�X�6�H��<�<�#�*�*�8�4�H��=�=�.�5�5�h��
�
�N�H��?�?�(�/�/��$�/�/�J�H����
� 4� 4�T�Z�Z� @�(�K�Krc�f�|jrdnd}|jrdnd}|jrdnd}|jrdnd}dj	|j�||||�}|jrdj	|�}n|jrd	j	|�}|jra|jrUtt|j|j��}d
j	||dj|j��}|j	|j|j��S)
Nz	 NOT NULLz NULLz AUTO_INCREMENTr�z DEFAULT {default}z COMMENT '{comment}'z{0}{1}{2}{3}{4}z{0} PRIMARY KEYz{0} UNIQUE KEYz{0} REFERENCES {1} ({2})rh)�defaultrv)r�rnr�rfr,r�r�r�r�r�r3r<r�r1)r�null�auto_incr�rv�defn�	ref_tables       r�_col_definitionzColumnDef._col_definition�s���"�n�n�{�'��(,���$�B��*.�-�-�&�R��,0�M�M�(�r�� �'�'����(9�4���g����;�;�$�+�+�D�1�D�
�]�]�#�*�*�4�0�D��?�?�t�/�/�2�3C��$�$�d�o�o�47�8�I�-�4�4�T�9�����)�)�*�,�D��{�{�4�=�=�$�-�-�{�H�Hrc��t|t�r|j|_|S|�	d|_|St	|�|_|S)z�Sets the default value of this Column.

        Args:
            default_val (object): The default value of the Column. Can be a
            string, number or :class`MySQLx.Expr`.

        Returns:
            mysqlx.ColumnDef: ColumnDef object.
        �NULL)rrrr��repr)r�default_vals  r�set_defaultzColumnDef.set_defaultsK���k�4�(�'�,�,�D�M����
 �"�D�M���!��-�D�M��rc��d|_|S)zlSet the Column to Auto Increment.

        Returns:
            mysqlx.ColumnDef: ColumnDef object.
        Tr�rFs r�auto_incrementzColumnDef.auto_incrementr�rc�.�t|�|_||_|S)z�Sets the Column as a Foreign Key.

        Args:
            name (string): Name of the referenced Table.
            *refs: Fields this Column references.

        Returns:
            mysqlx.ColumnDef: ColumnDef object.
        )r!r�r��rr��refss   r�foreign_keyzColumnDef.foreign_key$s��+�D�1�������rc��d|_|S)zfSet the Column as unsigned.

        Returns:
            mysqlx.ColumnDef: ColumnDef object.
        T)r�rFs r�unsignedzColumnDef.unsigned2r�rc��||_|S)z�Set the size of the decimal Column.

        Args:
            size (int): Size of the decimal.

        Returns:
            mysqlx.ColumnDef: ColumnDef object.
        )r�)rr�s  r�decimalszColumnDef.decimals;s������rc��||_|S)z�Set the Charset type of the Column.

        Args:
            charset (string): Charset type.

        Returns:
            mysqlx.ColumnDef: ColumnDef object.
        r�r�s  rrtzColumnDef.charsetGrPrc��||_|S)z�Set the Collation type of the Column.

        Args:
            collation (string): Collation type.

        Returns:
            mysqlx.ColumnDef: ColumnDef object.
        r�r�s  rruzColumnDef.collationSrKrc��d|_|S)zqSet the current column to binary type.

        Returns:
            mysqlx.ColumnDef: ColumnDef object.
        T)r�rFs r�binaryzColumnDef.binary_�������rc�<�ttt|��|_|S)z�Set the Enum/Set values.

        Args:
            *values: Values for Enum/Set type Column.

        Returns:
            mysqlx.ColumnDef: ColumnDef object.
        )�mapr�r!r�rs  rr zColumnDef.valueshs���4��&�!9�:����rc�V�dj|j|j��S)Nr�)r,r1r�rFs rrzColumnDef.get_sqlts"������
�
�D�,@�,@�,B�C�Crr)rrrrOrr�r�r�r�r�r�r�rtrur�r rr�r�s@rr�r��sL�����"L�*I�*�&���
�
�
��
�Drr�c�2��eZdZdZ�fd�Zd�Z�fd�Z�xZS)�GeneratedColumnDefz�Class used to describe a Generated Column.

    Args:
        name: Name of the column.
        col_type: Type of the column.
        expr: The Expression used to generate the value of this column.
    c���tt|�||�t|t�sJ�d|_|j|_yr�)rUr�rrr�_storedr�_expr)rr��col_typerras    �rrzGeneratedColumnDef.__init__�s7���
� �$�0��x�@��$��%�%�%�����Y�Y��
rc��d|_|S)z�Set the Generated Column to be stored.

        Returns:
            mysqlx.GeneratedColumnDef: GeneratedColumnDef object.
        T)r�rFs r�storedzGeneratedColumnDef.stored�r�rc���djtt|��|j|j
rd�Sd�S)Nz {0} GENERATED ALWAYS AS ({1}){2}z STOREDr�)r,rUr�rr�r�)rras �rrzGeneratedColumnDef.get_sql�s@���1�8�8��$�d�3�5��J�J�T�\�\�	�;�	;�79�;�	;r)rrrrOrr�rr�r�s@rr�r�xs������;�;rr�c�V�eZdZdZdZdZdZdZd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zy)�
ForeignKeyDefzClass describing a Foreign Key.rr���c���g|_g|_d|_d|_d|_|jtj�|_|jtj�|_	yr)
r�	_f_fieldsr1�_f_tabler��_actionr�	NO_ACTION�_update_action�_delete_actionrFs rrzForeignKeyDef.__init__�sT����������
���
�#���"�l�l�=�+B�+B�C���"�l�l�=�+B�+B�C��rc�v�|tjury|tjury|tjuryy)N�RESTRICT�CASCADEzSET NULLz	NO ACTION)rrr
�SET_NULL�r�actions  rrzForeignKeyDef._action�s8���]�+�+�+��
�}�,�,�
,��
�}�-�-�
-��rc��||_yr)r1)rr�s  rr�zForeignKeyDef.set_name�s	����
rc��||_yrr�r�s  rr�zForeignKeyDef.set_schema�r�rc� �t|�|_|S)z�Add a list of fields in the parent table.

        Args:
            *fields: Fields in the given table which constitute the Foreign Key.

        Returns:
            mysqlx.ForeignKeyDef: ForeignKeyDef object.
        )r!rrls  rrmzForeignKeyDef.fields�s��'��/����rc�.�t|�|_||_|S)z�Add the child table name and the fields.

        Args:
            name (string): Name of the referenced table.
            *refs: A list fields in the referenced table.

        Returns:
            mysqlx.ForeignKeyDef: ForeignKeyDef object.
        )r!rrr�s   r�	refers_tozForeignKeyDef.refers_to�s��)�$�/�����
��rc�2�|j|�|_|S)a�Define the action on updating a Foreign Key.

        Args:
            action (int): Action to be performed on updating the reference.
                          Can be any of the following values:
                          1. ForeignKeyDef.NO_ACTION
                          2. ForeignKeyDef.RESTRICT
                          3. ForeignKeyDef.CASCADE
                          4. ForeignKeyDef.SET_NULL

        Returns:
            mysqlx.ForeignKeyDef: ForeignKeyDef object.
        )rr	rs  r�	on_updatezForeignKeyDef.on_update�s��#�l�l�6�2����rc�2�|j|�|_|S)a�Define the action on deleting a Foreign Key.

        Args:
            action (int): Action to be performed on updating the reference.
                          Can be any of the following values:
                          1. ForeignKeyDef.NO_ACTION
                          2. ForeignKeyDef.RESTRICT
                          3. ForeignKeyDef.CASCADE
                          4. ForeignKeyDef.SET_NULL

        Returns:
            mysqlx.ForeignKeyDef: ForeignKeyDef object.
        )rr
rs  r�	on_deletezForeignKeyDef.on_delete�s��#�l�l�6�2����rc
��dj|j�}dj|j�}dj|jdj	|j
�t
t|j|j��dj	|j��}dj|||�S)Nz
ON UPDATE {0}z
ON DELETE {0}z)FOREIGN KEY {0}({1}) REFERENCES {2} ({3})rhz{0} {1} {2})r,r	r
r1r1rr3r<r�rr)rr�rr�s    rrzForeignKeyDef.get_sql�s��� �'�'��(;�(;�<�� �'�'��(;�(;�<��9�@�@��J�J�������.�0J��T�1�1�4�=�=�A�1C��H�H�T�^�^�$�&���#�#�C���8�8rN)rrrrOrrr
rrrr�r�rmrrrrrrrrr�sG��)��I��H��G��H�D���&�
���$�"9rr)r�)2rOr�r��errorsrrr�compatr�	constantsrr�dbdocr	�protobufr
r��resultrrr
r�rr!r*r.r3r<r>rRr�r�r�r�r�r�rr
rrrr*r/r:r^rbr�r�r�rrrr�<module>r!s|��0$��	�$�� �-��3�1�1��6��
�>�"=�(5�$�"��"�DC"�)�C"�L+�9�+�,'2�9�'2�T���&b-�)�b-�J9+�'�9+�x=�)�=�~2�i�2�B-�)�-�D-�)�-�$-�)�-�,'&�Y�'&�TK�9�K�,
@��
@� t�)�t�n�,��Bl1�9�l1�^:&�F�:&�zpD�
�pD�f;��;�:c9�F�c9r
© 2025 GrazzMean