
    g                       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j4                        ZeZ G d dej4                        Z G d dej<                        Z G d dej@                        Z! G d dej4                        Z" G d d ej4                        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(d/d+Z) e
jT                  d,      d0d-       Z+y.)1z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y)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/var/www/api/v1/venv_getwork_v1/lib/python3.12/site-packages/sqlalchemy/orm/exc.pyr   r   $   s    r   r   c                      e Zd ZdZy)
FlushErrorz0A invalid condition was detected during flush().Nr   r   r   r   r!   r!   @   s    :r   r!   c                      e Zd ZdZy)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y)UnmappedErrorz?Base for exceptions that involve expected mappings not present.Nr   r   r   r   r%   r%   M   s    Ir   r%   c                      e Zd ZdZy)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y)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    ) Dr   r)   c                  L    e Zd ZdZ ej
                  d      ddd       ZddZy)	UnmappedInstanceErrorz;An mapping operation was requested for an unknown instance.sqlalchemy.orm.baseNc                h   t         j                  j                  }|s8	 |j                  t	        |             t        t	        |            }d|d|d}t        j                  | |       y # t        $ r< dt        t	        |             d}t        |t              r|dt        |      z  z  }Y [w xY w)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__)selfobjmsgbasenames        r   r9   zUnmappedInstanceError.__init__b   s    ~~&&!!$s),%d3i0
 &*41  	tS) & tCy 9:/Jc4($&4S&9:Cs   7A, ,AB10B1c                <    | j                   d | j                  d   ffS Nr   	__class__argsr:   s    r   
__reduce__z UnmappedInstanceError.__reduce__y       ~~diil333r   N)r;   objectr<   Optional[str]returnr   r   r   r   r   r   preload_moduler9   rE   r   r   r   r-   r-   _   s*    ET./* 0*,4r   r-   c                  "    e Zd ZdZdddZddZy)r7   z8An mapping operation was requested for an unknown class.Nc                J    |st        |      }t        j                  | |       y rG   )_default_unmappedr%   r9   )r:   clsr<   s      r   r9   zUnmappedClassError.__init__   s    #C(CtS)r   c                <    | j                   d | j                  d   ffS r@   rA   rD   s    r   rE   zUnmappedClassError.__reduce__   rF   r   rG   )rQ   zType[_T]r<   rI   rJ   )r   r   r   r   r9   rE   r   r   r   r7   r7   }   s    B*
4r   r7   c                  L    e Zd ZdZ ej
                  d      ddd       ZddZy)	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.   Nc                    t         j                  j                  }|sd|j                  |      z  }t        j
                  j                  | |       y )NzDInstance '%s' has been deleted, or its row is otherwise not present.)r   r2   r3   	state_strsa_excInvalidRequestErrorr9   )r:   stater<   r=   s       r   r9   zObjectDeletedError.__init__   sH    ~~&&026..2GH 
 	""++D#6r   c                <    | j                   d | j                  d   ffS r@   rA   rD   s    r   rE   zObjectDeletedError.__reduce__   rF   r   rG   )rY   zInstanceState[Any]r<   rI   rJ   rL   r   r   r   rT   rT      s.    & T./	7 0	74r   rT   c                      e Zd ZdZy)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y)LoaderStrategyExceptionz2A loader strategy for an attribute does not exist.c                   |'t         j                  j                  | d|d|       y |J t         j                  j                  | dt        j                  |      d|dt        |      dt        |      d	       y )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".)rW   rX   r9   r   clsname_as_plain_namer   )r:   applied_to_property_typerequesting_property
applies_toactual_strategy_typestrategy_keys         r   r9   z LoaderStrategyException.__init__   s{      '&&//!46 )))&&//
 ../CD'23KL2:>r   N)
ra   	Type[Any]rb   zMapperProperty[Any]rc   z#Optional[Type[MapperProperty[Any]]]rd   zOptional[Type[LoaderStrategy]]re   zTuple[Any, ...])r   r   r   r   r9   r   r   r   r^   r^      s:    <"+ 1 8	
 = &r   r^   c                    	 dj                  | j                  | j                  f      }|S # t        $ r t	        | dd       }|t        |       }Y |S w xY w)N.r   )joinr   r   AttributeErrorgetattrrepr)rQ   cls_names     r   r6   r6      s]    !88S^^S\\:;
 O	  !3
D1CyHO	!s   '+ #AAr.   c                    t         j                  j                  }	 |j                  |       j                  }t        |       }|sd| dS y # t
        t        ft        z   $ r i }Y .w xY w)Nr0   r1   )	r   r2   r3   manager_of_classmappersr7   	TypeErrorNO_STATEr6   )rQ   r=   rp   r>   s       r   rP   rP      sw    >>""D'',44 #Do.. 	 	  	s   A A&%A&N)rQ   rf   rK   str)rQ   rf   rK   rI   ),r   
__future__r   typingr   r   r   r   r   r	   r   r    r   rW   r   r   
interfacesr   r   rY   r   r   rj   KeyErrorrr   SQLAlchemyErrorr   ConcurrentModificationErrorr!   ArgumentErrorr#   rX   r%   r'   r)   r-   r7   rT   r\   r^   r6   rM   rP   r   r   r   <module>r|      sB   ! "        0   & **$TH% LV++ 2 - ;'' ;F00 JF.. Jf44 F22 4M 4<	4 	4!433 !4H@&44 @f88 B *+ ,r   