
    ۇeh,$                        d dl Z d dlZd dlZdZd Z G d de          Z G d de          Z G d	 d
ee          Z	 G d de	          Z
 G d de
          Z G d d          Z G d dee          Z G d dee          Z G d dee          Z G d de          Z G d de          Z G d dee          Z G d de          Z G d d e          Z G d! d"e          Z G d# d$e          Z G d% d&e          ZdS )'    N)PostgresErrorFatalPostgresErrorUnknownPostgresErrorInterfaceErrorInterfaceWarningPostgresLogMessageClientConfigurationErrorInternalClientErrorOutdatedSchemaCacheErrorProtocolErrorUnsupportedClientFeatureErrorTargetServerAttributeNotMatchedUnsupportedServerFeatureErrorc                 F    | j         }|dk    p|                    d          S )Nasyncpgzasyncpg.)
__module__
startswith)clsmodnames     J/var/www/api/venv/lib/python3.11/site-packages/asyncpg/exceptions/_base.py_is_asyncpg_classr      s'    nGiA7#5#5j#A#AA    c                        e Zd Zi Zi ddddddddd	d
dddddddddddddddddddddd d!d"d#d$iZ fd%Zed&             Z xZS )'PostgresMessageMetaSseverityVseverity_enCsqlstateMmessageDdetailHhintPpositionpinternal_positionqinternal_queryWcontextsschema_namet
table_nameccolumn_nameddata_type_namenconstraint_nameFserver_source_filenameLserver_source_lineRserver_source_functionc                 P   t                                          | |||          }|j        | j        k    r3|dk    r-| j                                        D ]}t          ||d            t          |          rIt          j        |j                 }t          ||          r"t          d                    |                    |                    d          }|N| j                            |          }|(t          d                    ||j                            || j        |<   |S )NPostgresMessagez exception class redefinition: {}r    z={} has duplicate SQLSTATE code, which isalready defined by {})super__new__r   
_field_mapvaluessetattrr   sysmoduleshasattrRuntimeErrorformatget_message_map	TypeError__name__)
mclsnamebasesdctr   fmodcodeexisting	__class__s
            r   rB   zPostgresMessageMeta.__new__2   s9   ggoodD%55>T_,,9J1J1J_++-- & &Q%%%%S!! 	+cn-CsD!! "#E#L#L$ $    wwz""(,,T22H# !88>$((*;9= 9=> > > '*Dd#
r   c                 B    | j                             |t                    S N)rL   rK   r   )rO   rU   s     r   get_message_class_for_sqlstatez2PostgresMessageMeta.get_message_class_for_sqlstateI   s     $$T+?@@@r   )	rN   r   __qualname__rL   rC   rB   classmethodrZ   __classcell__rW   s   @r   r   r      sF       LZ] 	Z 	Y	
 	X 	V 	Z 	  	 	Y 	] 	\ 	] 	 	  	%!" 	!#$ 	%% J*    . A A [A A A A Ar   r   c                   X    e Zd Zed             Zed             Zedd            Zd ZdS )r@   c                 p    |                     d          }t          |                               |          S )Nr   )rK   typerZ   )r   fieldsr    s      r   _get_error_classz PostgresMessage._get_error_classP   s+    ::c??Cyy77AAAr   c                     d|i}t          |           j        }|                                D ]!\  }}|                    |          }|r|||<   "|S )Nquery)ra   rC   itemsrK   )r   rb   re   rR   	field_mapkvfields           r   _get_error_dictzPostgresMessage._get_error_dictU   sc     U
 II(	LLNN 	 	DAqMM!$$E E

r   Nc                    |                      ||          }|                     |          }|                    dd          }|j        dk    o't	          |          o|                    d          dk    }|r t
          j        |j                 }|j        }d}|j        dv ot	          |          }|r2|                    dd          }	|	t          j
        d	          z  }	|	|d<   |||fS )
Nr"    FeatureNotSupportedErrorr>   RevalidateCachedQueryzQcached statement plan is invalid due to a database schema or configuration change)DuplicatePreparedStatementErrorInvalidSQLStatementNameErrorr&   a  
                NOTE: pgbouncer with pool_mode set to "transaction" or
                "statement" does not support prepared statements properly.
                You have two options:

                * if you are using pgbouncer for connection pooling to a
                  single server, switch to the connection pool functionality
                  provided by asyncpg, it is a much better option for this
                  purpose;

                * if you have no option of avoiding the use of pgbouncer,
                  then you can set statement_cache_size to 0 when creating
                  the asyncpg connection object.
            )rk   rc   rK   rN   r   rF   rG   r   InvalidCachedStatementErrortextwrapdedent)
r   rb   re   rR   excclsr"   is_icse
exceptionsis_prepared_stmt_errorr&   s
             r   _make_constructorz!PostgresMessage._make_constructorc   s   !!&%00%%f--'')R(( O99 If%%IGG,--1HH 	  	9V%67J;F8G O  @ @ &f%% 	 " 	7762&&DHO %   D  CKw##r   c                     i }t          |           j                                        D ]}t          | |          }||||<   |S rY   )ra   rC   rD   getattr)selfrR   rS   vals       r   as_dictzPostgresMessage.as_dict   sN    d&--// 	 	A$""CA
r   rY   )rN   r   r[   r\   rc   rk   ry   r~    r   r   r@   r@   N   s{        B B [B   [ 6$ 6$ 6$ [6$p    r   r@   )	metaclassc                   0    e Zd ZdZd Zedd            ZdS )r   z#Base class for all Postgres errors.c                     | j         d         }| j        r|d                    | j                  z  }| j        r|d                    | j                  z  }|S Nr   z
DETAIL:  {}z

HINT:  {}argsr$   rJ   r&   r|   msgs     r   __str__zPostgresError.__str__   Z    il; 	7?))$+666C9 	3=''	222C
r   Nc                     |                      ||          \  }}} ||          }|j                            |           |S rY   )ry   __dict__update)r   rb   re   ru   r"   rR   exs          r   newzPostgresError.new   sF    "44VUCCVG__
3	r   rY   )rN   r   r[   __doc__r   r\   r   r   r   r   r   r      sI        --      [  r   r   c                       e Zd ZdZdS )r   z9A fatal error that should result in server disconnection.NrN   r   r[   r   r   r   r   r   r      s        CCCCr   r   c                       e Zd ZdZdS )r   z'An error with an unknown SQLSTATE code.Nr   r   r   r   r   r              1111r   r   c                   "    e Zd ZddddZd ZdS )InterfaceMessageNr$   r&   c                "    || _         || _        d S rY   r   )r|   r$   r&   s      r   __init__zInterfaceMessage.__init__   s    			r   c                     | j         d         }| j        r|d                    | j                  z  }| j        r|d                    | j                  z  }|S r   r   r   s     r   r   zInterfaceMessage.__str__   r   r   )rN   r   r[   r   r   r   r   r   r   r      sA        !%D         r   r   c                   &    e Zd ZdZddddZd ZdS )r   z/An error caused by improper use of asyncpg API.Nr   c                v    t                               | ||           t                              | |           d S Nr   )r   r   	Exceptionr|   r   r$   r&   s       r   r   zInterfaceError.__init__   s9    !!$vD!AAA4%%%%%r   c                 |     t          |           || j        | j                                      | j                  S r   )ra   r$   r&   with_traceback__traceback__r   s     r   with_msgzInterfaceError.with_msg   sE    tDzz;
 
 
 .
 
		
r   )rN   r   r[   r   r   r   r   r   r   r   r      sG        99&* & & & & &
 
 
 
 
r   r   c                       e Zd ZdZdS )r	   z1An error caused by improper client configuration.Nr   r   r   r   r	   r	      s        ;;;;r   r	   c                       e Zd ZdZdS )	DataErrorz'An error caused by invalid query input.Nr   r   r   r   r   r      r   r   r   c                       e Zd ZdZdS )r   z,Requested feature is unsupported by asyncpg.Nr   r   r   r   r   r      s        6666r   r   c                       e Zd ZdZdS )r   z6Requested feature is unsupported by PostgreSQL server.Nr   r   r   r   r   r      s        @@@@r   r   c                        e Zd ZdZddddZdS )r   z3A warning caused by an improper use of asyncpg API.Nr   c                v    t                               | ||           t                              | |           d S r   )r   r   UserWarningr   s       r   r   zInterfaceWarning.__init__   s9    !!$vD!AAAT3'''''r   )rN   r   r[   r   r   r   r   r   r   r      s8        ==&* ( ( ( ( ( ( (r   r   c                       e Zd ZdZdS )r
   z/All unexpected errors not classified otherwise.Nr   r   r   r   r
   r
      s        9999r   r
   c                       e Zd ZdZdS )r   zBUnexpected condition in the handling of PostgreSQL protocol input.Nr   r   r   r   r   r      s        LLLLr   r   c                       e Zd ZdZdS )r   zECould not find a host that satisfies the target attribute requirementNr   r   r   r   r   r     s        OOOOr   r   c                   ,     e Zd ZdZdddd fd
Z xZS )r   zEA value decoding error caused by a schema change before row fetching.N)schema	data_typer(   c                t    t                                          |           || _        || _        || _        d S rY   )rA   r   r0   r6   r(   )r|   r   r   r   r(   rW   s        r   r   z!OutdatedSchemaCacheError.__init__  s6    !' r   )rN   r   r[   r   r   r]   r^   s   @r   r   r     sO        OO&*dT ! ! ! ! ! ! ! ! ! ! !r   r   c                   6    e Zd ZdZd Zd Zedd            ZdS )r   z+A base class for non-error server messages.c                 \    d                     t          |           j        | j                  S )Nz{}: {})rJ   ra   rN   r"   )r|   s    r   r   zPostgresLogMessage.__str__  s!    tDzz2DLAAAr   c                 j    t          d                    t          |           j                            )Nzinstances of {} are immutable)rM   rJ   ra   rN   )r|   rP   r}   s      r   __setattr__zPostgresLogMessage.__setattr__  s3    7>>JJ! ! " " 	"r   Nc                    |                      ||          \  }}}|t          u rt          }|t          u rP|                    d          p|                    d          }|r$|                                dk    rt
          j        }t          |t          t          f          r ||          }n
 |            }|j
                            |           |S )Nr   r   WARNING)ry   r   r   rK   upperr   PostgresWarning
issubclassBaseExceptionWarningr   r   )r   rb   re   ru   message_textrR   r   r   s           r   r   zPostgresLogMessage.new  s    $'$9$9&%$H$H!c)))'F'''ww}--D1D1DH 1HNN,,	99 0f}g677 	&&&CC&((CC   
r   rY   )rN   r   r[   r   r   r   r\   r   r   r   r   r   r     s[        55B B B" " "    [  r   r   )r   rF   rs   __all__r   ra   r   r@   r   r   r   r   r   r   
ValueErrorr	   r   r   r   r   r   r
   r   r   r   r   r   r   r   <module>r      sV    



 ,B B B
1A 1A 1A 1A 1A$ 1A 1A 1AhT T T T T 3 T T T Tn    OY   (D D D D D D D D2 2 2 2 2- 2 2 2       
 
 
 
 
%y 
 
 
"< < < < <~z < < <2 2 2 2 2
 2 2 27 7 7 7 7N 7 7 7A A A A AN A A A( ( ( ( (' ( ( (: : : : :) : : :M M M M M' M M MP P P P P&9 P P P! ! ! ! !2 ! ! !         r   