Ë
    @Øïi„g  ã                  ód  — d Z ddlmZ ddlZddlZddlmZmZmZm	Z	m
Z
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 dd	lmZmZmZ dd
lmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z) erddl*m+Z+ dZ,dZ-dZ.dZ/dZ0 G d„ d«      Z1 G d„ de1«      Z2 G d„ de1«      Z3 G d„ de1«      Z4 G d„ de4«      Z5y)z,Implementation of the CRUD database objects.é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚDictÚListÚOptionalÚUnioné   )ÚDbDoc)ÚER_NO_SUCH_TABLEÚER_TABLE_EXISTS_ERRORÚER_X_CMD_NUM_ARGUMENTSÚER_X_INVALID_ADMIN_COMMAND)ÚNotSupportedErrorÚOperationalErrorÚProgrammingError)Ú
deprecatedÚescapeÚquote_identifier)	ÚAddStatementÚCreateCollectionIndexStatementÚDeleteStatementÚFindStatementÚInsertStatementÚModifyStatementÚRemoveStatementÚSelectStatementÚUpdateStatement)ÚConnectionTypeÚ
SchemaTypeÚSessionTypeÚ
StrOrBytes)ÚResultz_SELECT COUNT(*) FROM information_schema.views WHERE table_schema = '{0}' AND table_name = '{1}'z`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{0}' AND table_name = '{1}'zJSELECT COUNT(*) FROM information_schema.schemata WHERE schema_name = '{0}'zSELECT COUNT(*) FROM {0}.{1}zDROP TABLE IF EXISTS {0}.{1}c                  ó¶   — e Zd ZdZdd„Zedd„«       Zedd„«       Zedd„«       Zdd„Z	dd„Z
dd„Zdd	„Zdd
„Z edd«      dd„«       Z edd«      dd„«       Zy)ÚDatabaseObjectz¢Provides base functionality for database objects.

    Args:
        schema (mysqlx.Schema): The Schema object.
        name (str): The database object name.
    c                óÜ   — || _         t        |t        «      r|j                  «       n|| _        | j                   j                  «       | _        | j                  j                  «       | _        y ©N)	Ú_schemaÚ
isinstanceÚbytesÚdecodeÚ_nameÚget_sessionÚ_sessionÚget_connectionÚ_connection)ÚselfÚschemaÚnames      úE/var/www/html/aiagents/fe/lib/python3.12/site-packages/mysqlx/crud.pyÚ__init__zDatabaseObject.__init__V   sJ   € Ø#)ˆŒÜ+5°d¼EÔ+B˜$Ÿ+™+œ-ÈˆŒ
Ø%)§\¡\×%=Ñ%=Ó%?ˆŒØ+/¯=©=×+GÑ+GÓ+IˆÕó    c                ó   — | j                   S )z,:class:`mysqlx.Session`: The Session object.©r.   ©r1   s    r4   ÚsessionzDatabaseObject.session\   s   € ð �}‰}Ðr6   c                ó   — | j                   S )z*:class:`mysqlx.Schema`: The Schema object.©r(   r9   s    r4   r2   zDatabaseObject.schemaa   s   € ð �|‰|Ðr6   c                ó   — | j                   S )z&str: The name of this database object.©r,   r9   s    r4   r3   zDatabaseObject.namef   s   € ð �z‰zÐr6   c                ó   — | j                   S )z~Returns the underlying connection.

        Returns:
            mysqlx.connection.Connection: The connection object.
        )r0   r9   s    r4   r/   zDatabaseObject.get_connectionk   s   € ð ×ÑÐr6   c                ó   — | j                   S )zwReturns the session of this database object.

        Returns:
            mysqlx.Session: The Session object.
        r8   r9   s    r4   r-   zDatabaseObject.get_sessions   s   € ð �}‰}Ðr6   c                ó   — | j                   S )z{Returns the Schema object of this database object.

        Returns:
            mysqlx.Schema: The Schema object.
        r<   r9   s    r4   Ú
get_schemazDatabaseObject.get_schema{   s   € ð �|‰|Ðr6   c                ó   — | j                   S )zwReturns the name of this database object.

        Returns:
            str: The name of this database object.
        r>   r9   s    r4   Úget_namezDatabaseObject.get_nameƒ   s   € ð �z‰zÐr6   c                ó   — t         ‚)zÓVerifies if this object exists in the database.

        Returns:
            bool: `True` if object exists in database.

        Raises:
           NotImplementedError: This method must be implemented.
        )ÚNotImplementedErrorr9   s    r4   Úexists_in_databasez!DatabaseObject.exists_in_database‹   s
   € ô "Ð!r6   z8.0.12z)Use 'exists_in_database()' method insteadc                ó"   — | j                  «       S )a+  Verifies if this object exists in the database.

        Returns:
            bool: `True` if object exists in database.

        Raises:
           NotImplementedError: This method must be implemented.

        .. deprecated:: 8.0.12
           Use ``exists_in_database()`` method instead.
        )rG   r9   s    r4   Ú	am_i_realzDatabaseObject.am_i_real–   s   € ð ×&Ñ&Ó(Ð(r6   zUse 'get_name()' method insteadc                ó"   — | j                  «       S )zÅReturns the name of this database object.

        Returns:
            str: The name of this database object.

        .. deprecated:: 8.0.12
           Use ``get_name()`` method instead.
        )rD   r9   s    r4   Úwho_am_izDatabaseObject.who_am_i¥   s   € ð �}‰}‹Ðr6   N)r2   r    r3   r"   ÚreturnÚNone)rL   r!   )rL   r    )rL   Ústr)rL   r   )rL   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r5   Úpropertyr:   r2   r3   r/   r-   rB   rD   rG   r   rI   rK   © r6   r4   r%   r%   N   s›   „ ñóJð òó ðð òó ðð òó ðó óóóó	"ñ �ÐEÓFò)ó Gð)ñ �Ð;Ó<ò	ó =ñ	r6   r%   c                  ó®   ‡ — e Zd ZdZdˆ fd„Zdd„Zdd„Z	 d	 	 	 	 	 dd„Zdd„Zddd„Z	ddd„Z
ddd	„Zdd
„Z	 	 d	 	 	 	 	 	 	 	 	 dd„Z	 d	 	 	 	 	 dd„Zˆ xZS )ÚSchemazÆA client-side representation of a database schema. Provides access to
    the schema contents.

    Args:
        session (mysqlx.XSession): Session object.
        name (str): The Schema name.
    c                ó4   •— || _         t        ‰| �	  | |«       y r'   )r.   Úsuperr5   )r1   r:   r3   Ú	__class__s      €r4   r5   zSchema.__init__»   s   ø€ Ø%,ˆŒÜ‰Ñ˜˜tÕ$r6   c                óŽ   — t         j                  t        | j                  «      «      }| j                  j                  |«      dk(  S ©z�Verifies if this object exists in the database.

        Returns:
            bool: `True` if object exists in database.
        r
   )Ú_COUNT_SCHEMAS_QUERYÚformatr   r,   r0   Úexecute_sql_scalar©r1   Úsqls     r4   rG   zSchema.exists_in_database¿   s9   € ô #×)Ñ)¬&°·±Ó*<Ó=ˆØ×Ñ×2Ñ2°3Ó7¸1Ñ<Ð<r6   c                ó  — | j                   j                  dd| j                  i«      }|j                  «        g }|D ],  }|d   dk7  rŒ	 t	        | |d   «      }|j                  |«       Œ. |S # t
        $ r t	        | |d   «      }Y Œ/w xY w)zyReturns a list of collections for this schema.

        Returns:
            `list`: List of Collection objects.
        Úlist_objectsr2   ÚtypeÚ
COLLECTIONÚ
TABLE_NAMEr3   )r0   Úget_row_resultr,   Ú	fetch_allÚ
CollectionÚ
ValueErrorÚappend)r1   ÚrowsÚcollectionsÚrowÚ
collections        r4   Úget_collectionszSchema.get_collectionsÈ   s¡   € ð ×Ñ×.Ñ.¨~ÀÈ$Ï*É*Ð?UÓVˆØ�‰ÔØˆØò 	+ˆCØ�6‰{˜lÒ*Øð;Ü'¨¨c°,Ñ.?Ó@�
ð ×Ñ˜zÕ*ð	+ð Ðøô ò ;Ü'¨¨c°&©kÓ:’
ð;ús   Á
A.Á.B	ÂB	c                ó&   — | j                  ||«      S )zuReturns a a table object for the given collection

        Returns:
            mysqlx.Table: Table object.

        )Ú	get_table)r1   r3   Úcheck_existences      r4   Úget_collection_as_tablezSchema.get_collection_as_tableÛ   s   € ð �~‰~˜d OÓ4Ð4r6   c                ó  — | j                   j                  dd| j                  i«      }|j                  «        g }d}|D ]+  }|d   |v sŒ	 t	        | |d   «      }|j                  |«       Œ- |S # t
        $ r t	        | |d   «      }Y Œ/w xY w)zoReturns a list of tables for this schema.

        Returns:
            `list`: List of Table objects.
        rb   r2   )ÚTABLEÚVIEWrc   re   r3   )r0   rf   r,   rg   ÚTableri   rj   )r1   rk   ÚtablesÚobject_typesrm   Útables         r4   Ú
get_tableszSchema.get_tablesæ   s¤   € ð ×Ñ×.Ñ.¨~ÀÈ$Ï*É*Ð?UÓVˆØ�‰ÔØˆð
ˆð ò 	%ˆCØ�6‰{˜lÒ*ð5Ü! $¨¨LÑ(9Ó:�Eð —‘˜eÕ$ð	%ð ˆøô "ò 5Ü! $¨¨F©Ó4’Eð5ús   ÁA/Á/B
Â	B
c                óX   — t        | |«      }|r|j                  «       st        d«      ‚|S )zwReturns the table of the given name for this schema.

        Returns:
            mysqlx.Table: Table object.
        zTable does not exist)rw   rG   r   )r1   r3   rr   rz   s       r4   rq   zSchema.get_tableü   s0   € ô �d˜DÓ!ˆÙØ×+Ñ+Ô-Ü&Ð'=Ó>Ð>Øˆr6   c                óX   — t        | |«      }|r|j                  «       st        d«      ‚|S )ztReturns the view of the given name for this schema.

        Returns:
            mysqlx.View: View object.
        zView does not exist)ÚViewrG   r   )r1   r3   rr   Úviews       r4   Úget_viewzSchema.get_view  s0   € ô �D˜$ÓˆÙØ×*Ñ*Ô,Ü&Ð'<Ó=Ð=Øˆr6   c                óX   — t        | |«      }|r|j                  «       st        d«      ‚|S )z†Returns the collection of the given name for this schema.

        Returns:
            mysqlx.Collection: Collection object.
        zCollection does not exist)rh   rG   r   )r1   r3   rr   rn   s       r4   Úget_collectionzSchema.get_collection  s1   € ô    dÓ+ˆ
ÙØ×0Ñ0Ô2Ü&Ð'BÓCÐCØÐr6   c           	     óž   — | j                   j                  dt        j                  t	        | j
                  «      t	        |«      «      d«       y)zmDrops a collection.

        Args:
            name (str): The name of the collection to be dropped.
        r`   FN)r0   Úexecute_nonqueryÚ_DROP_TABLE_QUERYr]   r   r,   )r1   r3   s     r4   Údrop_collectionzSchema.drop_collection   sB   € ð 	×Ñ×)Ñ)ØÜ×$Ñ$Ü  §¡Ó,Ô.>¸tÓ.Dóð õ	
r6   c                óŠ  — |st        d«      ‚d|v rt        j                  dt        «       |d   }t	        | |«      }| j
                  |dœ}|�Út        |t        «      r|st        d«      ‚d}|D ]  }||vsŒt        d|› �«      ‚ g }	d	|v r3|d	   }
t        |
t        «      st        d
«      ‚|	j                  d	|
f«       d|v r^|d   }t        |t        t        f«      st        d«      ‚|	j                  dt        |t        «      rt        j                  |«      n|f«       d|	f|d<   	 | j                  j                  ddd|«       |S # t        $ rp}|j                  t         k(  rt#        d«      |‚|j                  t$        k(  r|s1t        d|› d�«      |‚t        |j&                  |j                  «      |‚Y d}~|S d}~ww xY w)aJ  Creates in the current schema a new collection with the specified
        name and retrieves an object representing the new collection created.

        Args:
            name (str): The name of the collection.
            reuse_existing (bool): `True` to reuse an existing collection.
            validation (Optional[dict]): A dict, containing the keys `level`
                                         with the validation level and `schema`
                                         with a dict or a string representation
                                         of a JSON schema specification.

        Returns:
            mysqlx.Collection: Collection object.

        Raises:
            :class:`mysqlx.ProgrammingError`: If ``reuse_existing`` is False
                                              and collection exists or the
                                              collection name is invalid.
            :class:`mysqlx.NotSupportedError`: If schema validation is not
                                               supported by the server.

        .. versionchanged:: 8.0.21
        úCollection name is invalidÚreusezG'reuse' is deprecated since 8.0.21. Please use 'reuse_existing' instead)r2   r3   NúInvalid value for 'validation'©Úlevelr2   ú Invalid option in 'validation': rŒ   úInvalid value for 'level'r2   úInvalid value for 'schema'Ú
validationÚoptionsÚmysqlxÚcreate_collectionTúlYour MySQL server does not support the requested operation. Please update to MySQL 8.0.19 or a later versionúCollection 'z' already exists)r   ÚwarningsÚwarnÚDeprecationWarningrh   r,   r)   ÚdictrN   rj   ÚjsonÚdumpsr0   r„   r   Úerrnor   r   r   Úmsg)r1   r3   Úreuse_existingr�   Úkwargsrn   ÚfieldsÚvalid_optionsÚoptionr‘   rŒ   r2   Úerrs                r4   r“   zSchema.create_collection.  s  € ñ< Ü"Ð#?Ó@Ð@à�fÑÜ�M‰Mð6ä"ôð
 $ G™_ˆNä  dÓ+ˆ
Ø,0¯J©JÀÑ!EˆàÐ!Ü˜j¬$Ô/±zÜ&Ð'GÓHÐHà/ˆMØ$ò X�Ø Ò.Ü*Ð-MÈfÈXÐ+VÓWÐWðXð ˆGà˜*Ñ$Ø" 7Ñ+�Ü! %¬Ô-Ü*Ð+FÓGÐGØ—‘ ¨Ð/Ô0à˜:Ñ%Ø# HÑ-�Ü! &¬3´¨+Ô6Ü*Ð+GÓHÐHØ—‘à Ü.8¸ÄÔ.FœŸ
™
 6Ô*ÈFðôð ".¨wÐ 7ˆF�9Ñð	DØ×Ñ×-Ñ-ØÐ-¨t°Vôð$ Ðøô  ò 	DØ�y‰yÔ2Ò2Ü'ðóð ð	ð
 �y‰yÔ1Ò1Ù%Ü*Ø& t fÐ,<Ð=óàðô ' s§w¡w°·	±	Ó:ÀÐCó &ð Ðûð	Dús   Ä)E	 Å		GÅA%F=Æ=Gc                óÈ  — |st        d«      ‚t        |t        «      r|st        d«      ‚d}|D ]  }||vsŒt        d|› �«      ‚ g }d|v r3|d   }t        |t        «      st        d«      ‚|j	                  d|f«       d|v r^|d   }t        |t        t        f«      st        d«      ‚|j	                  dt        |t        «      rt        j                  |«      n|f«       | j                  |d	|fd
œ}	 | j                  j                  ddd|«       y# t        $ rE}	|	j                  t        k(  rt        d«      |	‚t        |	j                  |	j                  «      |	‚d}	~	ww xY w)a
  Modifies a collection using a JSON schema validation.

        Args:
            name (str): The name of the collection.
            validation (Optional[dict]): A dict, containing the keys `level`
                                         with the validation level and `schema`
                                         with a dict or a string representation
                                         of a JSON schema specification.

        Raises:
            :class:`mysqlx.ProgrammingError`: If the collection name or
                                              validation is invalid.
            :class:`mysqlx.NotSupportedError`: If schema validation is not
                                               supported by the server.

        .. versionadded:: 8.0.21
        rˆ   rŠ   r‹   r�   rŒ   rŽ   r2   r�   r�   )r2   r3   r‘   r’   Úmodify_collection_optionsTr”   N)r   r)   r™   rN   rj   rš   r›   r,   r0   r„   r   rœ   r   r   r�   )
r1   r3   r�   r¡   r¢   r‘   rŒ   r2   r    r£   s
             r4   Úmodify_collectionzSchema.modify_collection�  sƒ  € ñ( Ü"Ð#?Ó@Ð@ä˜*¤dÔ+±:Ü"Ð#CÓDÐDà+ˆØ ò 	TˆFØ˜]Ò*Ü&Ð)IÈ&ÈÐ'RÓSÐSð	Tð ˆà�jÑ Ø˜wÑ'ˆEÜ˜e¤SÔ)Ü&Ð'BÓCÐCØ�N‰N˜G UÐ+Ô,à�zÑ!Ø Ñ)ˆFÜ˜f¤s¬D kÔ2Ü&Ð'CÓDÐDØ�N‰NàÜ*4°V¼TÔ*B”D—J‘J˜vÔ&Èðôð —j‘jØØ$ gÐ.ñ
ˆð	@Ø×Ñ×-Ñ-ØÐ5°t¸Võøô  ò 	@Ø�y‰yÔ6Ò6Ü'ðóð ð	ô
 # 3§7¡7¨C¯I©IÓ6¸CÐ?ûð	@ús   Ã4D Ä	E!ÄA EÅE!)r:   r!   r3   rN   rL   rM   ©rL   Úbool)rL   zList[Collection])F)r3   rN   rr   r¨   rL   rw   )rL   zList[Table])r3   rN   rr   r¨   rL   r~   )r3   rN   rr   r¨   rL   rh   )r3   rN   rL   rM   )FN)
r3   rN   rž   r¨   r�   ú%Optional[Dict[str, Union[str, Dict]]]rŸ   r   rL   rh   r'   )r3   rN   r�   r©   rL   rM   )rO   rP   rQ   rR   r5   rG   ro   rs   r{   rq   r€   r‚   r†   r“   r¦   Ú__classcell__)rY   s   @r4   rV   rV   ²   sÂ   ø„ ñõ%ó=óð( 27ð	5Øð	5Ø*.ð	5à	ó	5óô,
ô
ô
ó
ð"  %Ø<@ð	]àð]ð ð]ð :ð	]ð
 ð]ð 
ó]ð@ NRðB@ØðB@Ø%JðB@à	÷B@r6   rV   c                  ó~   — e Zd ZdZdd„Zd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y)rh   z�Represents a collection of documents on a schema.

    Args:
        schema (mysqlx.Schema): The Schema object.
        name (str): The collection name.
    c                óÊ   — t         j                  t        | j                  j                  «      t        | j
                  «      «      }| j                  j                  |«      dk(  S r[   ©Ú_COUNT_TABLES_QUERYr]   r   r(   r3   r,   r0   r^   r_   s     r4   rG   zCollection.exists_in_databaseÚ  óJ   € ô "×(Ñ(¬°·±×0AÑ0AÓ)BÄFÈ4Ï:É:ÓDVÓWˆØ×Ñ×2Ñ2°3Ó7¸1Ñ<Ð<r6   Nc                ó\   — t        | |«      }| j                  j                  «       |_        |S )zÔRetrieves documents from a collection.

        Args:
            condition (Optional[str]): The string with the filter expression of
                                       the documents to be retrieved.
        )r   r0   Úget_next_statement_idÚstmt_id©r1   Ú	conditionÚstmts      r4   ÚfindzCollection.findã  s+   € ô ˜T 9Ó-ˆØ×'Ñ'×=Ñ=Ó?ˆŒØˆr6   c                ó2   —  t        | «      j                  |Ž S )zÑAdds a list of documents to a collection.

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

        Returns:
            mysqlx.AddStatement: AddStatement object.
        )r   Úadd)r1   Úvaluess     r4   r¸   zCollection.addî  s   € ð &Œ|˜DÓ!×%Ñ% vÐ.Ð.r6   c                ó\   — t        | |«      }| j                  j                  «       |_        |S )ap  Removes documents based on the ``condition``.

        Args:
            condition (str): The string with the filter expression of the
                             documents to be removed.

        Returns:
            mysqlx.RemoveStatement: RemoveStatement object.

        .. versionchanged:: 8.0.12
           The ``condition`` parameter is now mandatory.
        )r   r0   r±   r²   r³   s      r4   ÚremovezCollection.removeù  ó+   € ô ˜t YÓ/ˆØ×'Ñ'×=Ñ=Ó?ˆŒØˆr6   c                ó\   — t        | |«      }| j                  j                  «       |_        |S )ar  Modifies documents based on the ``condition``.

        Args:
            condition (str): The string with the filter expression of the
                             documents to be modified.

        Returns:
            mysqlx.ModifyStatement: ModifyStatement object.

        .. versionchanged:: 8.0.12
           The ``condition`` parameter is now mandatory.
        )r   r0   r±   r²   r³   s      r4   ÚmodifyzCollection.modify
  r¼   r6   c                óv  — t         j                  t        | j                  j                  «      t        | j
                  «      «      }	 | j                  j                  |«      }|S # t        $ rJ}|j                  t        k(  r1t        d| j
                  › d| j                  j                  › d�«      |‚‚ d}~ww xY w)z}Counts the documents in the collection.

        Returns:
            int: The total of documents in the collection.
        r•   ú' does not exist in schema 'ú'N©Ú_COUNT_QUERYr]   r   r(   r3   r,   r0   r^   r   rœ   r   ©r1   r`   Úresr£   s       r4   ÚcountzCollection.count  s±   € ô ×!Ñ!Ü˜TŸ\™\×.Ñ.Ó/Ô1AÀ$Ç*Á*Ó1Mó
ˆð	Ø×"Ñ"×5Ñ5°cÓ:ˆCð ˆ
øô  ò 	Ø�y‰yÔ,Ò,Ü&Ø" 4§:¡: ,ð /ØŸ™×)Ñ)Ð*¨!ð-óð ðð ûð	úó   ÁA% Á%	B8Á.AB3Â3B8c                ó   — t        | ||«      S )ab  Creates a collection index.

        Args:
            index_name (str): Index name.
            fields_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,
                                                "array": array,
                                                "collation": collation,
                                                "options": options,
                                                "srid": srid},
                                                # {... more members,
                                                #      repeated as many times
                                                #      as needed}
                                                ],
                                    "type": type}
        )r   )r1   Ú
index_nameÚfields_descs      r4   Úcreate_indexzCollection.create_index/  s   € ô0 .¨d°JÀÓLÐLr6   c           	     ó„   — | j                   j                  ddd| j                  j                  | j                  |dœ«       y)z[Drops a collection index.

        Args:
            index_name (str): Index name.
        r’   Údrop_collection_indexF)r2   rn   r3   N)r0   r„   r(   r3   r,   )r1   rÉ   s     r4   Ú
drop_indexzCollection.drop_indexI  s=   € ð 	×Ñ×)Ñ)ØØ#ØàŸ,™,×+Ñ+Ø"Ÿj™jØ"ñõ			
r6   c                ó®   — d|v r|d   |k7  rt        d«      ‚| j                  d«      j                  d|«      j                  d|«      j	                  «       S )zÒReplaces the Document matching the document ID with a new document
        provided.

        Args:
            doc_id (str): Document ID
            doc (:class:`mysqlx.DbDoc` or `dict`): New Document
        Ú_idúKReplacement document has an _id that is different than the matched documentú	_id = :idú$Úid)r   r¾   ÚsetÚbindÚexecute©r1   Údoc_idÚdocs      r4   Úreplace_onezCollection.replace_oneZ  s\   € ð �C‰<˜C ™J¨&Ò0Ü"ð#óð ð �{‰{˜;Ó'×+Ñ+¨C°Ó5×:Ñ:¸4ÀÓH×PÑPÓRÐRr6   c                óà   — d|v r|d   |k7  rt        d«      ‚t        |t        «      st        |«      }| j                  |j	                  |«      «      j                  d«      j                  «       S )zÏUpserts the Document matching the document ID with a new document
        provided.

        Args:
            doc_id (str): Document ID
            doc (:class:`mysqlx.DbDoc` or dict): New Document
        rÐ   rÑ   T)r   r)   r   r¸   ÚcopyÚupsertr×   rØ   s      r4   Úadd_or_replace_onezCollection.add_or_replace_onei  si   € ð �C‰<˜C ™J¨&Ò0Ü"ð#óð ô ˜#œuÔ%Ü˜“*ˆCØ�x‰x˜Ÿ™ Ó(Ó)×0Ñ0°Ó6×>Ñ>Ó@Ð@r6   c                ó¸   — | j                  d«      j                  d|«      j                  «       }|j                  «       }| j                  j                  «        |S )z½Returns a Document matching the Document ID.

        Args:
            doc_id (str): Document ID

        Returns:
            mysqlx.DbDoc: The Document matching the Document ID.
        rÒ   rÔ   )r¶   rÖ   r×   Ú	fetch_oner0   Úfetch_active_result)r1   rÙ   ÚresultrÚ   s       r4   Úget_onezCollection.get_onez  sM   € ð —‘˜;Ó'×,Ñ,¨T°6Ó:×BÑBÓDˆØ×ÑÓ ˆØ×Ñ×,Ñ,Ô.Øˆ
r6   c                ó`   — | j                  d«      j                  d|«      j                  «       S )z¦Removes a Document matching the Document ID.

        Args:
            doc_id (str): Document ID

        Returns:
            mysqlx.Result: Result object.
        rÒ   rÔ   )r»   rÖ   r×   )r1   rÙ   s     r4   Ú
remove_onezCollection.remove_oneˆ  s)   € ð �{‰{˜;Ó'×,Ñ,¨T°6Ó:×BÑBÓDÐDr6   r§   r'   )r´   zOptional[str]rL   r   )r¹   r   rL   r   )r´   rN   rL   r   )r´   rN   rL   r   ©rL   Úint)rÉ   rN   rÊ   zDict[str, Any]rL   r   )rÉ   rN   rL   rM   )rÙ   rN   rÚ   zUnion[Dict, DbDoc]rL   ú'Result')rÙ   rN   rL   r   )rÙ   rN   rL   ré   )rO   rP   rQ   rR   rG   r¶   r¸   r»   r¾   rÆ   rË   rÎ   rÛ   rß   rä   ræ   rT   r6   r4   rh   rh   Ò  sb   „ ñó=ô	ó	/óó"ó"ð(MØðMØ,:ðMà	'óMó4
ó"SóAó"ô	Er6   rh   c                  óH   — e Zd ZdZd
d„Zdd„Zdd„Zdd„Zdd„Zdd„Z	d
d„Z
y	)rw   zîRepresents a database table on a schema.

    Provides access to the table through standard INSERT/SELECT/UPDATE/DELETE
    statements.

    Args:
        schema (mysqlx.Schema): The Schema object.
        name (str): The table name.
    c                óÊ   — t         j                  t        | j                  j                  «      t        | j
                  «      «      }| j                  j                  |«      dk(  S r[   r­   r_   s     r4   rG   zTable.exists_in_databaseŸ  r¯   r6   c                ó\   — t        | g|¢­Ž }| j                  j                  «       |_        |S )zËCreates a new :class:`mysqlx.SelectStatement` object.

        Args:
            *fields: The fields to be retrieved.

        Returns:
            mysqlx.SelectStatement: SelectStatement object
        )r   r0   r±   r²   ©r1   r    rµ   s      r4   ÚselectzTable.select¨  ó.   € ô ˜tÐ- fÒ-ˆØ×'Ñ'×=Ñ=Ó?ˆŒØˆr6   c                ó\   — t        | g|¢­Ž }| j                  j                  «       |_        |S )zÊCreates a new :class:`mysqlx.InsertStatement` object.

        Args:
            *fields: The fields to be inserted.

        Returns:
            mysqlx.InsertStatement: InsertStatement object
        )r   r0   r±   r²   rí   s      r4   ÚinsertzTable.insertµ  rï   r6   c                óZ   — t        | «      }| j                  j                  «       |_        |S )z‹Creates a new :class:`mysqlx.UpdateStatement` object.

        Returns:
            mysqlx.UpdateStatement: UpdateStatement object
        )r   r0   r±   r²   ©r1   rµ   s     r4   ÚupdatezTable.updateÂ  s)   € ô ˜tÓ$ˆØ×'Ñ'×=Ñ=Ó?ˆŒØˆr6   c                óZ   — t        | «      }| j                  j                  «       |_        |S )zãCreates a new :class:`mysqlx.DeleteStatement` object.

        Returns:
            mysqlx.DeleteStatement: DeleteStatement object

        .. versionchanged:: 8.0.12
           The ``condition`` parameter was removed.
        )r   r0   r±   r²   ró   s     r4   ÚdeletezTable.deleteÌ  s)   € ô ˜tÓ$ˆØ×'Ñ'×=Ñ=Ó?ˆŒØˆr6   c                óv  — t         j                  t        | j                  j                  «      t        | j
                  «      «      }	 | j                  j                  |«      }|S # t        $ rJ}|j                  t        k(  r1t        d| j
                  › d| j                  j                  › d�«      |‚‚ d}~ww xY w)ziCounts the rows in the table.

        Returns:
            int: The total of rows in the table.
        zTable 'rÀ   rÁ   NrÂ   rÄ   s       r4   rÆ   zTable.countÙ  s±   € ô ×!Ñ!Ü˜TŸ\™\×.Ñ.Ó/Ô1AÀ$Ç*Á*Ó1Mó
ˆð	Ø×"Ñ"×5Ñ5°cÓ:ˆCð ˆ
øô  ò 	Ø�y‰yÔ,Ò,Ü&Ø˜dŸj™j˜\ð *ØŸ™×)Ñ)Ð*¨!ð-óð ðð ûð	úrÇ   c                óÊ   — t         j                  t        | j                  j                  «      t        | j
                  «      «      }| j                  j                  |«      dk(  S )zŒDetermine if the underlying object is a view or not.

        Returns:
            bool: `True` if the underlying object is a view.
        r
   ©Ú_COUNT_VIEWS_QUERYr]   r   r(   r3   r,   r0   r^   r_   s     r4   Úis_viewzTable.is_viewí  óJ   € ô !×'Ñ'¬¨t¯|©|×/@Ñ/@Ó(AÄ6È$Ï*É*ÓCUÓVˆØ×Ñ×2Ñ2°3Ó7¸1Ñ<Ð<r6   Nr§   )r    rN   rL   r   )r    r   rL   r   )rL   r   )rL   r   rç   )rO   rP   rQ   rR   rG   rî   rñ   rô   rö   rÆ   rû   rT   r6   r4   rw   rw   ”  s*   „ ñó=óóóóóô(=r6   rw   c                  ó   — e Zd ZdZdd„Zy)r~   zÌRepresents a database view on a schema.

    Provides a mechanism for creating, alter and drop views.

    Args:
        schema (mysqlx.Schema): The Schema object.
        name (str): The table name.
    c                óÊ   — t         j                  t        | j                  j                  «      t        | j
                  «      «      }| j                  j                  |«      dk(  S r[   rù   r_   s     r4   rG   zView.exists_in_database  rü   r6   Nr§   )rO   rP   rQ   rR   rG   rT   r6   r4   r~   r~   ÷  s   „ ñô=r6   r~   )6rR   Ú
__future__r   rš   r–   Útypingr   r   r   r   r   r	   Údbdocr   Ú	errorcoder   r   r   r   Úerrorsr   r   r   Úhelpersr   r   r   Ú	statementr   r   r   r   r   r   r   r   r   Útypesr   r    r!   r"   rã   r#   rú   r®   r\   rÃ   r…   r%   rV   rh   rw   r~   rT   r6   r4   ú<module>r     sÉ   ðñ: 3å "ã Û ç B× Bå ÷ó ÷ JÑ Iß 9Ñ 9÷
÷ 
õ 
÷ GÓ FáÝð8ð ð
8ð ð
 Qð ð .€Ø2Ð ÷añ aôH]@ˆ^ô ]@ô@	E�ô EôD`=ˆNô `=ôF=ˆ5õ =r6   