o
    ˜"4gy
  ã                   @  s<  d Z ddl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 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ erjddlmZ ddlmZ ddl m!Z! ej"j#Z#ej"j$Z$G dd„ deeef ƒZ%G dd„ de%def ee ƒZ&G dd„ de%def ee ƒZ'dS )z%
psycopg client-side binding cursors
é    )Úannotations)ÚTYPE_CHECKING)Úpartialé   )ÚPostgresQueryÚPostgresClientQuery)Úpq)Úadapt)Úerrors)ÚConnectionTypeÚQueryÚParams)ÚRow)ÚCursor)ÚPrepare)Ú
BaseCursor)ÚAsyncCursor)ÚAny)Ú
Connection)ÚAsyncConnectionc                   @  s<   e Zd ZeZdddd	„Zd
ddœddd„Z	dddd„ZdS )ÚClientCursorMixinNÚqueryr   ÚparamsúParams | NoneÚreturnÚstrc                 C  s(   t  | ¡| _|  ||¡}|j | jj¡S )z£
        Return the query and parameters merged.

        Parameters are adapted and merged to the query the same way that
        `!execute()` would do.

        )r	   ÚTransformerÚ_txÚ_convert_queryr   ÚdecodeÚencoding)Úselfr   r   Úpgq© r#   ú^/var/www/html/authentication-server/venv/lib/python3.10/site-packages/psycopg/client_cursor.pyÚmogrify$   s   zClientCursorMixin.mogrifyF)Úforce_extendedÚbinaryr   r&   Úboolr'   úbool | NoneÚNonec                C  sˆ   |d u r| j }n|rtnt}|tkrt d¡‚|| _| jjr/| jjj 	t
| jj|jd ƒ¡ d S |r;| j |jd ¡ d S | j |j¡ d S )Nz0client-side cursors don't support binary results)ÚformatÚBINARYÚTEXTÚeÚNotSupportedErrorÚ_queryÚ_connÚ	_pipelineÚcommand_queueÚappendr   Ú_pgconnÚsend_query_paramsr   Ú
send_query)r!   r   r&   r'   Úfmtr#   r#   r$   Ú_execute_send0   s   ÿ
ÿzClientCursorMixin._execute_sendr"   Úprepareútuple[Prepare, bytes]c                 C  s
   t jdfS )Nó    )r   ÚNO)r!   r"   r:   r#   r#   r$   Ú_get_preparedP   s   
zClientCursorMixin._get_prepared)N)r   r   r   r   r   r   )r   r   r&   r(   r'   r)   r   r*   )r"   r   r:   r)   r   r;   )Ú__name__Ú
__module__Ú__qualname__r   Ú
_query_clsr%   r9   r>   r#   r#   r#   r$   r   !   s    û!ÿr   c                   @  ó   e Zd ZdZdS )ÚClientCursorÚpsycopgN©r?   r@   rA   r#   r#   r#   r$   rD   V   s    rD   zConnection[Any]c                   @  rC   )ÚAsyncClientCursorrE   NrF   r#   r#   r#   r$   rG   Z   s    rG   zAsyncConnection[Any]N)(Ú__doc__Ú
__future__r   Útypingr   Ú	functoolsr   Ú_queriesr   r   Ú r   r	   r
   r.   Úabcr   r   r   Úrowsr   Úcursorr   Ú
_preparingr   Ú_cursor_baser   Úcursor_asyncr   r   Ú
connectionr   Úconnection_asyncr   ÚFormatr-   r,   r   rD   rG   r#   r#   r#   r$   Ú<module>   s2    5
ÿ