Ë
    @ØïicÃ  ã                  ór  — d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZmZmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& dZ' G d„ d«      Z(d4d„Z)d5d6d„Z*d5d7d„Z+d5d8d„Z,	 d5	 	 	 	 	 	 	 d9d„Z- G d„ d«      Z. G d„ de.«      Z/ G d„ de.«      Z0 G d„ de.«      Z1 G d„ de1«      Z2 G d „ d!«      Z3 G d"„ d#e/«      Z4 G d$„ d%e/«      Z5 G d&„ d'e5«      Z6 G d(„ d)e5«      Z7 G d*„ d+e1«      Z8 G d,„ d-e/«      Z9 G d.„ d/e/«      Z: G d0„ d1e/«      Z; G d2„ d3e.«      Z<y):zImplementation of Statements.é    )ÚannotationsN)ÚAnyÚDictÚIterableÚListÚOptionalÚTupleÚUnioné   )ÚLockContention)ÚDbDoc)ÚNotSupportedErrorÚProgrammingError)Ú
ExprParser)Ú
deprecated)Úmysqlxpb_enum)Ú	DocResultÚResultÚ	RowResultÚ	SqlResult)ÚConnectionTypeÚDatabaseTargetTypeÚMessageTypeÚProtobufMessageCextTypeÚProtobufMessageTypeÚ
SchemaTypez&The given index name "{}" is not validc                  ó   — e Zd ZdZdd„Zy)ÚExprzExpression wrapper.c                ó   — || _         y ©N)Úexpr)Úselfr!   s     úJ/var/www/html/aiagents/fe/lib/python3.12/site-packages/mysqlx/statement.pyÚ__init__zExpr.__init__?   s	   € Øˆ�	ó    N)r!   r   ÚreturnÚNone)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   © r%   r#   r   r   <   s
   „ Ùôr%   r   c                 ó^   — t        | «      dk(  rt        | d   t        t        f«      r| d   S | S )zParse flexible parameters.r   r   )ÚlenÚ
isinstanceÚlistÚtuple)Úvaluess    r#   Úflexible_paramsr3   C   s.   € ä
ˆ6ƒ{�aÒœJ v¨a¡y´4¼°-Ô@Ø�a‰yÐØ€Mr%   c                óz   — d|v r&| d   dk(  xr | d   dk(  xs | d   dk(  xr | d   dk(  S | d   dk(  xr | d   dk(  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;   J   si   € ð ˜Ñ Ø˜1‘ Ñ$Ò>¨°B©¸3Ñ)>ò 
Ø�q‰M˜SÑ Ò: Z°¡^°sÑ%:ð	
ð �a‰=˜CÑÒ9 J¨r¡N°cÑ$9Ð9r%   c                óˆ   — t        | «      dk(  ryd|v r| j                  dd«      }d|› d�S | j                  dd«      }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.
    r   z``r5   r8   z""r6   )r.   Úreplace)r9   r:   Úquoteds      r#   Úquote_identifierr?   [   s[   € ô ˆ:ƒ˜!ÒØØ˜Ñ Ø×#Ñ# C¨Ó.ˆØ�6�(˜!ˆ}ÐØ×Ñ  TÓ*€FØˆvˆh�aˆ=Ðr%   c           	     ó^   — dj                  | D �cg c]  }t        ||«      ‘Œ c}«      S c c}w )a  Quote 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:   r9   s      r#   Úquote_multipart_identifierrD   o   s.   € ð �8‰8ØBMÖN°JÔ	˜* hÕ	/ÒNóð ùÚNs   �*c                ó¼   — d|v rdnd}||v rd|› �nd}|j                  |d«      }t        |«      dk(  r| n|d   j                  |«      |d   j                  |«      fS )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.
    r5   r8   r6   rA   r   r   r7   )Úsplitr.   Ústrip)Údefault_schemaÚ
table_namer:   ÚquoteÚ	delimiterÚtemps         r#   Úparse_table_namerM   ~   sn   € ð ! HÑ,‰C°#€EØ$¨
Ñ2�!�E�7‘¸€IØ×Ñ˜I qÓ)€Dä˜d›) qš.‰¨d°1©g¯m©m¸EÓ.BØˆR‰�‰�uÓðð r%   c                  ób  — e Zd ZdZddd„Zedd„«       Zedd„«       Zedd„«       Zej                  dd„«       Zedd„«       Z
edd„«       Zej                  dd	„«       Zedd
„«       Zej                  dd„«       Zedd„«       Zedd„«       Zej                  dd„«       Zdd„Zdd„Zdd„Zdd„Zy)Ú	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                ó˜   — || _         || _        |r|j                  «       nd | _        d | _        d| _        d| _        d| _        d| _        y )Nr   TF)	Ú_targetÚ
_doc_basedÚget_connectionÚ_connectionÚ_stmt_idÚ_exec_counterÚ_changedÚ	_preparedÚ_deallocate_prepare_execute)r"   ÚtargetÚ	doc_baseds      r#   r$   zStatement.__init__�   sO   € Ø+1ˆŒØ )ˆŒá'-ˆF×!Ñ!Ô#°4ð 	Ôð (,ˆŒØ"#ˆÔØ"ˆŒØ$ˆŒØ16ˆÕ(r%   c                ó   — | j                   S )z#object: The database object target.)rQ   ©r"   s    r#   rZ   zStatement.target©   s   € ð �|‰|Ðr%   c                ó.   — | j                   j                  S )z*:class:`mysqlx.Schema`: The Schema object.)rQ   Úschemar]   s    r#   r_   zStatement.schema®   s   € ð �|‰|×"Ñ"Ð"r%   c                ó   — | j                   S )zXReturns this statement ID.

        Returns:
            int: The statement ID.
        ©rU   r]   s    r#   Ústmt_idzStatement.stmt_id³   s   € ð �}‰}Ðr%   c                ó   — || _         y r    ra   ©r"   Úvalues     r#   rb   zStatement.stmt_id¼   ó	   € àˆ�r%   c                ó   — | j                   S )z5int: The number of times this statement was executed.©rV   r]   s    r#   Úexec_counterzStatement.exec_counterÀ   s   € ð ×!Ñ!Ð!r%   c                ó   — | j                   S )z+bool: `True` if this statement has changes.©rW   r]   s    r#   ÚchangedzStatement.changedÅ   s   € ð �}‰}Ðr%   c                ó   — || _         y r    rk   rd   s     r#   rl   zStatement.changedÊ   rf   r%   c                ó   — | j                   S )z1bool: `True` if this statement has been prepared.©rX   r]   s    r#   ÚpreparedzStatement.preparedÎ   s   € ð �~‰~Ðr%   c                ó   — || _         y r    ro   rd   s     r#   rp   zStatement.preparedÓ   s	   € àˆ�r%   c                ó    — | j                   dkD  S )z;bool: `True` if this statement was executed more than once.r   rh   r]   s    r#   ÚrepeatedzStatement.repeated×   s   € ð ×!Ñ! AÑ%Ð%r%   c                ó   — | j                   S )z9bool: `True` to deallocate + prepare + execute statement.©rY   r]   s    r#   Údeallocate_prepare_executez$Statement.deallocate_prepare_executeÜ   s   € ð ×/Ñ/Ð/r%   c                ó   — || _         y r    ru   rd   s     r#   rv   z$Statement.deallocate_prepare_executeá   s
   € à+0ˆÕ(r%   c                ó   — | j                   S )zkCheck if it is document based.

        Returns:
            bool: `True` if it is document based.
        )rR   r]   s    r#   Úis_doc_basedzStatement.is_doc_basedå   s   € ð �‰Ðr%   c                ó.   — | xj                   dz  c_         y)z@Increments the number of times this statement has been executed.r   Nrh   r]   s    r#   Úincrement_exec_counterz Statement.increment_exec_counterí   s   € à×Ò˜aÑÖr%   c                ó   — d| _         y)z<Resets the number of times this statement has been executed.r   Nrh   r]   s    r#   Úreset_exec_counterzStatement.reset_exec_counterñ   s
   € àˆÕr%   c                ó   — t         ‚©zqExecute the statement.

        Raises:
           NotImplementedError: This method must be implemented.
        ©ÚNotImplementedErrorr]   s    r#   ÚexecutezStatement.executeõ   ó
   € ô "Ð!r%   N©T©rZ   r   r[   Úboolr&   r'   )r&   r   )r&   r   ©r&   Úint)re   rˆ   r&   r'   ©r&   r†   )re   r†   r&   r'   )r&   r'   ©r&   r   )r(   r)   r*   r+   r$   ÚpropertyrZ   r_   rb   Úsetterri   rl   rp   rs   rv   ry   r{   r}   r‚   r,   r%   r#   rO   rO   ”   s"  „ ñô
7ð òó ðð ò#ó ð#ð òó ðð ‡^�^òó ðð ò"ó ð"ð òó ðð ‡^�^òó ðð òó ðð ‡_�_òó ðð ò&ó ð&ð ò0ó ð0ð  ×&Ñ&ò1ó 'ð1óó óô"r%   rO   c                  ó"  ‡ — e Zd ZdZ	 	 d	 	 	 	 	 	 	 dˆ fd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	d d„Z
d!d	„Zd"d
„Zd#d„Zd$d„Zd%d„Zd%d„Zd$d„Z	 	 d#d„Z	 	 d#d„Z ed«      dd„«       Z ed«      dd„«       Z	 d&	 	 	 	 	 d'd„Zd(d„Zd)d„Zd*d„Zˆ xZS )+Ú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                óh  •— t         ‰| �  ||¬«       i | _        i | _        d | _        d| _        d | _        d| _        d | _        d| _	        d | _
        d| _        d | _        d| _        d | _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        |r| j-                  |«       y y )N©rZ   r[   Ú r   F)Ú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©r"   rZ   r[   Ú	conditionÚ	__class__s       €r#   r$   zFilterableStatement.__init__
  sÖ   ø€ ô 	‰Ñ °)ÐÔ<Ø,.ˆÔØ68ˆŒØ.2ˆŒØ"$ˆÔð ð 	Œð #$ˆÔØ%)ˆÔØ$&ˆÔð ð 	Ôð !ˆŒð ð 	Œð  "ˆŒØ(,ˆÔØ"'ˆÔØ$ˆŒØ"'ˆÔØ %ˆŒØ$)ˆÔØ#ˆŒØ$ˆŒÙØ�O‰O˜IÕ&ð r%   c                óô  — t        |t        «      r)| j                  t        |«      j	                  «       «       yt        |t        «      r | j                  |j	                  «       «       yt        |t
        «      rX	 t        j                  |«      }t        |t        «      st        ‚	 |j                  «       D ]  }| j                  |||   «       Œ yt        d«      ‚# t        $ r}t        d«      |‚d}~ww xY w)a  Bind 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.
        zInvalid 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_single.  sÎ   € ô �cœ4Ô Ø�I‰I”e˜C“j×'Ñ'Ó)Õ*Ü˜œUÔ#Ø�I‰I�c—j‘j“lÕ#Ü˜œSÔ!ðOÜ—j‘j “o�Ü! #¤tÔ,Ü$Ð$ð -ð —x‘x“zò )�Ø—	‘	˜#˜s 3™xÕ(ñ)ô #Ð#JÓKÐKøô ò OÜ&Ð'DÓEÈ3ÐNûðOús   Á;+C Ã	C7Ã&C2Ã2C7c                óÂ   — d| _         dj                  t        |Ž «      | _        t	        | j                  | 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¥   rB   r3   rœ   r   rR   Úparse_order_specr�   rW   ©r"   Úclausess     r#   Ú_sortzFilterableStatement._sortH  sV   € ð ˆŒØŸ™¤/°7Ð";Ó<ˆŒÜ$Ø�N‰N §¡Ð/ó
ç
Ñ
Ó
ð 	Œð ˆŒØˆr%   c                óæ   — d| _         || _        	 t        || j                   «      }|j	                  «       | _        |j                  | _	        d| _
        | S # t        $ r}t        d«      |‚d}~ww xY w)a  Sets the search condition to filter.

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

        Returns:
            mysqlx.FilterableStatement: FilterableStatement object.
        TzInvalid conditionN)r¦   rž   r   rR   r!   rŸ   r²   r   Úplaceholder_name_to_positionr“   rW   )r"   r©   r!   r¶   s       r#   r§   zFilterableStatement._set_whereY  sw   € ð ˆŒØ#ˆŒð	AÜ˜i¨T¯_©_Ð)<Ó=ˆDØ#Ÿy™y›{ˆDÔð !×=Ñ=ˆÔØˆŒØˆøô	 ò 	AÜ"Ð#6Ó7¸SÐ@ûð	Aús   �,A Á	A0ÁA+Á+A0c                óÄ   — t        |Ž }d| _        dj                  |«      | _        t	        | j                  | j
                   «      j                  «       | _        d| _        y)zJSet group by.

        Args:
            *fields: List of fields.
        Trº   N)	r3   r¢   rB   r–   r   rR   Úparse_expr_listr—   rW   ©r"   Úfieldss     r#   Ú_set_group_byz!FilterableStatement._set_group_byn  sY   € ô ! &Ð)ˆØ ˆÔØ ŸX™X fÓ-ˆÔÜ#Ø×Ñ D§O¡OÐ 3ó
ç
‰/Ó
ð 	Œð ˆ�r%   c                ót   — d| _         t        || j                   «      j                  «       | _        d| _        y)zOSet having.

        Args:
            condition (str): The condition.
        TN)r£   r   rR   r!   r•   rW   ©r"   r©   s     r#   Ú_set_havingzFilterableStatement._set_having|  s0   € ð ˆŒÜ! )°·±Ð-@ÓA×FÑFÓHˆŒØˆ�r%   c                óÆ   — t        |Ž }d| _        dj                  |«      | _        t	        | j                  | j
                   «      j                  «       | _        d| _        | S )z¡Set the projection.

        Args:
            *fields: List of fields.

        Returns:
            :class:`mysqlx.FilterableStatement`: Returns self.
        Trº   )	r3   r¤   rB   rš   r   rR   Úparse_table_select_projectionr›   rW   rÃ   s     r#   Ú_set_projectionz#FilterableStatement._set_projection†  s`   € ô ! &Ð)ˆØ"ˆÔØ"Ÿx™x¨Ó/ˆÔÜ *Ø× Ñ  d§o¡oÐ"5ó!
ç
'Ñ
'Ó
)ð 	Ôð ˆŒØˆr%   c                ó   — | j                   S ©zlReturns the binding map dictionary.

        Returns:
            dict: The binding map dictionary.
        ©r“   r]   s    r#   Úget_binding_mapz#FilterableStatement.get_binding_map˜  ó   € ð × Ñ Ð r%   c                ó   — | j                   S ©z\Returns the bindings list.

        Returns:
            `list`: The bindings list.
        ©r”   r]   s    r#   Úget_bindingsz FilterableStatement.get_bindings   ó   € ð �~‰~Ðr%   c                ó   — | j                   S )zrReturns the grouping expression list.

        Returns:
            `list`: The grouping expression list.
        )r—   r]   s    r#   Úget_groupingz FilterableStatement.get_grouping¨  rÕ   r%   c                ó   — | j                   S )zdReturns the having expression.

        Returns:
            object: The having expression.
        )r•   r]   s    r#   Ú
get_havingzFilterableStatement.get_having°  ó   € ð �|‰|Ðr%   c                ó   — | j                   S )z]Returns the limit row count.

        Returns:
            int: The limit row count.
        )r™   r]   s    r#   Úget_limit_row_countz'FilterableStatement.get_limit_row_count¸  s   € ð ×$Ñ$Ð$r%   c                ó   — | j                   S )zWReturns the limit offset.

        Returns:
            int: The limit offset.
        )r˜   r]   s    r#   Úget_limit_offsetz$FilterableStatement.get_limit_offsetÀ  s   € ð ×!Ñ!Ð!r%   c                ó   — | j                   S )zbReturns the where expression.

        Returns:
            object: The where expression.
        )rŸ   r]   s    r#   Úget_where_exprz"FilterableStatement.get_where_exprÈ  ó   € ð ×ÑÐr%   c                ó   — | j                   S )zlReturns the projection expression.

        Returns:
            object: The projection expression.
        )r›   r]   s    r#   Úget_projection_exprz'FilterableStatement.get_projection_exprÐ  s   € ð ×$Ñ$Ð$r%   c                ó   — | j                   S )z`Returns the sort expression.

        Returns:
            object: The sort expression.
        )r�   r]   s    r#   Úget_sort_exprz!FilterableStatement.get_sort_exprÚ  s   € ð �‰Ðr%   ú8.0.12c                ó$   — | j                  |«      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#   ÚwherezFilterableStatement.whereä  s   € ð �‰˜yÓ)Ð)r%   c                ó    —  | 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#   ÚsortzFilterableStatement.sortó  s   € ð ˆt�z‰z˜7Ð#Ð#r%   c                óL  — t        |t        «      r|dk  rt        d«      ‚| j                  s;t	        | j
                  dk(  «      | _        t	        | j
                  dk(   «      | _        || _        d| _        |r,| j                  |«       t        j                  dt        ¬«       | 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.
        r   z0The '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/   rˆ   r²   r¡   r†   rV   rW   rY   r™   ÚoffsetÚwarningsÚwarnÚDeprecationWarning)r"   Ú	row_countrï   s      r#   ÚlimitzFilterableStatement.limit  s”   € ô" ˜)¤SÔ)¨Y¸ª]ÜÐOÓPÐPØ�~Š~Ü  ×!3Ñ!3°qÑ!8Ó9ˆDŒMÜ/3¸×8JÑ8JÈaÑ8OÐ4OÓ/PˆDÔ,à )ˆÔØˆŒÙØ�K‰K˜ÔÜ�M‰Mðô ,õ	ð ˆr%   c                óT   — t        |t        «      r|dk  rt        d«      ‚|| _        | 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
        r   z-The 'offset' value must be a positive integer)r/   rˆ   r²   r˜   )r"   rï   s     r#   rï   zFilterableStatement.offset$  s-   € ô ˜&¤#Ô&¨&°1ª*ÜÐLÓMÐMØ#ˆÔØˆr%   c                óª   — d| _         t        |«      }|dk(  r| j                  |d   «       | S |dk(  r|d   | j                  |d   <   | S t	        d«      ‚)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.
        Tr   r   é   ú#Invalid number of arguments to bind)r    r.   r¸   r”   r   )r"   ÚargsÚcounts      r#   r­   zFilterableStatement.bind7  si   € ð !ˆÔÜ�D“	ˆØ�AŠ:Ø×Ñ˜d 1™gÔ&ð
 ˆð	 �aŠZØ&*¨1¡gˆD�N‰N˜4 ™7Ñ#ð ˆô #Ð#HÓIÐIr%   c                ó   — t         ‚r   r€   r]   s    r#   r‚   zFilterableStatement.executeO  rƒ   r%   ©TN©rZ   r   r[   r†   r©   úOptional[str]r&   r'   )r´   z!Union[DbDoc, Dict[str, Any], str]r&   r'   )r½   r¯   r&   rŽ   )r©   r¯   r&   rŽ   )rÄ   r¯   r&   r'   )r©   r¯   r&   r'   )rÄ   r¯   r&   rŽ   ©r&   úDict[str, Any])r&   zUnion[Dict[str, Any], List])r&   z9List[Union[ProtobufMessageType, ProtobufMessageCextType]])r&   r   r‡   r    )ró   rˆ   rï   zOptional[int]r&   rŽ   )rï   rˆ   r&   rŽ   )rù   r   r&   rŽ   rŠ   )r(   r)   r*   r+   r$   r¸   r¾   r§   rÅ   rÈ   rË   rÏ   rÔ   r×   rÙ   rÜ   rÞ   rà   rã   rå   r   ré   rì   rô   rï   r­   r‚   Ú__classcell__©rª   s   @r#   rŽ   rŽ   þ   sü   ø„ ñ	ð Ø#'ð	"'à"ð"'ð ð"'ð !ð	"'ð
 
õ"'óHLó4ó"ó*óóó$!óóóó%ó"ó ð%à	Bó%ðà	Bóñ �Óò*ó ð*ñ �Óò$ó ð$ð 7;ð!Øð!Ø&3ð!à	ó!óFó&÷0"r%   rŽ   c                  óV   ‡ — e Zd ZdZdˆ fd„Zed	d„«       Zd
d„Zdd„Zdd„Z	dd„Z
ˆ xZS )ÚSqlStatementz¬A statement for SQL execution.

    Args:
        connection (mysqlx.connection.Connection): Connection object.
        sql (string): The sql statement to be executed.
    c                ó|   •— t         ‰| �  d d¬«       || _        || _        d | _        g | _        d| _        d| _        y ©NFr�   )r’   r$   rT   Ú_sqlr“   r”   r    r¡   )r"   Ú
connectionÚsqlrª   s      €r#   r$   zSqlStatement.__init__`  sB   ø€ Ü‰Ñ °ÐÔ6Ø+5ˆÔØˆŒ	Ø6:ˆÔØ-/ˆŒØ"'ˆÔØ$ˆ�r%   c                ó   — | j                   S )zstring: The SQL text statement.)r  r]   s    r#   r	  zSqlStatement.sqli  s   € ð �y‰yÐr%   c                ó   — | j                   S rÍ   rÎ   r]   s    r#   rÏ   zSqlStatement.get_binding_mapn  rÐ   r%   c                ó   — | j                   S rÒ   rÓ   r]   s    r#   rÔ   zSqlStatement.get_bindingsv  rÕ   r%   c                óÊ   — t        |«      dk(  rt        d«      ‚d| _        t        |Ž }t	        |t
        t        f«      r	|| _        | S | j                  j                  |«       | S )zµBinds value(s) to a specific placeholder(s).

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

        Returns:
            mysqlx.SqlStatement: SqlStatement object.
        r   rø   T)	r.   r   r    r3   r/   r0   r1   r”   Úappend)r"   rù   Úbindingss      r#   r­   zSqlStatement.bind~  sb   € ô ˆt‹9˜Š>Ü"Ð#HÓIÐIØ ˆÔÜ" DÐ)ˆÜ�h¤¤u Ô.Ø%ˆDŒNð ˆð �N‰N×!Ñ! (Ô+Øˆr%   c                ó8   — | j                   j                  | «      S )zaExecute the statement.

        Returns:
            mysqlx.SqlResult: SqlResult object.
        )rT   Úsend_sqlr]   s    r#   r‚   zSqlStatement.execute‘  s   € ð ×Ñ×(Ñ(¨Ó.Ð.r%   )r  r   r	  r¯   r&   r'   ©r&   r¯   rÿ   )r&   zUnion[Tuple, List])rù   r   r&   r  )r&   r   )r(   r)   r*   r+   r$   r‹   r	  rÏ   rÔ   r­   r‚   r  r  s   @r#   r  r  X  s5   ø„ ñõ%ð òó ðó!óó÷&/r%   r  c                  ó8   ‡ — e Zd ZdZdˆ fd„Z	 	 dd„Zdd„Zˆ xZS )ÚWriteStatementz*Provide common write operation attributes.c                ó4   •— t         ‰| �  ||«       g | _        y r    )r’   r$   Ú_values)r"   rZ   r[   rª   s      €r#   r$   zWriteStatement.__init__�  s   ø€ Ü‰Ñ˜ Ô+ð ð 	�r%   c                ó   — | j                   S )z^Returns the list of values.

        Returns:
            `list`: The list of values.
        )r  r]   s    r#   Ú
get_valueszWriteStatement.get_values©  s   € ð  �|‰|Ðr%   c                ó   — t         ‚r   r€   r]   s    r#   r‚   zWriteStatement.execute»  rƒ   r%   r…   )r&   zpList[Union[int, str, DbDoc, Dict[str, Any], List[Optional[Union[str, int, float, ExprParser, Dict[str, Any]]]]]]rŠ   )r(   r)   r*   r+   r$   r  r‚   r  r  s   @r#   r  r  š  s   ø„ Ù4õ
ðð
ó÷$"r%   r  c                  óF   ‡ — e Zd ZdZdˆ fd„Zdd„Zd	d
d„Zdd„Zdd„Zˆ xZ	S )ÚAddStatementz�A statement for document addition on a collection.

    Args:
        collection (mysqlx.Collection): The Collection object.
    c                óB   •— t         ‰| �  |d«       d| _        g | _        y )NTF)r’   r$   Ú_upsertÚids)r"   Ú
collectionrª   s     €r#   r$   zAddStatement.__init__Ë  s    ø€ Ü‰Ñ˜ TÔ*Ø"ˆŒØˆ�r%   c                ó   — | j                   S )zhReturns `True` if it's an upsert.

        Returns:
            bool: `True` if it's an upsert.
        ©r  r]   s    r#   Ú	is_upsertzAddStatement.is_upsertÐ  rÚ   r%   c                ó   — || _         | 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!  rd   s     r#   ÚupsertzAddStatement.upsertØ  s   € ð ˆŒØˆr%   c                óÀ   — t        |Ž D ]R  }t        |t        «      r| j                  j	                  |«       Œ/| j                  j	                  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.
        )r3   r/   r   r  r  )r"   r2   Úvals      r#   ÚaddzAddStatement.addã  sQ   € ô # FÐ+ò 	0ˆCÜ˜#œuÔ%Ø—‘×#Ñ# CÕ(à—‘×#Ñ#¤E¨#£JÕ/ð		0ð
 ˆr%   c                ó|   — t        | j                  «      dk(  r
t        «       S | j                  j	                  | «      S )ú[Execute the statement.

        Returns:
            mysqlx.Result: Result object.
        r   )r.   r  r   rT   Úsend_insertr]   s    r#   r‚   zAddStatement.executeó  s3   € ô ˆt�|‰|Ó Ò!Ü“8ˆOà×Ñ×+Ñ+¨DÓ1Ð1r%   )r  r   r&   r'   r‰   r„   )re   r†   r&   r  )r2   r   r&   r  ©r&   r   )
r(   r)   r*   r+   r$   r"  r$  r'  r‚   r  r  s   @r#   r  r  Ä  s!   ø„ ñõó
ô	ó÷ 	2r%   r  c                  ó"   — e Zd ZdZddd„Zdd„Zy)Ú
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                óò   — |t        d«      k(  r| j                  ||«       y || _        	 t        |d«      j	                  «       j
                  | _        || _	        y # t        $ r}t        |› «      |‚d }~ww xY w)Nú*Mysqlx.Crud.UpdateOperation.UpdateType.SETF)
r   Ú
_table_setÚupdate_typer   Údocument_fieldr9   Úsourcer²   r   re   )r"   r1  r3  re   r¶   s        r#   r$   zUpdateSpec.__init__  sr   € Øœ-Ð(TÓUÒUØ�O‰O˜F EÕ*à$/ˆDÔð:Ü#-¨f°eÓ#<×#KÑ#KÓ#M×#XÑ#X�”ð $ˆD�Jøô ò :Ü&¨#¨Ó0°cÐ9ûð:ús   ª)A Á	A6Á$A1Á1A6c                óp   — t        d«      | _        t        |d«      j                  «       | _        || _        y)zlTable set.

        Args:
            source (str): The source.
            value (str): The value.
        r/  TN)r   r1  r   Úparse_table_update_fieldr3  re   )r"   r3  re   s      r#   r0  zUpdateSpec._table_set  s0   € ô )Ð)UÓVˆÔÜ  ¨Ó.×GÑGÓIˆŒØˆ�
r%   r    )r1  rˆ   r3  r¯   re   r   r&   r'   )r3  r¯   re   r   r&   r'   )r(   r)   r*   r+   r$   r0  r,   r%   r#   r-  r-  ÿ  s   „ ñ	ô	$ô	r%   r-  c                  ó‚   ‡ — e Zd ZdZdˆ fd„Zdd„Zdd„Zdd„Z ed«      dd„«       Z	dd„Z
dd	„Zdd
„Zdd„Zdd„Zˆ xZS )ÚModifyStatementaU  A 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                ó6   •— t         ‰| �  ||¬«       i | _        y ©N)rZ   r©   ©r’   r$   Ú_update_ops©r"   r  r©   rª   s      €r#   r$   zModifyStatement.__init__.  s   ø€ Ü‰Ñ 
°iÐÔ@Ø+-ˆÕr%   c                ó    —  | j                   |Ž S )zÉSets the sorting criteria.

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

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.
        rë   r¼   s     r#   rì   zModifyStatement.sort2  ó   € ð ˆt�z‰z˜7Ð#Ð#r%   c                ó   — | j                   S ©ztReturns the list of update operations.

        Returns:
            `list`: The list of update operations.
        ©r;  r]   s    r#   Úget_update_opszModifyStatement.get_update_ops=  rá   r%   c                óZ   — t        t        d«      ||«      | j                  |<   d| _        | S )a2  Sets 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©r-  r   r;  rW   ©r"   Údoc_pathre   s      r#   ÚsetzModifyStatement.setE  s6   € ô &0ÜÐKÓLØØó&
ˆ×Ñ˜Ñ"ð
 ˆŒØˆr%   ræ   c                óZ   — t        t        d«      ||«      | 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_REPLACETrD  rE  s      r#   ÚchangezModifyStatement.changeW  s6   € ô &0ÜÐOÓPØØó&
ˆ×Ñ˜Ñ"ð
 ˆŒØˆr%   c                ór   — t        |Ž D ]$  }t        t        d«      |«      | j                  |<   Œ& d| _        | S )a  Removes 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)r3   r-  r   r;  rW   )r"   Ú	doc_pathsÚitems      r#   ÚunsetzModifyStatement.unsetm  sG   € ô $ YÐ/ò 	ˆDÜ%/ÜÐRÓSØó&ˆD×Ñ˜TÒ"ð	ð
 ˆŒØˆr%   c                óZ   — t        t        d«      ||«      | 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_INSERTTrD  ©r"   Úfieldre   s      r#   Úarray_insertzModifyStatement.array_insert  s6   € ô #-ÜÐOÓPØØó#
ˆ×Ñ˜Ñð
 ˆŒØˆr%   c                óZ   — t        t        d«      ||«      | 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_APPENDTrD  rE  s      r#   Úarray_appendzModifyStatement.array_append“  s6   € ô &0ÜÐOÓPØØó&
ˆ×Ñ˜Ñ"ð
 ˆŒØˆr%   c                óø   — |€d}t        |t        t        t        t        f«      st        d«      ‚t        t        d«      dt        |t        «      r|j                  «       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.
        r‘   z>Invalid data for update operation on document collection tablez2Mysqlx.Crud.UpdateOperation.UpdateType.MERGE_PATCHú$ÚpatchT)r/   r   r¬   r   r¯   r   r-  r   r!   r;  rW   )r"   Údocs     r#   rV  zModifyStatement.patch¨  sv   € ð ˆ;ØˆCÜ˜#¤
¬D´%¼Ð=Ô>Ü"ØPóð ô %/ÜÐNÓOØÜ$ S¬*Ô5ˆC�H‰HŒJ¸3ó%
ˆ×Ñ˜Ñ!ð
 ˆŒØˆr%   c                óf   — | j                   st        d«      ‚| j                  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¦   r   rT   Úsend_updater]   s    r#   r‚   zModifyStatement.executeÂ  ó.   € ð �~Š~Ü"Ð#FÓGÐGØ×Ñ×+Ñ+¨DÓ1Ð1r%   ©r  r   r©   r¯   r&   r'   )r½   r¯   r&   r7  rÿ   )rF  r¯   re   r   r&   r7  )rK  r¯   r&   r7  )rP  r¯   re   r   r&   r7  )rW  z#Union[Dict, DbDoc, ExprParser, str]r&   r7  r+  )r(   r)   r*   r+   r$   rì   rB  rG  r   rI  rM  rQ  rS  rV  r‚   r  r  s   @r#   r7  r7  "  sN   ø„ ñ	õ.ó	$ó óñ$ �Óòó ðó*ó$ó(ó*÷42r%   r7  c                  óÆ   ‡ — e Zd ZdZ	 	 d	 	 	 	 	 	 	 dˆ fd„Zedd„«       Zdd„Zdd„Zdd„Z	e
j                  f	 	 	 dd„Ze
j                  f	 	 	 dd„Zdd	„Zdd
„Zdd„Zˆ xZS )Ú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.
    c                ón   •— t         ‰| �  |||«       d| _        d| _        t        j
                  | _        y ©NF)r’   r$   Ú_lock_exclusiveÚ_lock_sharedr   ÚDEFAULTÚ_lock_contentionr¨   s       €r#   r$   zReadStatement.__init__Ü  s4   ø€ ô 	‰Ñ˜ ¨IÔ6Ø%*ˆÔØ"'ˆÔÜ0>×0FÑ0FˆÕr%   c                ó   — | j                   S )z::class:`mysqlx.LockContention`: The lock contention value.)re  r]   s    r#   Úlock_contentionzReadStatement.lock_contentionç  s   € ð ×$Ñ$Ð$r%   c                óx   — 	 t        |j                  «      }|| _        y# t        $ r}t        d«      |‚d}~ww xY w)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)r   re   r²   r   re  )r"   rg  Ú_r¶   s       r#   Ú_set_lock_contentionz"ReadStatement._set_lock_contentionì  sF   € ð	ä˜×4Ñ4Ó5ˆAð
 !0ˆÕøô	 ò 	Ü"ØMóàðûð	ús   ‚ Ÿ	9¨4´9c                ó   — | j                   S )zrReturns `True` if is `EXCLUSIVE LOCK`.

        Returns:
            bool: `True` if is `EXCLUSIVE LOCK`.
        )rb  r]   s    r#   Úis_lock_exclusivezReadStatement.is_lock_exclusiveþ  s   € ð ×#Ñ#Ð#r%   c                ó   — | j                   S )zlReturns `True` if is `SHARED LOCK`.

        Returns:
            bool: `True` if is `SHARED LOCK`.
        )rc  r]   s    r#   Úis_lock_sharedzReadStatement.is_lock_shared  rÐ   r%   c                óD   — d| _         d| _        | j                  |«       | 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©rb  rc  rj  ©r"   rg  s     r#   Úlock_sharedzReadStatement.lock_shared  s'   € ð  %ˆÔØ ˆÔØ×!Ñ! /Ô2Øˆr%   c                óD   — d| _         d| _        | j                  |«       | 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.
        TFrp  rq  s     r#   Úlock_exclusivezReadStatement.lock_exclusive  s'   € ð  $ˆÔØ!ˆÔØ×!Ñ! /Ô2Øˆr%   c                ó$   —  | 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_byzReadStatement.group_by*  s   € ð 	ˆ×Ñ˜FÑ#Øˆr%   c                ó(   — | 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.ReadStatement: ReadStatement object.
        )rÈ   rÇ   s     r#   ÚhavingzReadStatement.having6  s   € ð 	×Ñ˜Ô#Øˆr%   c                ó8   — | j                   j                  | «      S ©r)  )rT   Ú	send_findr]   s    r#   r‚   zReadStatement.executeD  s   € ð ×Ñ×)Ñ)¨$Ó/Ð/r%   rü   rý   )r&   r   )rg  r   r&   r'   r‰   )rg  r   r&   r_  )rÄ   r¯   r&   r_  )r©   r¯   r&   r_  )r&   zUnion[DocResult, RowResult])r(   r)   r*   r+   r$   r‹   rg  rj  rl  rn  r   rd  rr  rt  rv  rx  r‚   r  r  s   @r#   r_  r_  Ð  s²   ø„ ñ	ð Ø#'ð		Gà"ð	Gð ð	Gð !ð		Gð
 
õ	Gð ò%ó ð%ó0ó$$ó!ð 1?×0FÑ0FðØ-ðà	óð 1?×0FÑ0FðØ-ðà	óó
ó÷0r%   r_  c                  óB   ‡ — e Zd ZdZ	 d	 	 	 	 	 dˆ fd„Zdd„Zdd„Zˆ xZ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                ó(   •— t         ‰| �  |d|«       y )NT©r’   r$   r<  s      €r#   r$   zFindStatement.__init__X  s   ø€ ô 	‰Ñ˜ T¨9Õ5r%   c                ó    —  | 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     r#   rÄ   zFindStatement.fields]  s   € ð $ˆt×#Ñ# VÐ,Ð,r%   c                ó    —  | j                   |Ž S ©zÅSets the sorting criteria.

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

        Returns:
            mysqlx.FindStatement: FindStatement object.
        rë   r¼   s     r#   rì   zFindStatement.sorti  r>  r%   r    )r  r   r©   rþ   r&   r'   )rÄ   r¯   r&   r}  )r½   r¯   r&   r}  )r(   r)   r*   r+   r$   rÄ   rì   r  r  s   @r#   r}  r}  M  s6   ø„ ñð JNð6Ø,ð6Ø9Fð6à	õ6ó

-÷	$r%   r}  c                  ó<   ‡ — e Zd ZdZdˆ fd„Zdd„Zdd„Zd	d„Zˆ xZ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                óD   •— t         ‰| �  |d«        | j                  |Ž  y ra  )r’   r$   rË   ©r"   ÚtablerÄ   rª   s      €r#   r$   zSelectStatement.__init__}  s"   ø€ Ü‰Ñ˜ Ô&Øˆ×Ñ˜fÒ%r%   c                ó$   — | j                  |«      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     r#   ré   zSelectStatement.where�  ó   € ð �‰˜yÓ)Ð)r%   c                ó    —  | 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_byzSelectStatement.order_byŒ  r>  r%   c                óØ  — | j                   rd| j                  › �nd}| j                  rd| j                  › �nd}| j                  rd| j
                  › �nd}| j                  rd| j                  › �nd}| j                  rd| j                  › d| j                  › �nd}d| j                  xs d	› d
| j                  j                  › d| j                  j                  › |› |› |› |› |› �}|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 zSELECT Ú*z FROM rA   )r¦   rž   r¢   r–   r£   r•   r¥   rœ   r¡   r™   r˜   rš   r_   ÚnamerZ   )r"   ré   rv  rx  r‹  rô   Ústmts          r#   Úget_sqlzSelectStatement.get_sql—  sý   € ð 04¯~ª~�'˜$Ÿ/™/Ð*Ñ+À2ˆØ8<×8IÒ8I�Z × 2Ñ 2Ð3Ñ4ÈrˆØ.2¯oªo�8˜DŸL™L˜>Ñ*À2ˆØ48·M²M�Z §¡Ð/Ñ0Àrˆð �~Š~ð �d×+Ñ+Ð,¨H°T×5GÑ5GÐ4HÑIàð 	ð �d×*Ñ*Ò1¨cÐ2ð 3Ø—K‘K×$Ñ$Ð% Q t§{¡{×'7Ñ'7Ð&8Øˆg�h�Z ˜x¨ z°%°ð:ð 	ð
 ˆr%   )r‡  r   rÄ   r¯   r&   r'   )r©   r¯   r&   r„  )r½   r¯   r&   r„  r  )	r(   r)   r*   r+   r$   ré   r‹  r�  r  r  s   @r#   r„  r„  u  s   ø„ ñõ&ó	*ó	$÷r%   r„  c                  ó4   ‡ — e Zd ZdZdˆ fd„Zdd„Zdd„Zˆ xZS )ÚInsertStatementz—A statement for insert operations on Table.

    Args:
        table (mysqlx.Table): The Table object.
        *fields: The fields to be inserted.
    c                ó@   •— t         ‰| �  |d«       t        |Ž | _        y ra  )r’   r$   r3   Ú_fieldsr†  s      €r#   r$   zInsertStatement.__init__¶  s   ø€ Ü‰Ñ˜ Ô&Ü+:¸FÐ+Cˆ�r%   c                óZ   — | j                   j                  t        t        |Ž «      «       | 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  r0   r3   )r"   r2   s     r#   r2   zInsertStatement.valuesº  s%   € ð 	�‰×ÑœD¤°&Ð!9Ó:Ô;Øˆr%   c                ó8   — | j                   j                  | «      S rz  )rT   r*  r]   s    r#   r‚   zInsertStatement.executeÆ  s   € ð ×Ñ×+Ñ+¨DÓ1Ð1r%   )r‡  r   rÄ   r   r&   r'   )r2   r   r&   r’  r+  )r(   r)   r*   r+   r$   r2   r‚   r  r  s   @r#   r’  r’  ®  s   ø„ ñõDó
÷2r%   r’  c                  óL   ‡ — e Zd ZdZdˆ fd„Zd	d„Zd
d„Zdd„Zdd„Zdd„Z	ˆ xZ
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                ó6   •— t         ‰| �  |d¬«       i | _        y r  r:  ©r"   r‡  rª   s     €r#   r$   zUpdateStatement.__init__Ù  s   ø€ Ü‰Ñ °ÐÔ7Ø+-ˆÕr%   c                ó$   — | j                  |«      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     r#   ré   zUpdateStatement.whereÝ  r‰  r%   c                ó    —  | 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     r#   r‹  zUpdateStatement.order_byè  r>  r%   c                ó   — | j                   S r@  rA  r]   s    r#   rB  zUpdateStatement.get_update_opsó  rá   r%   c                óZ   — t        t        d«      ||«      | j                  |<   d| _        | S )a  Updates 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/  TrD  rO  s      r#   rG  zUpdateStatement.setû  s6   € ô #-ÜÐFÓGØØó#
ˆ×Ñ˜Ñð
 ˆŒØˆr%   c                óf   — | j                   st        d«      ‚| j                  j                  | «      S )z£Execute the statement.

        Returns:
            mysqlx.Result: Result object

        Raises:
            ProgrammingError: If condition was not set.
        z!No condition was found for updaterZ  r]   s    r#   r‚   zUpdateStatement.execute  r\  r%   ©r‡  r   r&   r'   )r©   r¯   r&   r˜  )r½   r¯   r&   r˜  rÿ   )rP  r¯   re   r   r&   r˜  r+  )r(   r)   r*   r+   r$   ré   r‹  rB  rG  r‚   r  r  s   @r#   r˜  r˜  Ï  s&   ø„ ñõ.ó	*ó	$ó ó÷$2r%   r˜  c                  ó4   ‡ — e Zd ZdZdˆ fd„Zdd„Zdd„Zˆ xZS )ÚRemoveStatementaE  A 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                ó(   •— t         ‰| �  ||¬«       y r9  r  r<  s      €r#   r$   zRemoveStatement.__init__'  s   ø€ Ü‰Ñ 
°iÐÕ@r%   c                ó    —  | j                   |Ž S r‚  rë   r¼   s     r#   rì   zRemoveStatement.sort*  r>  r%   c                óf   — | j                   st        d«      ‚| j                  j                  | «      S )rY  z!No condition was found for remove©r¦   r   rT   Úsend_deleter]   s    r#   r‚   zRemoveStatement.execute5  r\  r%   r]  )r½   r¯   r&   r¢  r+  )r(   r)   r*   r+   r$   rì   r‚   r  r  s   @r#   r¢  r¢    s   ø„ ñ	õAó	$÷2r%   r¢  c                  ó<   ‡ — e Zd ZdZdˆ fd„Zdd„Zdd„Zd	d„Zˆ xZS )
ÚDeleteStatementz¯A statement that drops a table.

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

    .. versionchanged:: 8.0.12
       The ``condition`` parameter was removed.
    c                ó(   •— t         ‰| �  |d¬«       y r  r  rš  s     €r#   r$   zDeleteStatement.__init__M  s   ø€ Ü‰Ñ °ÐÕ7r%   c                ó$   — | j                  |«      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     r#   ré   zDeleteStatement.whereP  r‰  r%   c                ó    —  | 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     r#   r‹  zDeleteStatement.order_by[  r>  r%   c                óf   — | j                   st        d«      ‚| j                  j                  | «      S )rY  z!No condition was found for deleter¦  r]   s    r#   r‚   zDeleteStatement.executef  r\  r%   r   )r©   r¯   r&   r©  )r½   r¯   r&   r©  r+  )	r(   r)   r*   r+   r$   ré   r‹  r‚   r  r  s   @r#   r©  r©  C  s   ø„ ñõ8ó	*ó	$÷2r%   r©  c                  ó<   ‡ — e Zd ZdZ	 	 	 	 	 	 	 	 dˆ fd„Zdd„Zˆ xZS )Ú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         ‰| �  |¬«       t        j                  |«      | _        || _        | j                  j                  dg «      | _        y )N)rZ   rÄ   )r’   r$   ÚcopyÚdeepcopyÚ_index_descÚ_index_nameÚpopÚ_fields_desc)r"   r  Ú
index_nameÚ
index_descrª   s       €r#   r$   z'CreateCollectionIndexStatement.__init__‹  sJ   ø€ ô 	‰Ñ 
ÐÔ+Ü+/¯=©=¸Ó+DˆÔØ *ˆÔØ26×2BÑ2B×2FÑ2FÀxÐQSÓ2TˆÕr%   c                ó	  — | j                   €(t        t        j                  | j                   «      «      ‚	 t	        | j                   «      j                  «       j                  «       }t        |t        «      r9|d   t        d«      k7  rht        t        j                  | j                   «      «      ‚|j                  t        d«      k7  r(t        t        j                  | j                   «      «      ‚| j                  st        d| j                  › �«      ‚t        | j                  t        «      st        d«      ‚i }| j                   |d<   | j                   j"                  |d<   | j                   j$                  j"                  |d<   d| j                  v r| j                  j'                  d«      |d<   nd	|d<   | j                  j'                  d
d«      |d
<   |d
   rt)        d«      ‚g |d<   | j                  rt        d| j                  › �«      ‚	 | j                  D �]Â  }i }|j'                  d«      |d<   |j'                  d«      |d<   |j'                  dd«      |d<   |j'                  dd«      |d<   t        |d   t*        «      st-        d«      ‚t        |d   t*        «      st-        d«      ‚|d   j/                  «       dk(  r|d   st        d«      ‚|d   j/                  «       d	k(  r|d   dk(  rt        d«      ‚d|v rV|d   j/                  «       j1                  d«      s t        d|d   j/                  «       › d�«      ‚|j'                  d«      |d<   d|v r5|d   j/                  «       dk7  rt        d«      ‚|j'                  d«      |d<   d|v r5|d   j/                  «       dk7  rt        d «      ‚|j'                  d«      |d<   |d   j3                  |«       �ŒÅ 	 | j                  D ]  }|sŒt        d#|› �«      ‚ | j6                  j9                  d$d%d&|«      S # t        t        f$ r.}t        t        j                  | j                   «      «      |‚d}~ww xY w# t4        $ r}t        d!|› d"› �«      |‚d}~ww xY w)'r)  NÚtypezMysqlx.Expr.Expr.Type.IDENTzCRequired member 'fields' not found in the given index description: z,Required member 'fields' must contain a listrŽ  r  r_   ÚINDEXÚuniqueFz!Unique indexes are not supported.Ú
constraintzUnidentified fields: rP  Ú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'zRequired inner member z not found in constraint: zUnidentified inner fields: ÚmysqlxÚcreate_collection_indexT)r´  r   ÚERR_INVALID_INDEX_NAMEÚformatr   r!   Úget_messager/   r¬   r   rº  r²   ÚAttributeErrorr¶  r³  r0   rQ   rŽ  r_   rµ  r   r†   Ú	TypeErrorÚupperÚ
startswithr  ÚKeyErrorrT   Úexecute_nonquery)r"   Úparsed_identr¶   rù   Ú
field_descr½  s         r#   r‚   z&CreateCollectionIndexStatement.execute–  s¹  € ð ×ÑÐ#Ü"Ô#9×#@Ñ#@À×AQÑAQÓ#RÓSÐSð	Ü% d×&6Ñ&6Ó7×<Ñ<Ó>×JÑJÓLˆLô ˜,¬Ô-Ø Ñ'¬=Ð9VÓ+WÒWÜ*Ü.×5Ñ5°d×6FÑ6FÓGóð ð  ×$Ñ$¬Ð6SÓ(TÒTÜ*Ü.×5Ñ5°d×6FÑ6FÓGóð ð × Ò Ü"ð Ø $× 0Ñ 0Ð1ð3óð ô
 ˜$×+Ñ+¬TÔ2Ü"Ð#QÓRÐRØ!ˆØ×'Ñ'ˆˆV‰Ø!Ÿ\™\×.Ñ.ˆˆ\ÑØŸ™×,Ñ,×1Ñ1ˆˆX‰Ø�T×%Ñ%Ñ%Ø×+Ñ+×/Ñ/°Ó7ˆD�ŠLà"ˆD�‰LØ×)Ñ)×-Ñ-¨h¸Ó>ˆˆX‰à�Š>Ü#Ð$GÓHÐHØˆˆ\Ñà×ÒÜ"Ð%:¸4×;KÑ;KÐ:LÐ#MÓNÐNð1	Ø"×/Ñ/ó ,6�
Ø�
Ø'1§~¡~°gÓ'>�
˜8Ñ$Ø%/§^¡^°FÓ%;�
˜6Ñ"Ø)3¯©¸
ÀEÓ)J�
˜:Ñ&Ø&0§n¡n°W¸eÓ&D�
˜7Ñ#Ü! *¨ZÑ"8¼$Ô?Ü#Ð$MÓNÐNÜ! *¨WÑ"5´tÔ<Ü#Ð$JÓKÐKØ˜‘<×%Ñ%Ó'¨9Ò4¸ZÈ
Ò=SÜ*ð9óð ð ˜‘<×%Ñ%Ó'¨7Ò2°zÀ&Ñ7IÈYÒ7VÜ*ð3óð ð  *Ñ,Ø% fÑ-×3Ñ3Ó5×@Ñ@ÀÔHÜ.ð à *¨6Ñ 2× 8Ñ 8Ó :Ð;¸1ð>óð ð
 /9¯n©n¸[Ó.I�J˜{Ñ+ð  
Ñ*Ø! &Ñ)×/Ñ/Ó1°YÒ>Ü.ð=óð ð -7¯N©N¸9Ó,E�J˜yÑ)Ø˜ZÑ'Ø! &Ñ)×/Ñ/Ó1°YÒ>Ü.ð7óð ð *4¯©¸Ó)?�J˜vÑ&Ø�\Ñ"×)Ñ)¨*Ö5ñY,6ðd ×+Ñ+ò 	SˆJÚÜ&Ð)DÀZÀLÐ'QÓRÐRð	Sð ×Ñ×0Ñ0ØÐ/°°tó
ð 	
øôm œNÐ+ò 	Ü"Ü&×-Ñ-¨d×.>Ñ.>Ó?óàðûð	ûôZ ò 	Ü"Ø(¨¨Ð-GÈ
À|ÐTóàðûð	ús1   ¶B:P# ÈGQ# Ð#Q Ð2)QÑQ Ñ#	RÑ,Q>Ñ>R)r  r   r·  r¯   r¸  r   r&   r'   r+  )r(   r)   r*   r+   r$   r‚   r  r  s   @r#   r¯  r¯  t  s>   ø„ ñð,	Uà&ð	Uð ð	Uð #ð		Uð
 
õ	U÷p
r%   r¯  )r2   r   r&   zUnion[List, Tuple])r‘   )r9   r¯   r:   r¯   r&   r†   )r9   r¯   r:   r¯   r&   r¯   )rC   zIterable[str]r:   r¯   r&   r¯   )rH   r¯   rI   r¯   r:   r¯   r&   zTuple[str, str])=r+   Ú
__future__r   r±  r°   rð   Útypingr   r   r   r   r   r	   r
   Ú	constantsr   Údbdocr   Úerrorsr   r   r!   r   Úhelpersr   Úprotobufr   Úresultr   r   r   r   Útypesr   r   r   r   r   r   rÊ  r   r3   r;   r?   rD   rM   rO   rŽ   r  r  r  r-  r7  r_  r}  r„  r’  r˜  r¢  r©  r¯  r,   r%   r#   ú<module>rÞ     sa  ðñ> $å "ã Û Û ç D× DÑ Då %Ý ß 7Ý Ý Ý #ß ;Ó ;÷÷ ð BÐ ÷ñ óô:ô"ô(ð  ;=ðØðØ%(ðØ47ðàó÷,g"ñ g"ôTW"˜)ô W"ôt
?/�9ô ?/ôD'"�Yô '"ôT82�>ô 82÷v ñ  ôFk2Ð)ô k2ô\z0Ð'ô z0ôz%$�Mô %$ôP6�mô 6ôr2�nô 2ôBI2Ð)ô I2ôX%2Ð)ô %2ôP.2Ð)ô .2ôbR
 Yõ R
r%   