
    [h                       d 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 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
 ddlmZ ddlmZ erd	dlmZ d	dlmZ d	dlmZ  e	de          ZeefZ	  G d dej                  ZeZ G d dej                  Z G d dej                  Z G d dej                   Z! G d dej                  Z" G d d ej                  Z# G d! d"e!          Z$ G d# d$e!          Z% G d% d&ej                   Z& G d' d(ej                   Z' G d) d*ej                   Z(d4d/Z) e
j*        d0          d5d2            Z+d3S )6zSQLAlchemy ORM exceptions.    )annotations)Any)Optional)Tuple)Type)TYPE_CHECKING)TypeVar   )_mapper_property_as_plain_name   )exc)util)MultipleResultsFound)NoResultFound)LoaderStrategy)MapperProperty)InstanceState_T)boundc                      e Zd ZdZdS )StaleDataErroraa  An operation encountered database state that is unaccounted for.

    Conditions which cause this to happen include:

    * A flush may have attempted to update or delete rows
      and an unexpected number of rows were matched during
      the UPDATE or DELETE statement.   Note that when
      version_id_col is used, rows in UPDATE or DELETE statements
      are also matched against the current known version
      identifier.

    * A mapped object with version_id_col was refreshed,
      and the version number coming back from the database does
      not match that of the object itself.

    * A object is detached from its parent object, however
      the object was previously attached to a different parent
      identity which was garbage collected, and a decision
      cannot be made if the new parent was really the most
      recent "parent".

    N__name__
__module____qualname____doc__     a/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/orm/exc.pyr   r   $   s           r   r   c                      e Zd ZdZdS )
FlushErrorz0A invalid condition was detected during flush().Nr   r   r   r   r!   r!   @   s        ::::r   r!   c                      e Zd ZdZdS )MappedAnnotationErrorzRaised when ORM annotated declarative cannot interpret the
    expression present inside of the :class:`.Mapped` construct.

    .. versionadded:: 2.0.40

    Nr   r   r   r   r#   r#   D   s           r   r#   c                      e Zd ZdZdS )UnmappedErrorz?Base for exceptions that involve expected mappings not present.Nr   r   r   r   r%   r%   M   s        IIIIr   r%   c                      e Zd ZdZdS )ObjectDereferencedErrorzPAn operation cannot complete due to an object being garbage
    collected.

    Nr   r   r   r   r'   r'   Q   s           r   r'   c                      e Zd ZdZdZdS )DetachedInstanceErrorzSAn attempt to access unloaded attributes on a
    mapped instance that is detached.bhk3N)r   r   r   r   coder   r   r   r)   r)   X   s        ) ) DDDr   r)   c                  P    e Zd ZdZ ej        d          ddd            ZddZdS )UnmappedInstanceErrorz;An mapping operation was requested for an unknown instance.sqlalchemy.orm.baseNobjobjectmsgOptional[str]c                   t           j        j        }|s	 |                    t	          |                     t          t	          |                    }d|d|d}nZ# t          $ rM dt          t	          |                     d}t          |t                    r|dt          |          z  z  }Y nw xY wt          	                    | |           d S )NzClass z| is mapped, but this instance lacks instrumentation.  This occurs when the instance is created before sqlalchemy.orm.mapper(z) was called.Class '' is not mappedz;; was a class (%s) supplied where an instance was required?)
r   	preloadedorm_baseclass_mappertype_safe_cls_nameUnmappedClassError
isinstancer%   __init__)selfr/   r1   basenames        r   r=   zUnmappedInstanceError.__init__b   s    ~& 	!!$s)),,,%d3ii00
 &*TT4441  &   JtCyy 9 9JJJc4(( $&4S&9&9:C 	tS)))))s   AA AB43B4returnr   c                .    | j         d | j        d         ffS Nr   	__class__argsr>   s    r   
__reduce__z UnmappedInstanceError.__reduce__y       ~dil333r   N)r/   r0   r1   r2   rA   r   r   r   r   r   r   preload_moduler=   rH   r   r   r   r-   r-   _   s`        EET.//* * * * 0/*,4 4 4 4 4 4r   r-   c                  $    e Zd ZdZdddZdd
ZdS )r;   z8An mapping operation was requested for an unknown class.NclsType[_T]r1   r2   c                ^    |st          |          }t                              | |           d S rJ   )_default_unmappedr%   r=   )r>   rO   r1   s      r   r=   zUnmappedClassError.__init__   s3     	)#C((CtS)))))r   rA   r   c                .    | j         d | j        d         ffS rC   rD   rG   s    r   rH   zUnmappedClassError.__reduce__   rI   r   rJ   )rO   rP   r1   r2   rK   )r   r   r   r   r=   rH   r   r   r   r;   r;   }   sG        BB* * * * *
4 4 4 4 4 4r   r;   c                  P    e Zd ZdZ ej        d          ddd            ZddZdS )ObjectDeletedErrora  A refresh operation failed to retrieve the database
    row corresponding to an object's known primary key identity.

    A refresh operation proceeds when an expired attribute is
    accessed on an object, or when :meth:`_query.Query.get` is
    used to retrieve an object which is, upon retrieval, detected
    as expired.   A SELECT is emitted for the target row
    based on primary key; if no row is returned, this
    exception is raised.

    The true meaning of this exception is simply that
    no row exists for the primary key identifier associated
    with a persistent object.   The row may have been
    deleted, or in some cases the primary key updated
    to a new value, outside of the ORM's management of the target
    object.

    r.   NstateInstanceState[Any]r1   r2   c                    t           j        j        }|sd|                    |          z  }t          j                            | |           d S )NzDInstance '%s' has been deleted, or its row is otherwise not present.)r   r6   r7   	state_strsa_excInvalidRequestErrorr=   )r>   rV   r1   r?   s       r   r=   zObjectDeletedError.__init__   sT    ~& 	026..2G2GH 
 	"++D#66666r   rA   r   c                .    | j         d | j        d         ffS rC   rD   rG   s    r   rH   zObjectDeletedError.__reduce__   rI   r   rJ   )rV   rW   r1   r2   rK   rL   r   r   r   rU   rU      sf         & T.//	7 	7 	7 	7 0/	74 4 4 4 4 4r   rU   c                      e Zd ZdZdS )UnmappedColumnErrorz5Mapping operation was requested on an unknown column.Nr   r   r   r   r^   r^      s        ????r   r^   c                      e Zd ZdZddZdS )LoaderStrategyExceptionz2A loader strategy for an attribute does not exist.applied_to_property_type	Type[Any]requesting_propertyMapperProperty[Any]
applies_to#Optional[Type[MapperProperty[Any]]]actual_strategy_typeOptional[Type[LoaderStrategy]]strategy_keyTuple[Any, ...]c                   |(t           j                            | d|d|           d S |J t           j                            | dt          j        |          d|dt          |          dt          |          d	           d S )NzCan't find strategy z for zCan't apply "z" strategy to property "z", which is a "z7"; this loader strategy is intended to be used with a "z".)rZ   r[   r=   r   clsname_as_plain_namer   )r>   ra   rc   re   rg   ri   s         r   r=   z LoaderStrategyException.__init__   s      '&//<<!4!46     )))&//
 ./CDDDD'''23KLLLL2:>>>>    r   N)
ra   rb   rc   rd   re   rf   rg   rh   ri   rj   )r   r   r   r   r=   r   r   r   r`   r`      s.        <<     r   r`   rO   rb   rA   strc                    	 d                     | j        | j        f          }n2# t          $ r% t	          | dd           }|t          |           }Y nw xY w|S )N.r   )joinr   r   AttributeErrorgetattrrepr)rO   cls_names     r   r:   r:      si    !88S^S\:;; ! ! !3
D11CyyH! Os   !$ ,AAr.   r2   c                    t           j        j        }	 |                    |           j        }n!# t
          t          ft          z   $ r i }Y nw xY wt          |           }|sd| dS d S )Nr4   r5   )	r   r6   r7   manager_of_classmappersr;   	TypeErrorNO_STATEr:   )rO   r?   rw   r@   s       r   rR   rR      s    >"D'',,4 	    	
 #D .....ts   . AAN)rO   rb   rA   rm   )rO   rb   rA   r2   ),r   
__future__r   typingr   r   r   r   r   r	   r   r    r   rZ   r   r   
interfacesr   r   rV   r   r   rq   KeyErrorry   SQLAlchemyErrorr   ConcurrentModificationErrorr!   ArgumentErrorr#   r[   r%   r'   r)   r-   r;   rU   r^   r`   r:   rM   rR   r   r   r   <module>r      s   !   " " " " " "                                           0 0 0 0 0 0             & & & & & &       %************$$$$$$WTH% L    V+   2 - ; ; ; ; ;' ; ; ;    F0   J J J J JF. J J J    f4       F2   4 4 4 4 4M 4 4 4<	4 	4 	4 	4 	4 	4 	4 	4!4 !4 !4 !4 !43 !4 !4 !4H@ @ @ @ @&4 @ @ @    f8   B    *++   ,+  r   