o
    ?ÊÆh¼  ã                   @  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 erXd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ƒ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%d3d,d-„Z&e 'd.¡d4d0d1„ƒZ(d2S )5zSQLAlchemy ORM exceptions.é    )Úannotations)ÚAny)ÚOptional)ÚTuple)ÚType)ÚTYPE_CHECKING)ÚTypeVaré   )Ú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__© r   r   ú_/var/www/html/HyperOracle/crypto_trader/venv/lib/python3.10/site-packages/sqlalchemy/orm/exc.pyr   #   ó    r   c                   @  r   )Ú
FlushErrorz0A invalid condition was detected during flush().Nr   r   r   r   r   r   ?   r   r   c                   @  r   )ÚUnmappedErrorz?Base for exceptions that involve expected mappings not present.Nr   r   r   r   r   r   C   r   r   c                   @  r   )ÚObjectDereferencedErrorzPAn operation cannot complete due to an object being garbage
    collected.

    Nr   r   r   r   r   r    G   r   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.Úbhk3N)r   r   r   r   Úcoder   r   r   r   r!   N   s    r!   c                   @  ó0   e Zd ZdZe d¡dddd	„ƒZddd„ZdS )ÚUnmappedInstanceErrorz;An mapping operation was requested for an unknown instance.úsqlalchemy.orm.baseNÚobjÚobjectÚmsgúOptional[str]c                 C  sˆ   t jj}|s<z| t|ƒ¡ tt|ƒƒ}d||f }W n  ty;   dtt|ƒƒ› d�}t|tƒr9|dt|ƒ 7 }Y nw 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_baseÚclass_mapperÚtypeÚ_safe_cls_nameÚUnmappedClassErrorÚ
isinstancer   Ú__init__)Úselfr'   r)   ÚbaseÚnamer   r   r   r4   X   s(   ýÿ
ÿÿ€ýzUnmappedInstanceError.__init__Úreturnr   c                 C  ó   | j d | jd ffS ©Nr   ©Ú	__class__Úargs©r5   r   r   r   Ú
__reduce__o   ó   z UnmappedInstanceError.__reduce__©N)r'   r(   r)   r*   ©r8   r   ©r   r   r   r   r   Úpreload_moduler4   r?   r   r   r   r   r%   U   s
    r%   c                   @  s&   e Zd ZdZdddd„Zddd„ZdS )r2   z8An mapping operation was requested for an unknown class.NÚclsúType[_T]r)   r*   c                 C  s   |st |ƒ}t | |¡ d S rA   )Ú_default_unmappedr   r4   )r5   rE   r)   r   r   r   r4   v   s   zUnmappedClassError.__init__r8   r   c                 C  r9   r:   r;   r>   r   r   r   r?   {   r@   zUnmappedClassError.__reduce__rA   )rE   rF   r)   r*   rB   )r   r   r   r   r4   r?   r   r   r   r   r2   s   s    r2   c                   @  r$   )Ú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]r)   r*   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.   Ú	state_strÚsa_excÚInvalidRequestErrorr4   )r5   rI   r)   r6   r   r   r   r4   “   s   ÿÿzObjectDeletedError.__init__r8   r   c                 C  r9   r:   r;   r>   r   r   r   r?   Ÿ   r@   zObjectDeletedError.__reduce__rA   )rI   rJ   r)   r*   rB   rC   r   r   r   r   rH      s
    rH   c                   @  r   )ÚUnmappedColumnErrorz5Mapping operation was requested on an unknown column.Nr   r   r   r   r   rN   £   r   rN   c                   @  s   e Zd ZdZd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              
   C  s^   |d u rt j | d||f ¡ d S |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".)rL   rM   r4   r   Úclsname_as_plain_name)r5   rP   rR   rT   rV   rX   r   r   r   r4   ª   s$   ÿþüýþz LoaderStrategyException.__init__N)
rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   )r   r   r   r   r4   r   r   r   r   rO   §   s    rO   rE   rQ   r8   Ústrc                 C  sP   zd  | j| jf¡}W |S  ty'   t| dd ƒ}|d u r$t| ƒ}Y |S Y |S w )NÚ.r   )Újoinr   r   ÚAttributeErrorÚgetattrÚrepr)rE   Úcls_namer   r   r   r1   È   s   ü
þür1   r&   r*   c              	   C  sT   t jj}z| | ¡j}W n ttft y   i }Y nw t| ƒ}|s(d|› d�S d S )Nr+   r,   )	r   r-   r.   Úmanager_of_classÚmappersr2   Ú	TypeErrorÚNO_STATEr1   )rE   r6   rc   r7   r   r   r   rG   Ó   s   þ
ýürG   N)rE   rQ   r8   r[   )rE   rQ   r8   r*   ))r   Ú
__future__r   Útypingr   r   r   r   r   r   Ú r
   rL   r   r   r   Ú
interfacesr   r   rI   r   r   r^   ÚKeyErrorre   ÚSQLAlchemyErrorr   ÚConcurrentModificationErrorr   rM   r   r    r!   r%   r2   rH   rN   rO   r1   rD   rG   r   r   r   r   Ú<module>   sB   $
!