HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/site-packages/mysqlx/__pycache__/statement.cpython-311.pyc
�

�nc���^�dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZddl
mZdd	lmZdd
lmZdZGd�d
��Zd�Zd2d�Zd2d�Zd2d�Zd2d�ZGd�d��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�d��ZGd �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(dS)3zImplementation of Statements.�N�)�LockContention)�DbDoc)�NotSupportedError�ProgrammingError)�
ExprParser)�
deprecated)�
mysqlxpb_enum)�Resultz&The given index name "{}" is not validc��eZdZdZd�ZdS)�ExprzExpression wrapper.c��||_dS�N)�expr)�selfrs  �2D:\Python311\Lib\site-packages\mysqlx/statement.py�__init__z
Expr.__init__1s
����	�	�	�N)�__name__�
__module__�__qualname__�__doc__r�rrr
r
.s)������������rr
c��t|��dkr*t|dttf��r|dS|S)zParse flexible parameters.rr)�len�
isinstance�list�tuple)�valuess r�flexible_paramsr 5s=��
�6�{�{�a���J�v�a�y�4��-�@�@���a�y���Mr�c��d|vr0|ddkr|ddkp|ddko|ddkS|ddko|ddkS)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)<sn���� �
��1�
��$�>��B��3�)>�
��q�M�S� �:�Z��^�s�%:�	
��a�=�C��9�J�r�N�c�$9�9rc��t|��dkrdSd|vr|�dd��}d|�d�S|�dd��}d|�d�S)a@Quote the given identifier with backticks, converting backticks (`) in
    the identifier name with the correct escape sequence (``).

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

    Returns:
        A string with the identifier quoted with backticks.
    rz``r#r&z""r$)r�replace)r'r(�quoteds   r�quote_identifierr-Mso���:���!����t��� ���#�#�C��.�.���6�}�}�}��
�
�
��T�
*�
*�F��v�=�=�=�rc�F��d��fd�|D����S)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.
    �.c�0��g|]}t|�����Sr)r-)�.0r'r(s  �r�
<listcomp>z.quote_multipart_identifier.<locals>.<listcomp>ls$���N�N�N�J�	�*�h�	/�	/�N�N�Nr)�join)�identifiersr(s `r�quote_multipart_identifierr5as2����8�8�N�N�N�N�+�N�N�N���rc���d|vrdnd}||vrd|��nd}|�|d��}t|��dkr|n|d�|��|d�|��fS)z�Parse table name.

    Args:
        default_schema (str): The default schema.
        table_name (str): The table name.
        sql_mode(Optional[str]): The SQL mode.

    Returns:
        str: The parsed table name.
    r#r&r$r/rrr%)�splitr�strip)�default_schema�
table_namer(�quote�	delimiter�temps      r�parse_table_namer>ps���!�H�,�5�C�C�#�E�$�
�2�;��E�����I����I�q�)�)�D��d�)�)�q�.�B���d�1�g�m�m�E�.B�.B��R����u����rc�b�eZdZdZdd�Zed���Zed���Zed���Zej	d���Zed���Z
ed	���Zej	d
���Zed���Zej	d���Zed
���Z
ed���Zej	d���Zd�Zd�Zd�Zd�ZdS)�	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.
    Tc��||_||_|r|���nd|_d|_d|_d|_d|_d|_dS)NrTF)	�_target�
_doc_based�get_connection�_connection�_stmt_id�
_exec_counter�_changed�	_prepared�_deallocate_prepare_execute)r�target�	doc_baseds   rrzStatement.__init__�sY�����#���6<�F�6�0�0�2�2�2�$�����
������
����+0��(�(�(rc��|jS)z#object: The database object target.)rB�rs rrKzStatement.target�s���|�rc��|jjS)z*:class:`mysqlx.Schema`: The Schema object.)rB�schemarNs rrPzStatement.schema�s���|�"�"rc��|jS)zXReturns this statement ID.

        Returns:
            int: The statement ID.
        �rFrNs r�stmt_idzStatement.stmt_id�s���}�rc��||_dSrrR�r�values  rrSzStatement.stmt_id��
����
�
�
rc��|jS)z5int: The number of times this statement was executed.�rGrNs r�exec_counterzStatement.exec_counter�s
���!�!rc��|jS)z+bool: `True` if this statement has changes.�rHrNs r�changedzStatement.changed�s���}�rc��||_dSrr\rUs  rr]zStatement.changed�rWrc��|jS)z1bool: `True` if this statement has been prepared.�rIrNs r�preparedzStatement.prepared�s���~�rc��||_dSrr`rUs  rrazStatement.prepared�s
������rc��|jdkS)z;bool: `True` if this statement was executed more than once.rrYrNs r�repeatedzStatement.repeated�s���!�A�%�%rc��|jS)z9bool: `True` to deallocate + prepare + execute statement.�rJrNs r�deallocate_prepare_executez$Statement.deallocate_prepare_execute�s
���/�/rc��||_dSrrfrUs  rrgz$Statement.deallocate_prepare_execute�s��+0��(�(�(rc��|jS)zkCheck if it is document based.

        Returns:
            bool: `True` if it is document based.
        )rCrNs r�is_doc_basedzStatement.is_doc_based������rc�&�|xjdz
c_dS)z@Increments the number of times this statement has been executed.rNrYrNs r�increment_exec_counterz Statement.increment_exec_counter�s�����a�����rc��d|_dS)z<Resets the number of times this statement has been executed.rNrYrNs r�reset_exec_counterzStatement.reset_exec_counter�s������rc��t��zqExecute the statement.

        Raises:
           NotImplementedError: This method must be implemented.
        ��NotImplementedErrorrNs r�executezStatement.execute��
��"�!rN�T)rrrrr�propertyrKrPrS�setterrZr]rardrgrjrmrortrrrr@r@�s���������1�1�1�1�����X���#�#��X�#�����X��
�^����^���"�"��X�"�����X��
�^����^������X���_����_���&�&��X�&��0�0��X�0� �&�1�1�'�&�1���� � � ����"�"�"�"�"rr@c����eZdZdZd�fd�	Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zed��d���Zed��d���Zdd�Zd�Zd�Zd�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.
    TNc���t���||���i|_i|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_d|_d|_d|_d|_|r|�|��dSdS)N�rKrLr!rF)�superr�_binding_map�	_bindings�_having�
_grouping_str�	_grouping�
_limit_offset�_limit_row_count�_projection_str�_projection_expr�	_sort_str�
_sort_expr�
_where_str�_where_expr�has_bindings�	has_limit�has_group_by�
has_having�has_projection�has_sort�	has_where�
_set_where�rrKrL�	condition�	__class__s    �rrzFilterableStatement.__init__�s����
������)��<�<�<������������������� $���!��� $���������������!������!������#�����
�����	'��O�O�I�&�&�&�&�&�	'�	'rc�n�t|t��r6|�t|�������dSt|t��r)|�|�����dSt|t
��r�	t
j|��}t|t��st�n"#t$r}td��|�d}~wwxYw|�
��D]}|�|||���dStd���)aBind single object.

        Args:
            obj (:class:`mysqlx.DbDoc` or str): DbDoc or JSON string object.

        Raises:
            :class:`mysqlx.ProgrammingError`: If invalid JSON string to bind.
            ValueError: If JSON loaded is not a dictionary.
        zInvalid JSON string to bindNz%Invalid JSON string or object to bind)r�dict�bindr�as_str�str�json�loads�
ValueErrorr�keys)r�obj�res�err�keys     r�_bind_singlez FilterableStatement._bind_singles8���c�4� � �	L��I�I�e�C�j�j�'�'�)�)�*�*�*�*�*�
��U�
#�
#�	L��I�I�c�j�j�l�l�#�#�#�#�#�
��S�
!�
!�
	L�
O��j��o�o��!�#�t�,�,�%�$�$�%���
O�
O�
O�&�'D�E�E�3�N�����
O�����x�x�z�z�
)�
)���	�	�#�s�3�x�(�(�(�(�
)�
)�#�#J�K�K�Ks� 0C�
C0�C+�+C0c���d|_d�t|���|_t	|j|j�����|_d|_|S)z�Sets the sorting criteria.

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

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.
        T�,)	r�r3r r�rrC�parse_order_specr�rH�r�clausess  r�_sortzFilterableStatement._sort+s]����
����/�7�";�<�<���$��N���/�
�
�
�
�
�
�	
����
��rc���d|_||_	t||j��}|���|_n"#t$r}td��|�d}~wwxYw|j|_	d|_
|S)aSets the search condition to filter.

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

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.
        TzInvalid conditionN)r�r�rrCrr�r�r�placeholder_name_to_positionr~rH)rr�rr�s    rr�zFilterableStatement._set_where<s������#���	A��i�T�_�)<�=�=�D�#�y�y�{�{�D�����	A�	A�	A�"�#6�7�7�S�@�����	A���� �=�����
��s�/A�
A�
A�Ac���t|�}d|_d�|��|_t	|j|j�����|_d|_dS)zJSet group by.

        Args:
            *fields: List of fields.
        Tr�N)	r r�r3r�rrC�parse_expr_listr�rH�r�fieldss  r�
_set_group_byz!FilterableStatement._set_group_byQsc��!�&�)�� ��� �X�X�f�-�-���#���D�O� 3�
�
�
�/�
�
�	
����
�
�
rc�|�d|_t||j�����|_d|_dS)zOSet having.

        Args:
            condition (str): The condition.
        TN)r�rrCrr�rH�rr�s  r�_set_havingzFilterableStatement._set_having_s8�����!�)���-@�A�A�F�F�H�H�����
�
�
rc���t|�}d|_d�|��|_t	|j|j�����|_d|_|S)z�Set the projection.

        Args:
            *fields: List of fields.

        Returns:
            :class:`mysqlx.FilterableStatement`: Returns self.
        Tr�)	r r�r3r�rrC�parse_table_select_projectionr�rHr�s  r�_set_projectionz#FilterableStatement._set_projectionisf��!�&�)��"���"�x�x��/�/��� *�� �d�o�"5�!
�!
�
'�
'�
)�
)�	
����
��rc��|jS�zlReturns the binding map dictionary.

        Returns:
            dict: The binding map dictionary.
        �r~rNs r�get_binding_mapz#FilterableStatement.get_binding_map{�
��� � rc��|jS�z\Returns the bindings list.

        Returns:
            `list`: The bindings list.
        �rrNs r�get_bindingsz FilterableStatement.get_bindings�����~�rc��|jS)zrReturns the grouping expression list.

        Returns:
            `list`: The grouping expression list.
        )r�rNs r�get_groupingz FilterableStatement.get_grouping�r�rc��|jS)zdReturns the having expression.

        Returns:
            object: The having expression.
        )r�rNs r�
get_havingzFilterableStatement.get_having�����|�rc��|jS)z]Returns the limit row count.

        Returns:
            int: The limit row count.
        )r�rNs r�get_limit_row_countz'FilterableStatement.get_limit_row_count��
���$�$rc��|jS)zWReturns the limit offset.

        Returns:
            int: The limit offset.
        )r�rNs r�get_limit_offsetz$FilterableStatement.get_limit_offset�s
���!�!rc��|jS)zbReturns the where expression.

        Returns:
            object: The where expression.
        )r�rNs r�get_where_exprz"FilterableStatement.get_where_expr��
����rc��|jS)zlReturns the projection expression.

        Returns:
            object: The projection expression.
        )r�rNs r�get_projection_exprz'FilterableStatement.get_projection_expr�r�rc��|jS)z`Returns the sort expression.

        Returns:
            object: The sort expression.
        )r�rNs r�
get_sort_exprz!FilterableStatement.get_sort_expr�rkr�8.0.12c�,�|�|��S)a&Sets the search condition to filter.

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

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.

        .. deprecated:: 8.0.12
        �r�r�s  r�wherezFilterableStatement.where�s�����y�)�)�)rc��|j|�S)z�Sets the sorting criteria.

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

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.

        .. deprecated:: 8.0.12
        �r�r�s  r�sortzFilterableStatement.sort�s���t�z�7�#�#rc�^�t|t��r|dkrtd���|js;t	|jdk��|_t	|jdk��|_||_d|_|r0|�	|��tjdt���|S)a�Sets the maximum number of items to be returned.

        Args:
            row_count (int): The maximum number of items.

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.

        Raises:
            ValueError: If ``row_count`` is not a positive integer.

        .. versionchanged:: 8.0.12
           The usage of ``offset`` was deprecated.
        rz0The 'row_count' value must be a positive integerTzh'limit(row_count, offset)' is deprecated, please use 'offset(offset)' to set the number of items to skip)�category)
r�intr�r��boolrGrHrJr��offset�warnings�warn�DeprecationWarning)r�	row_countr�s   r�limitzFilterableStatement.limit�s����)�S�)�)�	Q�Y��]�	Q��O�P�P�P��~�	Q� ��!3�q�!8�9�9�D�M�/3��8J�a�8O�4O�/P�/P�D�,� )�������	��K�K������M��,�	
�
�
�
��rc�h�t|t��r|dkrtd���||_|S)a:Sets the number of items to skip.

        Args:
            offset (int): The number of items to skip.

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.

        Raises:
            ValueError: If ``offset`` is not a positive integer.

        .. versionadded:: 8.0.12
        rz-The 'offset' value must be a positive integer)rr�r�r�)rr�s  rr�zFilterableStatement.offsets?���&�#�&�&�	N�&�1�*�	N��L�M�M�M�#����rc���d|_t|��}|dkr|�|d��n,|dkr|d|j|d<nt	d���|S)a�Binds value(s) to a specific placeholder(s).

        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��#Invalid number of arguments to bind)r�rr�rr)r�args�counts   rr�zFilterableStatement.bindsw��!����D�	�	���A�:�	J����d�1�g�&�&�&�&�
�a�Z�	J�&*�1�g�D�N�4��7�#�#�"�#H�I�I�I��rc��t�rqrrrNs rrtzFilterableStatement.execute,rur�TNr)rrrrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r	r�r�r�r�r�rt�
__classcell__�r�s@rrzrz�s��������	�	�'�'�'�'�'�'�2L�L�L�4���"���*���������$!�!�!����������%�%�%�"�"�"� � � �%�%�%�����Z����*�*���*��Z����$�$���$�����B���&���0"�"�"�"�"�"�"rrzc�P��eZdZdZ�fd�Zed���Zd�Zd�Zd�Z	d�Z
�xZS)�SqlStatementz�A statement for SQL execution.

    Args:
        connection (mysqlx.connection.Connection): Connection object.
        sql (string): The sql statement to be executed.
    c���t���dd���||_||_d|_g|_d|_d|_dS�NFr|)r}rrE�_sqlr~rr�r�)r�
connection�sqlr�s   �rrzSqlStatement.__init__=sQ���
��������6�6�6�%�����	� ������!�������rc��|jS)zstring: The SQL text statement.)r�rNs rr�zSqlStatement.sqlFs���y�rc��|jSr�r�rNs rr�zSqlStatement.get_binding_mapKr�rc��|jSr�r�rNs rr�zSqlStatement.get_bindingsSr�rc���t|��dkrtd���d|_t|�}t	|t
tf��r||_n|j�|��|S)z�Binds value(s) to a specific placeholder(s).

        Args:
            *args: The value(s) to bind.

        Returns:
            mysqlx.SqlStatement: SqlStatement object.
        rr�T)	rrr�r rrrr�append)rr��bindingss   rr�zSqlStatement.bind[sr���t�9�9��>�	J�"�#H�I�I�I� ���"�D�)���h��u�
�.�.�	,�%�D�N�N��N�!�!�(�+�+�+��rc�6�|j�|��S)zaExecute the statement.

        Returns:
            mysqlx.SqlResult: SqlResult object.
        )rE�send_sqlrNs rrtzSqlStatement.executens����(�(��.�.�.r)rrrrrrwr�r�r�r�rtr�r�s@rr�r�5s�������������������X��!�!�!�������&/�/�/�/�/�/�/rr�c�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�WriteStatementz*Provide common write operation attributes.c�Z��t���||��g|_dSr)r}r�_values)rrKrLr�s   �rrzWriteStatement.__init__zs(���
�������+�+�+�����rc��|jS)z^Returns the list of values.

        Returns:
            `list`: The list of values.
        )r�rNs r�
get_valueszWriteStatement.get_values~r�rc��t�rqrrrNs rrtzWriteStatement.execute�rur)rrrrrrrtr�r�s@rr�r�ws\�������4�4���������"�"�"�"�"�"�"rr�c�<��eZdZdZ�fd�Zd�Zdd�Zd�Zd�Z�xZ	S)	�AddStatementz�A statement for document addition on a collection.

    Args:
        collection (mysqlx.Collection): The Collection object.
    c�h��t���|d��d|_g|_dS)NTF)r}r�_upsert�ids)r�
collectionr�s  �rrzAddStatement.__init__�s/���
������T�*�*�*��������rc��|jS)zhReturns `True` if it's an upsert.

        Returns:
            bool: `True` if it's an upsert.
        �rrNs r�	is_upsertzAddStatement.is_upsert�r�rTc��||_|S)z�Sets the upset flag to the boolean of the value provided.
        Setting of this flag allows updating of the matched rows/documents
        with the provided value.

        Args:
            value (optional[bool]): Set or unset the upsert flag.
        r
rUs  r�upsertzAddStatement.upsert�s������rc���t|�D]Y}t|t��r|j�|���2|j�t|�����Z|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 rrr�r�)rr�vals   r�addzAddStatement.add�sg��#�F�+�	0�	0�C��#�u�%�%�
0���#�#�C�(�(�(�(���#�#�E�#�J�J�/�/�/�/��rc��t|j��dkrt��S|j�|��S)�[Execute the statement.

        Returns:
            mysqlx.Result: Result object.
        r)rr�rrE�send_insertrNs rrtzAddStatement.execute�s;���t�|����!�	��8�8�O���+�+�D�1�1�1rrv)
rrrrrrr
rrtr�r�s@rrr�s���������������
���	�	�	�	���� 	2�	2�	2�	2�	2�	2�	2rrc� �eZdZdZdd�Zd�ZdS)�
UpdateSpecz�Update specification class implementation.

    Args:
        update_type (int): The update type.
        source (str): The source.
        value (Optional[str]): The value.

    Raises:
        ProgrammingError: If `source` is invalid.
    Nc��|td��kr|�||��dS||_	t|d�����j|_n##t$r}t|���|�d}~wwxYw||_	dS)N�*Mysqlx.Crud.UpdateOperation.UpdateType.SETF)
r
�
_table_set�update_typer�document_fieldr'�sourcer�rrV)rrrrVr�s     rrzUpdateSpec.__init__�s����-�(T�U�U�U�	��O�O�F�E�*�*�*�*�*�*�D��
:�(���7�7�F�F�H�H�S������
:�
:�
:�&�#�x�0�0�c�9�����
:�����D�J�J�Js�,A!�!
B�+A<�<Bc��td��|_t|d�����|_||_dS)zlTable set.

        Args:
            source (str): The source.
            value (str): The value.
        rTN)r
rr�parse_table_update_fieldrrV)rrrVs   rrzUpdateSpec._table_set�s=��)�)U�V�V��� ���.�.�G�G�I�I�����
�
�
rr)rrrrrrrrrrr�sA������	�	�	�	�	�	�	�	�	�	�	rrc�z��eZdZdZ�fd�Zd�Zd�Zd�Zed��d���Z	d�Z
d	�Zd
�Zd�Z
d�Z�xZS)
�ModifyStatementaUA statement for document update operations on a Collection.

    Args:
        collection (mysqlx.Collection): The Collection object.
        condition (str): Sets the search condition to identify the documents
                         to be modified.

    .. versionchanged:: 8.0.12
       The ``condition`` parameter is now mandatory.
    c�\��t���||���i|_dS�N)rKr��r}r�_update_ops�rrr�r�s   �rrzModifyStatement.__init__�s.���
�����
�i��@�@�@�����rc��|j|�S)z�Sets the sorting criteria.

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

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.
        r�r�s  rr�zModifyStatement.sort�����t�z�7�#�#rc��|jS�ztReturns the list of update operations.

        Returns:
            `list`: The list of update operations.
        �r#rNs r�get_update_opszModifyStatement.get_update_opsr�rc�`�ttd��||��|j|<d|_|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.
        z/Mysqlx.Crud.UpdateOperation.UpdateType.ITEM_SETT�rr
r#rH�r�doc_pathrVs   r�setzModifyStatement.sets;��&0��K�L�L���&
�&
����"�
��
��rr�c�`�ttd��||��|j|<d|_|S)a�Add 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.

        .. deprecated:: 8.0.12
        z3Mysqlx.Crud.UpdateOperation.UpdateType.ITEM_REPLACETr,r-s   r�changezModifyStatement.change"s;��&0��O�P�P���&
�&
����"�
��
��rc�v�t|�D]'}ttd��|��|j|<�(d|_|S)aRemoves attributes from documents in a collection.

        Args:
            doc_paths (list): The list of document paths of the attributes to be
                              removed.

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.
        z2Mysqlx.Crud.UpdateOperation.UpdateType.ITEM_REMOVET)r rr
r#rH)r�	doc_paths�items   r�unsetzModifyStatement.unset8sO��$�Y�/�	�	�D�%/��R�S�S��&�&�D��T�"�"���
��rc�`�ttd��||��|j|<d|_|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.
        z3Mysqlx.Crud.UpdateOperation.UpdateType.ARRAY_INSERTTr,�r�fieldrVs   r�array_insertzModifyStatement.array_insertJs;��#-��O�P�P���#
�#
�����
��
��rc�`�ttd��||��|j|<d|_|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.
        z3Mysqlx.Crud.UpdateOperation.UpdateType.ARRAY_APPENDTr,r-s   r�array_appendzModifyStatement.array_append^s;��&0��O�P�P���&
�&
����"�
��
��rc�(�|�d}t|ttttf��std���t
td��dt|t��r|���n|��|j	d<d|_
|S)a�Takes a :class:`mysqlx.DbDoc`, string JSON format or a dict with the
        changes and applies it on all matching documents.

        Args:
            doc (object): A generic document (DbDoc), string in JSON format or
                          dict, with the changes to apply to the matching
                          documents.

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.
        Nr!z>Invalid data for update operation on document collection tablez2Mysqlx.Crud.UpdateOperation.UpdateType.MERGE_PATCH�$�patchT)rrr�rr�rrr
rr#rH)r�docs  rr>zModifyStatement.patchss����	��C��#�
�D�%��=�>�>�	�"�P���
�%/��N�O�O��$�S�*�5�5�>�C�H�H�J�J�J�3�%
�%
����!�
��
��rc�b�|jstd���|j�|��S)��Execute the statement.

        Returns:
            mysqlx.Result: Result object.

        Raises:
            ProgrammingError: If condition was not set.
        z!No condition was found for modify�r�rrE�send_updaterNs rrtzModifyStatement.execute��5���~�	H�"�#F�G�G�G���+�+�D�1�1�1r)rrrrrr�r*r/r	r1r5r9r;r>rtr�r�s@rrr�s��������	�	������	$�	$�	$� � � ����$�Z���������*���$���(���*���42�2�2�2�2�2�2rrc���eZdZdZd�fd�	Zed���Zd�Zd�Zd�Z	e
jfd	�Ze
jfd
�Z
d�Zd�Zd
�Z�xZS)�
ReadStatementa�Provide base functionality for Read operations

    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.
    TNc���t���|||��d|_d|_tj|_dS�NF)r}r�_lock_exclusive�_lock_sharedr�DEFAULT�_lock_contentionr�s    �rrzReadStatement.__init__�s@���
�������I�6�6�6�$���!��� .� 6����rc��|jS)z::class:`mysqlx.LockContention`: The lock contention value.)rLrNs r�lock_contentionzReadStatement.lock_contention�s
���$�$rc��	t|j��}n"#t$r}td��|�d}~wwxYw||_dS)z�Set the lock contention.

        Args:
            lock_contention (:class:`mysqlx.LockContention`): Lock contention.

        Raises:
            ProgrammingError: If is an invalid lock contention value.
        z;Invalid lock contention mode. Use 'NOWAIT' or 'SKIP_LOCKED'N)rrVr�rrL)rrN�_r�s    r�_set_lock_contentionz"ReadStatement._set_lock_contention�s`��	���4�5�5�A�A���	�	�	�"�M����
�����	����!0����s��
6�1�6c��|jS)zrReturns `True` if is `EXCLUSIVE LOCK`.

        Returns:
            bool: `True` if is `EXCLUSIVE LOCK`.
        )rIrNs r�is_lock_exclusivezReadStatement.is_lock_exclusive�s
���#�#rc��|jS)zlReturns `True` if is `SHARED LOCK`.

        Returns:
            bool: `True` if is `SHARED LOCK`.
        )rJrNs r�is_lock_sharedzReadStatement.is_lock_shared�r�rc�L�d|_d|_|�|��|S)z�Execute a read operation with `SHARED LOCK`. Only one lock can be
           active at a time.

        Args:
            lock_contention (:class:`mysqlx.LockContention`): Lock contention.
        FT�rIrJrQ�rrNs  r�lock_sharedzReadStatement.lock_shared�s-�� %��� ����!�!�/�2�2�2��rc�L�d|_d|_|�|��|S)z�Execute a read operation with `EXCLUSIVE LOCK`. Only one lock can be
           active at a time.

        Args:
            lock_contention (:class:`mysqlx.LockContention`): Lock contention.
        TFrWrXs  r�lock_exclusivezReadStatement.lock_exclusive�s-�� $���!����!�!�/�2�2�2��rc��|j|�|S)z�Sets a grouping criteria for the resultset.

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

        Returns:
            mysqlx.ReadStatement: ReadStatement object.
        )r�r�s  r�group_byzReadStatement.group_by�s��	���F�#�#��rc�0�|�|��|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.ReadStatement: ReadStatement object.
        )r�r�s  r�havingzReadStatement.having�s��	
����#�#�#��rc�6�|j�|��S�r)rE�	send_findrNs rrtzReadStatement.executes����)�)�$�/�/�/rr�)rrrrrrwrNrQrSrUrrKrYr[r]r_rtr�r�s@rrFrF�s��������	�	�7�7�7�7�7�7��%�%��X�%�0�0�0�$$�$�$�!�!�!�+9�*@�
�
�
�
�.<�-C�
�
�
�
�
�
�
����0�0�0�0�0�0�0rrFc�0��eZdZdZd�fd�	Zd�Zd�Z�xZS)�
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.
    Nc�N��t���|d|��dS)NT�r}rr$s   �rrzFindStatement.__init__s%���
������T�9�5�5�5�5�5rc��|j|�S)z�Sets a document field filter.

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

        Returns:
            mysqlx.FindStatement: FindStatement object.
        )r�r�s  rr�zFindStatement.fieldss��$�t�#�V�,�,rc��|j|�S�z�Sets the sorting criteria.

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

        Returns:
            mysqlx.FindStatement: FindStatement object.
        r�r�s  rr�zFindStatement.sort)r&rr)rrrrrr�r�r�r�s@rrdrdse���������6�6�6�6�6�6�
-�
-�
-�	$�	$�	$�	$�	$�	$�	$rrdc�4��eZdZdZ�fd�Zd�Zd�Zd�Z�xZS)�SelectStatementz�A statement for record retrieval operations on a Table.

    Args:
        table (mysqlx.Table): The Table object.
        *fields: The fields to be retrieved.
    c�`��t���|d��|j|�dSrH)r}rr��r�tabler�r�s   �rrzSelectStatement.__init__=s3���
�������&�&�&����f�%�%�%�%rc�,�|�|��S)z�Sets the search condition to filter.

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

        Returns:
            mysqlx.SelectStatement: SelectStatement object.
        r�r�s  rr�zSelectStatement.whereA������y�)�)�)rc��|j|�S)z�Sets the order by criteria.

        Args:
            *clauses: The expression strings defining the order by criteria.

        Returns:
            mysqlx.SelectStatement: SelectStatement object.
        r�r�s  r�order_byzSelectStatement.order_byLr&rc�4�|jr
d|j��nd}|jr
d|j��nd}|jr
d|j��nd}|jr
d|j��nd}|jrd|j	�d|j
��nd}d|jpd	�d
|jj
�d|jj
�|�|�|�|�|��}|S)zYReturns the generated SQL.

        Returns:
            str: The generated SQL.
        z WHERE r!z
 GROUP BY z HAVING z
 ORDER BY z LIMIT z OFFSET zSELECT �*z FROM r/)r�r�r�r�r�r�r�r�r�r�r�r�rP�namerK)rr�r]r_rrr��stmts       r�get_sqlzSelectStatement.get_sqlWs��04�~�E�+�$�/�+�+�+�2��8<�8I�Q�4�� 2�4�4�4�r��.2�o�E�*�D�L�*�*�*�2��48�M�I�0���0�0�0�r���~�
�I�d�+�I�I�T�5G�I�I�I��	�
:�d�*�1�c�
:�
:��K�$�
:�
:�'+�{�'7�
:��
:��
:� &�
:�(0�
:�27�
:�
:�	
�
�r)	rrrrrr�rrrwr�r�s@rrkrk5so���������&�&�&�&�&�	*�	*�	*�	$�	$�	$�������rrkc�.��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�h��t���|d��t|�|_dSrH)r}rr �_fieldsrms   �rrzInsertStatement.__init__vs-���
�������&�&�&�&��/����rc�b�|j�tt|�����|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 )rrs  rrzInsertStatement.valueszs,��	
����D��&�!9�:�:�;�;�;��rc�6�|j�|��Sra)rErrNs rrtzInsertStatement.execute�s����+�+�D�1�1�1r)rrrrrrrtr�r�s@rryryns`���������0�0�0�0�0�
�
�
�2�2�2�2�2�2�2rryc�@��eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z	�xZ
S)�UpdateStatementz�A statement for record update operations on a Table.

    Args:
        table (mysqlx.Table): The Table object.

    .. versionchanged:: 8.0.12
       The ``fields`` parameters were removed.
    c�\��t���|d���i|_dSr�r"�rrnr�s  �rrzUpdateStatement.__init__�s.���
��������7�7�7�����rc�,�|�|��S)z�Sets the search condition to filter.

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

        Returns:
            mysqlx.UpdateStatement: UpdateStatement object.
        r�r�s  rr�zUpdateStatement.where�rprc��|j|�S)z�Sets the order by criteria.

        Args:
            *clauses: The expression strings defining the order by criteria.

        Returns:
            mysqlx.UpdateStatement: UpdateStatement object.
        r�r�s  rrrzUpdateStatement.order_by�r&rc��|jSr(r)rNs rr*zUpdateStatement.get_update_ops�r�rc�`�ttd��||��|j|<d|_|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.
        rTr,r7s   rr/zUpdateStatement.set�s;��#-��F�G�G���#
�#
�����
��
��rc�b�|jstd���|j�|��S)z�Execute the statement.

        Returns:
            mysqlx.Result: Result object

        Raises:
            ProgrammingError: If condition was not set.
        z!No condition was found for updaterBrNs rrtzUpdateStatement.execute�rDr)rrrrrr�rrr*r/rtr�r�s@rrr�s���������������	*�	*�	*�	$�	$�	$� � � ����$2�2�2�2�2�2�2rrc�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�RemoveStatementaEA statement for document removal from a collection.

    Args:
        collection (mysqlx.Collection): The Collection object.
        condition (str): Sets the search condition to identify the documents
                         to be removed.

    .. versionchanged:: 8.0.12
       The ``condition`` parameter was added.
    c�N��t���||���dSr!rfr$s   �rrzRemoveStatement.__init__�s&���
�����
�i��@�@�@�@�@rc��|j|�Srir�r�s  rr�zRemoveStatement.sort�r&rc�b�|jstd���|j�|��S)rAz!No condition was found for remove�r�rrE�send_deleterNs rrtzRemoveStatement.execute�rDr)rrrrrr�rtr�r�s@rr�r��se�������	�	�A�A�A�A�A�	$�	$�	$�2�2�2�2�2�2�2rr�c�4��eZdZdZ�fd�Zd�Zd�Zd�Z�xZS)�DeleteStatementz�A statement that drops a table.

    Args:
        table (mysqlx.Table): The Table object.

    .. versionchanged:: 8.0.12
       The ``condition`` parameter was removed.
    c�N��t���|d���dSr�rfr�s  �rrzDeleteStatement.__init__
s&���
��������7�7�7�7�7rc�,�|�|��S)z�Sets the search condition to filter.

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

        Returns:
            mysqlx.DeleteStatement: DeleteStatement object.
        r�r�s  rr�zDeleteStatement.whererprc��|j|�S)z�Sets the order by criteria.

        Args:
            *clauses: The expression strings defining the order by criteria.

        Returns:
            mysqlx.DeleteStatement: DeleteStatement object.
        r�r�s  rrrzDeleteStatement.order_byr&rc�b�|jstd���|j�|��S)rAz!No condition was found for deleter�rNs rrtzDeleteStatement.execute&rDr)	rrrrrr�rrrtr�r�s@rr�r�so���������8�8�8�8�8�	*�	*�	*�	$�	$�	$�2�2�2�2�2�2�2rr�c�(��eZdZdZ�fd�Zd�Z�xZS)�CreateCollectionIndexStatementa)A statement that creates an index on a collection.

    Args:
        collection (mysqlx.Collection): Collection.
        index_name (string): Index name.
        index_desc (dict): A dictionary containing the fields members that
                           constraints the index to be created. It must have
                           the form as shown in the following::

                               {"fields": [{"field": member_path,
                                            "type": member_type,
                                            "required": member_required,
                                            "collation": collation,
                                            "options": options,
                                            "srid": srid},
                                            # {... more members,
                                            #      repeated as many times
                                            #      as needed}
                                            ],
                                "type": type}
    c����t���|���tj|��|_||_|j�dg��|_dS)N)rKr�)r}r�copy�deepcopy�_index_desc�_index_name�pop�_fields_desc)rr�
index_name�
index_descr�s    �rrz'CreateCollectionIndexStatement.__init__KsY���
�����
��+�+�+��=��4�4���%��� �,�0�0��2�>�>����rc�

�|j�,tt�|j�����	t	|j��������}t|t��rF|dtd��kr,tt�|j�����nD|j
td��kr,tt�|j�����nF#ttf$r2}tt�|j����|�d}~wwxYw|j
std|j�����t|j
t��std���i}|j|d<|jj|d<|jjj|d<d|jvr|j�d��|d<nd	|d<|j�d
d��|d
<|d
rt)d���g|d
<|jrtd|j�����	|j
D�]J}i}|�d��|d<|�d��|d<|�dd��|d<|�dd��|d<t|dt*��st-d���t|dt*��st-d���|d���dkr|dstd���|d���d	kr|ddkrtd���d|vrp|d����d��s+td|d����d����|�d��|d<d|vrE|d���dkrtd���|�d��|d<d|vrE|d���dkrtd ���|�d��|d<|d
�|����Ln(#t4$r}td!|�d"|����|�d}~wwxYw|j
D]}|rtd#|������|j�d$d%d&|��S)'rN�typezMysqlx.Expr.Expr.Type.IDENTzCRequired member 'fields' not found in the given index description: z,Required member 'fields' must contain a listrurrP�INDEX�uniqueFz!Unique indexes are not supported.�
constraintzUnidentified fields: r8�member�required�arrayz'Field member 'required' must be Booleanz$Field member 'array' must be Boolean�SPATIALzQField member 'required' must be set to 'True' when index type is set to 'SPATIAL'�GEOJSONzIIndex 'type' must be set to 'SPATIAL' when field type is set to 'GEOJSON'�	collation�TEXTzCThe 'collation' member can only be used when field type is set to '�'�optionszIThe 'options' member can only be used when index type is set to 'GEOJSON'�sridzFThe 'srid' member can only be used when index type is set to 'GEOJSON'zRequired inner member z not found in constraint: zUnidentified inner fields: �mysqlx�create_collection_indexT)r�r�ERR_INVALID_INDEX_NAME�formatrr�get_messagerr�r
r�r��AttributeErrorr�r�rrBrurPr�rr��	TypeError�upper�
startswithr��KeyErrorrE�execute_nonquery)r�parsed_identr�r��
field_descr�s      rrtz&CreateCollectionIndexStatement.executeQs�����	T�"�#9�#@�#@��AQ�#R�#R�S�S�S�	�%�d�&6�7�7�<�<�>�>�J�J�L�L�L��,��-�-�	
���'�=�9V�+W�+W�W��*�.�5�5�d�6F�G�G�����
 �$�
�6S�(T�(T�T��*�.�5�5�d�6F�G�G�������N�+�	�	�	�"�&�-�-�d�.>�?�?����
�����	����� �	�"�3� $� 0�3�3���
�
�$�+�T�2�2�	S�"�#Q�R�R�R����'��V��!�\�.��\����,�1��X���T�%�%�	#��+�/�/��7�7�D��L�L�"�D��L��)�-�-�h��>�>��X����>�	I�#�$G�H�H�H���\����	O�"�#M�4�;K�#M�#M�N�N�N�1	�"�/�,
6�,
6�
��
�'1�~�~�g�'>�'>�
�8�$�%/�^�^�F�%;�%;�
�6�"�)3���
�E�)J�)J�
�:�&�&0�n�n�W�e�&D�&D�
�7�#�!�*�Z�"8�$�?�?�O�#�$M�N�N�N�!�*�W�"5�t�<�<�L�#�$J�K�K�K���<�%�%�'�'�9�4��Z�
�=S��*�9������<�%�%�'�'�7�2��z�&�7I�Y�7V��*�3�����*�,�J�%�f�-�3�3�5�5�@�@��H�H��.�>� *�6� 2� 8� 8� :� :�>�>�>����
/9�n�n�[�.I�.I�J�{�+��
�*�F�!�&�)�/�/�1�1�Y�>��.�=����-7�N�N�9�,E�,E�J�y�)��Z�'�@�!�&�)�/�/�1�1�Y�>��.�7����*4����)?�)?�J�v�&��\�"�)�)�*�5�5�5�5�Y,
6��Z�	�	�	�"�T��T�T�
�T�T����
�����	����
�+�	S�	S�J��
S�&�'Q�Z�'Q�'Q�R�R�R�
S���0�0��/��t�
�
�	
s1�CD
�
E�-E�E�IR"�"
S�,S�S)rrrrrrtr�r�s@rr�r�4sX���������,?�?�?�?�?�q
�q
�q
�q
�q
�q
�q
rr�)r!))rr�r�r��	constantsr�dbdocr�errorsrrrr�helpersr	�protobufr
�resultrr�r
r r)r-r5r>r@rzr�r�rrrrFrdrkryrr�r�r�rrr�<module>r�s���:$�#�������������%�%�%�%�%�%�������7�7�7�7�7�7�7�7�������������#�#�#�#�#�#�������A�������������:�:�:�:�"����(��������(e"�e"�e"�e"�e"�e"�e"�e"�PF"�F"�F"�F"�F"�)�F"�F"�F"�R
?/�?/�?/�?/�?/�9�?/�?/�?/�D"�"�"�"�"�Y�"�"�"�082�82�82�82�82�>�82�82�82�v � � � � � � � �Fk2�k2�k2�k2�k2�)�k2�k2�k2�\q0�q0�q0�q0�q0�'�q0�q0�q0�h#$�#$�#$�#$�#$�M�#$�#$�#$�L6�6�6�6�6�m�6�6�6�r2�2�2�2�2�n�2�2�2�BI2�I2�I2�I2�I2�)�I2�I2�I2�X%2�%2�%2�%2�%2�)�%2�%2�%2�P.2�.2�.2�.2�.2�)�.2�.2�.2�bN
�N
�N
�N
�N
�Y�N
�N
�N
�N
�N
r