
    nh@                        d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
mZ ddlmZ erddlmZ 	 	 	 	 	 	 	 	 	 	 d
dZ	 	 	 	 	 	 ddZy	)zRConstants, types, and classes shared across Client Bulk Write API implementations.    )annotations)TYPE_CHECKINGAnyMappingMutableMappingNoReturn)ClientBulkWriteExceptionOperationFailure)_get_wce_doc)_DocumentOutc                H   |j                  d      r|d   |d<   |dxx   |j                  dd      z  cc<   |dxx   |j                  dd      z  cc<   |dxx   |j                  dd      z  cc<   |dxx   |j                  dd      z  cc<   |dxx   |j                  dd      z  cc<   |j                  d      }|rC|D ]>  }|j                         }|d	   |z   }||d	<   | |   d
   |d<   |d   j                  |       @ t        |      }|r|d   j                  |       yy)z?Merge result of a single bulk write batch into the full result.error	nInsertedr   nDeletednMatched	nModified	nUpsertedwriteErrorsidx   opwriteConcernErrorsN)getcopyappendr   )	opsoffsetfull_resultresultwrite_errorsdocreplacementoriginal_indexwces	            /var/www/html/SchoolMeal/SchoolMeal/pds_admin_SchoolMeal/Backend/venv/lib/python3.12/site-packages/pymongo/_client_bulk_shared.py_merge_commandr&      s7    zz'%gG

; ::
vzz*a88
vzz*a88

; ::

; ::::m,L 	;C((*K Z&0N!/K #N 3A 6K&--k:	; v
C
()005     c                   | d   rM| d   j                  d        | d   d   }|d   }|d   }|dk(  r |j                  d      rd	}t        |||       t        | d
   t              rt        | |      | d
   t        | |      )z6Raise a ClientBulkWriteException from the full result.r   c                    | d   S )Nr    )r   s    r%   <lambda>z4_throw_client_bulk_write_exception.<locals>.<lambda>B   s
    %, r'   )keyr   codeerrmsg   zTransaction numberszrThis MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.r   )sort
startswithr
   
isinstanceBaseExceptionr	   )r   verbose_resultserrr-   msgr.   s         r%   "_throw_client_bulk_write_exceptionr7   <   s    
 =!M"'',F'G-(+6{(m2:#..)>?- 
 #64==+g&6&{OD+V]J^^
";
@@r'   N)
r   z#list[tuple[str, Mapping[str, Any]]]r   intr   zMutableMapping[str, Any]r   zMapping[str, Any]returnNone)r   r   r4   boolr9   r   )__doc__
__future__r   typingr   r   r   r   r   pymongo.errorsr	   r
   pymongo.helpers_sharedr   pymongo.typingsr   r&   r7   r*   r'   r%   <module>rB      su     Y " H H E /,6	,66 *6 	6
 
6@AA04AAr'   