a
    •˜ëjÔ  ã                   @  sÄ  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d�ZeefZG dd„ dejƒZeZG dd„ dejƒZG dd„ dejƒZG dd„ dej ƒZ!G dd„ dejƒZ"G dd „ d ejƒZ#G d!d"„ d"e!ƒZ$G d#d$„ d$e!ƒZ%G d%d&„ d&ej ƒZ&G d'd(„ d(ej ƒZ'G d)d*„ d*ej ƒZ(d+d,d-œd.d/„Z)e
 *d0¡d+d1d-œd2d3„ƒZ+d4S )5z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                   @  s   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__© r   r   úQ/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/sqlalchemy/orm/exc.pyr   $   s   r   c                   @  s   e Zd ZdZdS )Ú
FlushErrorz0A invalid condition was detected during flush().Nr   r   r   r   r   r   @   s   r   c                   @  s   e Zd ZdZdS )ÚMappedAnnotationErrorzŸRaised 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   c                   @  s   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   r   c                   @  s   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    c                   @  s   e Zd ZdZdZdS )ÚDetachedInstanceErrorzSAn attempt to access unloaded attributes on a
    mapped instance that is detached.Zbhk3N)r   r   r   r   Úcoder   r   r   r   r!   X   s   r!   c                   @  s:   e Zd ZdZe d¡ddddœdd„ƒZd	d
œdd„ZdS )ÚUnmappedInstanceErrorz;An mapping operation was requested for an unknown instance.úsqlalchemy.orm.baseNÚobjectúOptional[str])ÚobjÚmsgc                 C  sˆ   t jj}|sxz*| t|ƒ¡ tt|ƒƒ}d||f }W n@ tyv   dtt|ƒƒ› d�}t|tƒrr|dt|ƒ 7 }Y n0 t 	| |¡ d S )Nz“Class %r is mapped, but this instance lacks instrumentation.  This occurs when the instance is created before sqlalchemy.orm.mapper(%s) was called.úClass 'ú' is not mappedz;; was a class (%s) supplied where an instance was required?)
r   Ú	preloadedÚorm_baseZclass_mapperÚtypeÚ_safe_cls_nameÚUnmappedClassErrorÚ
isinstancer   Ú__init__)Úselfr'   r(   ÚbaseÚnamer   r   r   r1   b   s$    ýÿ
ÿÿ
zUnmappedInstanceError.__init__r   ©Úreturnc                 C  s   | j d | jd ffS ©Nr   ©Ú	__class__Úargs©r2   r   r   r   Ú
__reduce__y   s    z UnmappedInstanceError.__reduce__)N©r   r   r   r   r   Úpreload_moduler1   r<   r   r   r   r   r#   _   s   r#   c                   @  s0   e Zd ZdZddddœdd„Zdd	œd
d„ZdS )r/   z8An mapping operation was requested for an unknown class.NzType[_T]r&   )Úclsr(   c                 C  s   |st |ƒ}t | |¡ d S )N)Ú_default_unmappedr   r1   )r2   r?   r(   r   r   r   r1   €   s    zUnmappedClassError.__init__r   r5   c                 C  s   | j d | jd ffS r7   r8   r;   r   r   r   r<   …   s    zUnmappedClassError.__reduce__)N)r   r   r   r   r1   r<   r   r   r   r   r/   }   s   r/   c                   @  s:   e Zd ZdZe d¡ddddœdd„ƒZd	d
œ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$   NzInstanceState[Any]r&   )Ústater(   c                 C  s,   t jj}|sd| |¡ }tj | |¡ d S )NzDInstance '%s' has been deleted, or its row is otherwise not present.)r   r+   r,   Z	state_strÚsa_excÚInvalidRequestErrorr1   )r2   rB   r(   r3   r   r   r   r1   �   s    ÿÿzObjectDeletedError.__init__r   r5   c                 C  s   | j d | jd ffS r7   r8   r;   r   r   r   r<   ©   s    zObjectDeletedError.__reduce__)Nr=   r   r   r   r   rA   ‰   s   rA   c                   @  s   e Zd ZdZdS )ÚUnmappedColumnErrorz5Mapping operation was requested on an unknown column.Nr   r   r   r   r   rE   ­   s   rE   c                   @  s&   e Zd ZdZddddddœdd	„Zd
S )ÚLoaderStrategyExceptionz2A loader strategy for an attribute does not exist.ú	Type[Any]zMapperProperty[Any]z#Optional[Type[MapperProperty[Any]]]zOptional[Type[LoaderStrategy]]zTuple[Any, ...])Úapplied_to_property_typeÚrequesting_propertyÚ
applies_toÚactual_strategy_typeÚstrategy_keyc              	   C  sX   |d u r t j | d||f ¡ n4|d us,J ‚t j | dt |¡|t|ƒt|ƒf ¡ d S )NzCan't find strategy %s for %szuCan't apply "%s" strategy to property "%s", which is a "%s"; this loader strategy is intended to be used with a "%s".)rC   rD   r1   r   Zclsname_as_plain_namer
   )r2   rH   rI   rJ   rK   rL   r   r   r   r1   ´   s$    ÿþüýþz LoaderStrategyException.__init__N)r   r   r   r   r1   r   r   r   r   rF   ±   s   rF   rG   Ústr)r?   r6   c                 C  sJ   zd  | j| jf¡}W n. tyD   t| dd ƒ}|d u r@t| ƒ}Y n0 |S )NÚ.r   )Újoinr   r   ÚAttributeErrorÚgetattrÚrepr)r?   Úcls_namer   r   r   r.   Ò   s    r.   r$   r&   c              	   C  sX   t jj}z| | ¡j}W n ttft y6   i }Y n0 t| ƒ}|sPd|› d�S d S d S )Nr)   r*   )	r   r+   r,   Zmanager_of_classÚmappersr/   Ú	TypeErrorÚNO_STATEr.   )r?   r3   rT   r4   r   r   r   r@   Ý   s    þý

r@   N),r   Ú
__future__r   Útypingr   r   r   r   r   r   r   r
   Ú r   rC   r   r   Z
interfacesr   r   rB   r   r   rP   ÚKeyErrorrV   ZSQLAlchemyErrorr   ZConcurrentModificationErrorr   ÚArgumentErrorr   rD   r   r    r!   r#   r/   rA   rE   rF   r.   r>   r@   r   r   r   r   Ú<module>   sB   	$!