
    iK                    $   d Z ddlmZ ddlmZmZ ddlmZmZ ddl	mZm
Z
 ddlmZ ddlmZ dd	lmZ erdd
lmZ ej&                  Z ed      Z G d dej,                  e      Z G d dej.                  e      Z G d de      Z G d de      Zy)z)
Entry point into the adaptation system.
    )annotations)ABCabstractmethod)TYPE_CHECKINGAny   )abcpq)PyFormat)Transformer)AdaptersMap)BaseConnection\c                      e Zd ZU dZdZded<   	 ej                  j                  Z	ded<   	 dddZ
dd	Zedd
       ZddZddZddZy)DumperzP
    Convert Python object of the type `!cls` to PostgreSQL representation.
    r   intoid	pq.FormatformatNc                L    || _         |  |r|j                  | _        y d | _        y N)cls
connection)selfr   contexts      m/var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/venv/lib/python3.12/site-packages/psycopg/adapt.py__init__zDumper.__init__&   !    07',,T    c           
         dt        |       j                   dt        |       j                   d| j                   dt	        |       dd	S )N<.z (oid=z) at 0xx>)type
__module____qualname__r   id)r   s    r   __repr__zDumper.__repr__+   sH    T
%%&aT
(?(?'@TXXJgbhq\4	
r   c                     y r    )r   objs     r   dumpzDumper.dump1   s    /2r   c                   | j                  |      x}y| j                  r:t        j                  | j                  j                        }|j                  |      S t        j                         }|j                  |      }t        |vrd|z   dz   S d|z   dz   }|j                  d      dk(  r|j                  dd      }|S )z
        By default return the `dump()` value quoted and sanitised, so
        that the result can be used to build a SQL string. This works well
        for most types and you won't likely have to implement this method in a
        subclass.
        s   NULL   's    E'   \s   \\)	r-   r   r
   Escapingpgconnescape_literalescape_stringORD_BSreplace)r   r,   valueescoutrvs         r   quotezDumper.quote4   s     YYs^#E,??++doo445C%%e,, kkm&  #:$$ SL4'U#u,E7+B	r   c                    | j                   S )a  
        Implementation of the `~psycopg.abc.Dumper.get_key()` member of the
        `~psycopg.abc.Dumper` protocol. Look at its definition for details.

        This implementation returns the `!cls` passed in the constructor.
        Subclasses needing to specialise the PostgreSQL type according to the
        *value* of the object dumped (not only according to to its type)
        should override this class.

        )r   r   r,   r   s      r   get_keyzDumper.get_key`   s     xxr   c                    | S )a/  
        Implementation of the `~psycopg.abc.Dumper.upgrade()` member of the
        `~psycopg.abc.Dumper` protocol. Look at its definition for details.

        This implementation just returns `!self`. If a subclass implements
        `get_key()` it should probably override `!upgrade()` too.
        r+   r=   s      r   upgradezDumper.upgradem   s	     r   r   r   r%   r   abc.AdaptContext | None)returnstr)r,   r   rC   zBuffer | None)r,   r   rC   Buffer)r,   r   r   r   rC   zabc.DumperKey)r,   r   r   r   rC   r   )__name__r&   r'   __doc__r   __annotations__r
   FormatTEXTr   r   r)   r   r-   r;   r>   r@   r+   r   r   r   r      sU     CL2		FI&(B

 2 2*Xr   r   c                  f    e Zd ZU dZej
                  j                  Zded<   	 dddZ	e
d	d       Zy)
LoaderzK
    Convert PostgreSQL values with type OID `!oid` to Python objects.
    r   r   Nc                L    || _         |  |r|j                  | _        y d | _        y r   )r   r   )r   r   r   s      r   r   zLoader.__init__   r   r   c                     y)z.Convert a PostgreSQL value to a Python object.Nr+   )r   datas     r   loadzLoader.load   s     	r   r   r   r   r   rB   )rO   rE   rC   r   )rF   r&   r'   rG   r
   rI   rJ   r   rH   r   r   rP   r+   r   r   rL   rL   x   s8     		FI&(B
  r   rL   c                  &     e Zd ZdZdd fdZ xZS )RecursiveDumperz:Dumper with a transformer to help dumping recursive types.c                Z    t         |   ||       t        j                  |      | _        y r   superr   r   from_context_tx)r   r   r   	__class__s      r   r   zRecursiveDumper.__init__   $    g&++G4r   r   rA   rF   r&   r'   rG   r   __classcell__rY   s   @r   rS   rS          D5 5r   rS   c                  &     e Zd ZdZdd fdZ xZS )RecursiveLoaderz:Loader with a transformer to help loading recursive types.c                Z    t         |   ||       t        j                  |      | _        y r   rU   )r   r   r   rY   s      r   r   zRecursiveLoader.__init__   rZ   r   r   rQ   r[   r]   s   @r   r`   r`      r^   r   r`   N)rG   
__future__r   r	   r   r   typingr   r    r
   _enumsr   _transformerr   _adapters_mapr   _connection_baser   rE   ordr5   r   rL   rS   r`   r+   r   r   <module>rj      sz    # # %  ) 4 50		TZSZZ ZzSZZ &5f 55f 5r   