
    ,h&                    "   % S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SS	KJ
r
  SS
KJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK J!r!  SSKJr"  SSKJ#r#  SS KJ$r$  SS!K%J&r&  SS"K%J'r'  \(       aZ  SS#KJ(r(  SS$KJ)r)  SS%KJ*r*  SS&K+J,r,  SS'K+J-r-  SS(KJ.r.  SS)K/J0r0  SS*K1J2r2  SS+K3J4r4  SS,KJ5r5  SS-K6J7r7  SS.K8J9r9  SS/K:J;r;  SS0K<J=r>  SS1K<J?r?  \(       a  S2\@S3'   OSrA\(       d  Sr> " S4 S5\'5      rB " S6 S7\'\   5      rC\#R                   " S8 S9\R                  \\   5      5       rF " S: S;5      rG " S< S=5      rHg)>zDefines instrumentation of instances.

This module is usually not directly visible to user applications, but
defines a large part of the ORM's interactivity.

    )annotations)Any)Callable)Dict)Generic)Iterable)Optional)Set)Tuple)TYPE_CHECKING)UnionN   )base)exc)
interfaces)_O)is_collection_impl)ATTR_WAS_SET)INIT_OK)LoaderCallableStatus)	NEVER_SET)NO_VALUE)PASSIVE_NO_INITIALIZE)PASSIVE_NO_RESULT)PASSIVE_OFF)SQL_OK)PathRegistry   )
inspection)util)Literal)Protocol)_IdentityKeyType)_InstanceDict)_LoaderCallable)AttributeImpl)History)PassiveFlag)_AdaptedCollectionProtocol)IdentityMap)ClassManager)	ORMOption)Mapper)Session)Row)async_session)AsyncSessionz)weakref.WeakValueDictionary[int, Session]	_sessionsc                      \ rS rSrSS jrSrg)_InstanceDictProtoP   c                    g N selfs    L/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/orm/state.py__call___InstanceDictProto.__call__Q   s        r8   N)returnOptional[IdentityMap])__name__
__module____qualname____firstlineno__r<   __static_attributes__r8   r>   r;   r4   r4   P   s    4r>   r4   c                  2    \ rS rSrSr        SS jrSrg)_InstallLoaderCallableProtoT   a
  used at result loading time to install a _LoaderCallable callable
upon a specific InstanceState, which will be used to populate an
attribute when that attribute is accessed.

Concrete examples are per-instance deferred column loaders and
relationship lazy loaders.

c                    g r7   r8   )r:   statedict_rows       r;   r<   $_InstallLoaderCallableProto.__call__^   s    r>   r8   NrJ   InstanceState[_O]rK   r$   rL   zRow[Any]r?   None)rA   rB   rC   rD   __doc__r<   rE   r8   r>   r;   rG   rG   T   s,    &/<CK	r>   rG   c                     \ rS rSr% SrSrS\S'   SrS\S'   SrS	\S
'   Sr	S\S'   Sr
S\S'   \R                  rS\S'   SrS\S'   SrS\S'   S\S'   S\S'   SrS\S'    SrS\S'    SrS\S'   SrS\S'   SrS\S'   SrS\S '   SrS!\S"'   SrS#\S$'   S%\S&'    \(       d  S' rS(\S)'    S*\S+'    \(       d  \R6                  rS^S, jr\R<                  S_S- j5       r\ S`S. j5       r!\ S`S/ j5       r"\ S`S0 j5       r#\ S`S1 j5       r$\ S`S2 j5       r%\ S`S3 j5       r&\RN                  \RP                  " S45      S`S5 j5       5       r)SaS6 jr*\ SbS7 j5       r+\ ScS8 j5       r,\ SdS9 j5       r-\ SeS: j5       r.\ SfS; j5       r/\R<                  SgS< j5       r0\R<                  ShS= j5       r1\R<                  SiS> j5       r2\R<                  SjS? j5       r3\ S`S@ j5       r4\5 Sk       SlSA jj5       r6SmSnSB jjr7SoSC jr8SpSD jr9\ SqSE j5       r:SrSF jr;SsSG jr<StSH jr=SuSI jr>SvSJ jr?SwSK jr@SxSL jrASySM jrB\5        SzSN j5       rC      S{SO jrD Sk       S|SP jjrE      S}SQ jrF\ S~SR j5       rGSSS jrH\ S~ST j5       rI\ \R                  " SUSV5      S~SW j5       5       rK\ S~SX j5       rL  S           SSY jjrMSSZ jrN Sm     SS[ jjrO\5 Sm     SS\ jj5       rPS]rQg)InstanceStatec   a  Tracks state information at the instance level.

The :class:`.InstanceState` is a key object used by the
SQLAlchemy ORM in order to track the state of an object;
it is created the moment an object is instantiated, typically
as a result of :term:`instrumentation` which SQLAlchemy applies
to the ``__init__()`` method of the class.

:class:`.InstanceState` is also a semi-public object,
available for runtime inspection as to the state of a
mapped instance, including information such as its current
status within a particular :class:`.Session` and details
about data on individual attributes.  The public API
in order to acquire a :class:`.InstanceState` object
is to use the :func:`_sa.inspect` system::

    >>> from sqlalchemy import inspect
    >>> insp = inspect(some_mapped_object)
    >>> insp.attrs.nickname.history
    History(added=['new nickname'], unchanged=(), deleted=['nickname'])

.. seealso::

    :ref:`orm_mapper_inspection_instancestate`

)__dict____weakref__class_managerobjcommitted_stateexpired_attributesClassManager[_O]rX   NzOptional[int]
session_idOptional[_IdentityKeyType[_O]]keyrunidr8   zTuple[ORMOption, ...]load_optionsr   	load_pathinsert_orderzOptional[object]_strong_objweakref.ref[_O]rY   Dict[str, Any]rZ   Fboolmodifiedexpired_deleted_load_pending_orphaned_outside_of_sessionTis_instanceobjectidentity_tokenzOptional[Dict[str, Any]]_last_known_valuesr4   _instance_dictc                    g)z+default 'weak reference' for _instance_dictNr8   r9   s    r;   rq   InstanceState._instance_dict   s    r>   Set[str]r[   z:Dict[str, Callable[[InstanceState[_O], PassiveFlag], Any]]	callablesc                    UR                   U l        X l        [        R                  " XR
                  5      U l        0 U l        [        5       U l	        g r7   )
	__class__rW   rX   weakrefref_cleanuprY   rZ   setr[   )r:   rY   rX   s      r;   __init__InstanceState.__init__   s8    mm;;sMM2!"%%r>   c           
         [         R                  " U R                   Vs0 s H  o[        X5      _M     sn5      $ s  snf )a)  Return a namespace representing each attribute on
the mapped object, including its current value
and history.

The returned object is an instance of :class:`.AttributeState`.
This object allows inspection of the current data
within an attribute as well as attribute history
since the last flush.

)r    ReadOnlyPropertiesrX   AttributeStater:   r_   s     r;   attrsInstanceState.attrs   s8     &&7;||D|.++|D
 	
Ds   ;c                N    U R                   SL =(       a    U R                  (       + $ )zeReturn ``True`` if the object is :term:`transient`.

.. seealso::

    :ref:`session_object_states`

Nr_   	_attachedr9   s    r;   	transientInstanceState.transient   s     xx46$66r>   c                D    U R                   SL =(       a    U R                  $ )zcReturn ``True`` if the object is :term:`pending`.

.. seealso::

    :ref:`session_object_states`

Nr   r9   s    r;   pendingInstanceState.pending   s     xx42DNN2r>   c                j    U R                   SL=(       a    U R                  =(       a    U R                  $ )a`  Return ``True`` if the object is :term:`deleted`.

An object that is in the deleted state is guaranteed to
not be within the :attr:`.Session.identity_map` of its parent
:class:`.Session`; however if the session's transaction is rolled
back, the object will be restored to the persistent state and
the identity map.

.. note::

    The :attr:`.InstanceState.deleted` attribute refers to a specific
    state of the object that occurs between the "persistent" and
    "detached" states; once the object is :term:`detached`, the
    :attr:`.InstanceState.deleted` attribute **no longer returns
    True**; in order to detect that a state was deleted, regardless
    of whether or not the object is associated with a
    :class:`.Session`, use the :attr:`.InstanceState.was_deleted`
    accessor.

.. versionadded: 1.1

.. seealso::

    :ref:`session_object_states`

Nr_   r   rj   r9   s    r;   deletedInstanceState.deleted   s%    8 xxt#HH4==Hr>   c                    U R                   $ )a  Return True if this object is or was previously in the
"deleted" state and has not been reverted to persistent.

This flag returns True once the object was deleted in flush.
When the object is expunged from the session either explicitly
or via transaction commit and enters the "detached" state,
this flag will continue to report True.

.. seealso::

    :attr:`.InstanceState.deleted` - refers to the "deleted" state

    :func:`.orm.util.was_deleted` - standalone function

    :ref:`session_object_states`

)rj   r9   s    r;   was_deletedInstanceState.was_deleted  s    & }}r>   c                t    U R                   SL=(       a$    U R                  =(       a    U R                  (       + $ )zReturn ``True`` if the object is :term:`persistent`.

An object that is in the persistent state is guaranteed to
be within the :attr:`.Session.identity_map` of its parent
:class:`.Session`.

.. seealso::

    :ref:`session_object_states`

Nr   r9   s    r;   
persistentInstanceState.persistent)  s(     xxt#LLt}};LLr>   c                N    U R                   SL=(       a    U R                  (       + $ )zdReturn ``True`` if the object is :term:`detached`.

.. seealso::

    :ref:`session_object_states`

Nr   r9   s    r;   detachedInstanceState.detached8  s     xxt#:DNN(::r>   zsqlalchemy.orm.sessionc                    U R                   S L=(       a1    U R                   [        R                  R                  R                  ;   $ r7   )r]   r    	preloadedorm_sessionr2   r9   s    r;   r   InstanceState._attachedC  s7     OO4' H4>>#=#=#G#GG	
r>   c                P    U R                   nUc	  0 =U l         nX;  a	  [        X!'   gg)zdTrack the last known value of a particular key after expiration
operations.

.. versionadded:: 1.3

N)rp   r   )r:   r_   lkvs      r;   _track_last_known_value%InstanceState._track_last_known_valueK  s2     %%;,..D#c>CH r>   c                n    U R                   (       a   [        U R                      $ g! [         a     gf = f)a  Return the owning :class:`.Session` for this instance,
or ``None`` if none available.

Note that the result here can in some cases be *different*
from that of ``obj in session``; an object that's been deleted
will report as not ``in session``, however if the transaction is
still in progress, this attribute will still refer to that session.
Only when the transaction is completed does the object become
fully detached under normal circumstances.

.. seealso::

    :attr:`_orm.InstanceState.async_session`

N)r]   r2   KeyErrorr9   s    r;   sessionInstanceState.sessionY  s;    " ?? 11   s   ' 
44c                H    [         c  gU R                  nUb  [        U5      $ g)a  Return the owning :class:`_asyncio.AsyncSession` for this instance,
or ``None`` if none available.

This attribute is only non-None when the :mod:`sqlalchemy.ext.asyncio`
API is in use for this ORM object. The returned
:class:`_asyncio.AsyncSession` object will be a proxy for the
:class:`_orm.Session` object that would be returned from the
:attr:`_orm.InstanceState.session` attribute for this
:class:`_orm.InstanceState`.

.. versionadded:: 1.4.18

.. seealso::

    :ref:`asyncio_toplevel`

N)_async_providerr   )r:   sesss     r;   r0   InstanceState.async_sessionq  s*    & "||"4((r>   c                "    U R                  5       $ )z~Return the mapped object represented by this
:class:`.InstanceState`.

Returns None if the object has been garbage collected

)rY   r9   s    r;   rn   InstanceState.object  s     xxzr>   c                <    U R                   c  gU R                   S   $ )a  Return the mapped identity of the mapped object.
This is the primary key identity as persisted by the ORM
which can always be passed directly to
:meth:`_query.Query.get`.

Returns ``None`` if the object has no primary key identity.

.. note::
    An object which is :term:`transient` or :term:`pending`
    does **not** have a mapped identity until it is flushed,
    even if its attributes include primary key values.

Nr   r_   r9   s    r;   identityInstanceState.identity  s     8888A;r>   c                    U R                   $ )zReturn the identity key for the mapped object.

This is the key used to locate the object within
the :attr:`.Session.identity_map` mapping.   It contains
the identity as returned by :attr:`.identity` within it.


r   r9   s    r;   identity_keyInstanceState.identity_key  s     xxr>   c                    0 $ r7   r8   r9   s    r;   parentsInstanceState.parents      	r>   c                    0 $ r7   r8   r9   s    r;   _pending_mutations InstanceState._pending_mutations  r   r>   c                    0 $ r7   r8   r9   s    r;   _empty_collections InstanceState._empty_collections  r   r>   c                .    U R                   R                  $ )z<Return the :class:`_orm.Mapper` used for this mapped object.)rX   mapperr9   s    r;   r   InstanceState.mapper  s     ||"""r>   c                ,    [        U R                  5      $ )zReturn ``True`` if this object has an identity key.

This should always have the same value as the
expression ``state.persistent`` or ``state.detached``.

)rg   r_   r9   s    r;   has_identityInstanceState.has_identity  s     DHH~r>   c                R   UR                   R                  =(       d    S nUR                   R                  =(       d    S nUR                   R                  =(       d    S nUR                   R                  =(       d    S nU H  nUR
                  n	UR                  S L n
U
(       + =(       a    U	(       + nS Ul        U(       a  UR                  (       a  U?U(       a  U(       a  Ub  U" X(5        O1Ub  U" X(5        O%U	(       a  Ub	  U" X(5        OU
(       a  Ub  U" X(5        S Ul        M     g r7   )	dispatchpersistent_to_detacheddeleted_to_detachedpending_to_transientpersistent_to_transientrj   r_   r]   rd   )r:   statesr   to_transientr   r   r   r   rJ   r   r   r   s               r;   _detach_statesInstanceState._detach_states  s     33;t 	 &..BBJd&//DDL44< 	  EnnGii4'G$4WJ#E		I.:/?+7*7:0<#G31=$W4 $E) r>   c                ^    U(       a  [         R                  U /U5        g S =U l        U l        g r7   )rS   r   r]   rd   )r:   r   s     r;   _detachInstanceState._detach  s&    (($9155DOd.r>   c                $    U R                  5         g r7   )r   r9   s    r;   _disposeInstanceState._dispose  s    r>   c                |    [         c  gU R                  5       nUb  UR                  U 5        U ?S=U l        U l        g)zWeakref callback cleanup.

This callable cleans out the state when it is being garbage
collected.

this _cleanup **assumes** that there are no strong refs to us!
Will not work otherwise!

N)dictrq   _fast_discardr]   rd   )r:   ry   instance_dicts      r;   rz   InstanceState._cleanup  sE     <++-$''-# .21$*r>   c                X    U R                  5       nUb  [        R                  " U5      $ 0 $ )aG  Return the instance dict used by the object.

Under normal circumstances, this is always synonymous
with the ``__dict__`` attribute of the mapped object,
unless an alternative instrumentation system has been
configured.

In the case that the actual object has been garbage
collected, this accessor returns a blank dictionary.

)rY   r   r   )r:   os     r;   r   InstanceState.dict  s*     HHJ=%%a((Ir>   c                 B   U S   U S   U SS  pCnUR                   nUR                  R                  X$U5         UR                  " U SS  0 UD6  g !   [        R
                  " 5          UR                  R                  X$U5        S S S 5         g ! , (       d  f        g = f= f)Nr   r   r   )rX   r   initoriginal_initr    safe_reraiseinit_failure)mixedkwargsr:   instanceargsrX   s         r;   _initialize_instance"InstanceState._initialize_instance2  s    $Qxq59,,d&1	B!!5977	B""$  --d&A %$$$s)   A B%BB
B	BBc                h    U R                   U   R                  R                  X R                  U5      $ r7   )rX   implget_historyr   )r:   r_   passives      r;   r   InstanceState.get_history>  s(    ||C %%11$		7KKr>   c                4    U R                   U   R                  $ r7   )rX   r   r   s     r;   get_implInstanceState.get_implA  s    ||C %%%r>   c                l    XR                   ;  a  [        5       U R                   U'   U R                   U   $ r7   )r   PendingCollectionr   s     r;   _get_pending_mutation#InstanceState._get_pending_mutationD  s2    ---+<+>D##C(&&s++r>   c                >  ^  T R                  5       T R                  T R                  T R                  S.nUR	                  U 4S jS 5       5        T R
                  (       a  T R
                  R                  5       US'   T R                  R                  T U5      US'   U$ )N)r   rW   rZ   r[   c              3  j   >#    U  H(  nUTR                   ;   d  M  UTR                   U   4v   M*     g 7fr7   )rU   ).0kr:   s     r;   	<genexpr>-InstanceState.__getstate__.<locals>.<genexpr>P  s:      
 DMM! "Qa !s   33)
r   rh   ri   ru   r_   r   ra   rW   r[   inforb   rX   )	rY   rW   rZ   r[   updaterb   	serializerX   
_serialize)r:   
state_dicts   ` r;   __getstate__InstanceState.__getstate__I  s    
kk#33"&"9"9	&

 	 

 	
  >>&*nn&>&>&@J{# $ 7 7j I
9r>   c                l   US   nUb7  [         R                  " X R                  5      U l        UR                  U l        OS U l        US   U l        UR                  S0 5      U l        UR                  S0 5      U l        UR                  S0 5      U l	        UR                  SS5      U l
        UR                  S	S5      U l        S
U;   a  U R                  R                  US
   5        SU;   a  US   U l        US   U l        O SU;   a  US   U l        O[!        5       U l        U R"                  R                  S Vs/ s H  nX1;   d  M
  X1U   4PM     sn5        U R$                  (       a  U R$                  S   U l        SU;   a  [(        R*                  " US   5      U l        US   " XU5        g s  snf )Nr   c                     g r7   r8   r8   r>   r;   <lambda>,InstanceState.__setstate__.<locals>.<lambda>m  s    tr>   rW   rZ   r   r   rh   Fri   r   ru   r[   )r_   ra   r   rb   rX   )rx   ry   rz   rY   rw   rW   getrZ   r   r   rh   ri   r   r   ru   r[   r{   rU   r_   ro   r   deserializerb   )r:   r   instr   s       r;   __setstate__InstanceState.__setstate__g  s   *%{{47DH..DK#DH$X.DK)~~.?D",..1Er"J!~~i4"z59!~~i7ZIIZ/0*$'4DN&01E&FD##z1*45I*J'*-%' 10A? #qM"0	
 88"&((1+D*$)55j6MNDN9d*5s   =	F1

F1c                4   UR                  US5      nU R                  U   R                  nUb!  [        U5      (       a  UR	                  U5        U R
                  R                  U5        U R                  (       a  U R                  R                  US5        gg)z@Remove the given attribute and any
callables associated with it.N)poprX   r   r   _invalidate_collectionr[   discardru   )r:   rK   r_   oldmanager_impls        r;   _resetInstanceState._reset  sz     iiT"||C(--?1,??//4'',>>NNsD) r>   c                Z    SUR                   ;   a  [        UR                  5      U l        g g Nru   )rU   r   ru   )r:   from_s     r;   _copy_callablesInstanceState._copy_callables  s#    %..(!%//2DN )r>   c                   ^^^ UT   R                   n[        U5      (       a  Um        SUUU4S jjnU$         SUU4S jjnU$ )Nc                   > SU R                   ;  a  0 U l        UR                  TS 5      nUb  TR                  U5        TU R                  T'   g r  )rU   ru   r  r	  )rJ   rK   rL   r  
fixed_implfnr_   s       r;   _set_callableGInstanceState._instance_level_callable_processor.<locals>._set_callable  sI     enn4&(EOiiT*?55c:')$r>   c                R   > SU R                   ;  a  0 U l        TU R                  T'   g r  )rU   ru   )rJ   rK   rL   r  r_   s      r;   r  r    s&     enn4&(EO')$r>   rN   )r   r   )clsrX   r  r_   r   r  r  s     ``  @r;   "_instance_level_callable_processor0InstanceState._instance_level_callable_processor  s     s|  d##J*(*1>*EM** *& *(*1>*EM** * r>   c                :   SU l         U R                  (       a2  UR                  U 5        U R                  R	                  5         SU l        S U l        SU R                  ;   a  U R                  S	 SU R                  ;   a  U R                  S	 U R                  R                  U R                  R                   Vs/ s H  o3R                  PM     sn5        U R                  (       a9  U R                  R                  U R                  5       H  nU R                  U	 M     U R                  R                  R                  U5       H%  nUR                  U5      nSUR                   l        M'     U R$                  (       a@  U R$                  R                  U R$                   Vs0 s H  oDU;   d  M
  XAU   _M     sn5        U R                  R&                  R                  U5       H  nX	 M     U R                  R(                  R+                  U S 5        g s  snf s  snf )NTFr   r   )ri   rh   r
  rZ   clearrd   rU   r[   r   rX   _loader_implsr_   ru   intersection_collection_impl_keysr  _sa_adapterinvalidatedrp   _all_key_setr   expire)r:   rK   modified_setr   r   
collectionr_   s          r;   _expireInstanceState._expire  s    ==  &  &&(!DM4==023%i(&&"&,,"<"<="<$XX"<=	
 >> ,,99$..INN1% J 33@@GA1J15J"". H ""##**&*&=&=L&=e!H&=L <<,,99%@C
 A 	$$T40= >0 Ms   9H!	H.	Hc                   U R                   R                  SS 5      nU R                  nU GH  nU R                  U   R                  nUR
                  (       aH  U(       a  UR                  (       d  Xe;   a  MM  U R                  R                  U5        U(       a  Xe;   a  XV	 UR                  U[        5      n[        U5      (       a  U[        La  UR                  U5        U R                  n	U	b  Xi;   a  U[        La  XU'   U R                  R                  US 5        U(       d  M  UR                  US 5        GM     U R                  R                  R!                  X5        g )Nr   )rU   r  ru   rX   r   accepts_scalar_loader	callable_r[   addr  r   r   r	  rp   rZ   r   r&  )
r:   rK   attribute_names	no_loaderr   ru   r_   r   r  r   s
             r;   _expire_attributes InstanceState._expire_attributes  s    --##$8$?NN	"C<<$))D))$..C4D''++C0!1!))C*C!$''Cx,?++C0))C3:#X2EC  $$S$/wC&' #* 	$$T;r>   c                $  ^  U[         -  (       d  [        $ T R                  R                  T R                  5      nUR                  U 4S jU 5       5      nT R                  R                  T X25        T R                  R                  5         [        $ )z__call__ allows the InstanceState to act as a deferred
callable for loading expired attributes, which is also
serializable (picklable).

c              3  |   >#    U  H1  nTR                   U   R                  R                  (       a  M-  Uv   M3     g 7fr7   )rX   r   load_on_unexpirer   attrr:   s     r;   r   .InstanceState._load_expired.<locals>.<genexpr>  s2      #
<<%**;; D   ,<	<)
r   r   r[   r!  
unmodified
differencerX   expired_attribute_loaderr  r   )r:   rJ   r   toloads   `   r;   _load_expiredInstanceState._load_expired  sz     $$((55dooF"" #
#
 
 	--dFD 	%%'r>   c                ^    [        U R                  5      R                  U R                  5      $ )z8Return the set of keys which have no uncommitted changes)r{   rX   r;  rZ   r9   s    r;   r:  InstanceState.unmodified-  s$     4<< ++D,@,@AAr>   c                |    [        U5      R                  U R                  5      R                  U R                  5      $ )z*Return self.unmodified.intersection(keys).)r{   r!  rX   r;  rZ   )r:   keyss     r;   unmodified_intersection%InstanceState.unmodified_intersection3  s.     I\$,,'Z,,-	
r>   c                    [        U R                  5      R                  U R                  5      R                  U R                  5      $ )zReturn the set of keys which do not have a loaded value.

This includes expired attributes and any other attribute that was never
populated or modified.

)r{   rX   r;  rZ   r   r9   s    r;   unloadedInstanceState.unloaded<  s3     Z,,-Z		"	
r>   z2.0zsThe :attr:`.InstanceState.unloaded_expirable` attribute is deprecated.  Please use :attr:`.InstanceState.unloaded`.c                    U R                   $ )zSynonymous with :attr:`.InstanceState.unloaded`.

This attribute was added as an implementation-specific detail at some
point and should be considered to be private.

)rG  r9   s    r;   unloaded_expirable InstanceState.unloaded_expirableJ  s     }}r>   c                b   ^  T R                   R                  U 4S jT R                   5       5      $ )Nc              3  |   >#    U  H1  nTR                   U   R                  R                  (       d  M-  Uv   M3     g 7fr7   )rX   r   r,  r6  s     r;   r   5InstanceState._unloaded_non_object.<locals>.<genexpr>[  s2      *
$||D!&&<< D$r9  )rG  r!  rX   r9   s   `r;   _unloaded_non_object"InstanceState._unloaded_non_objectY  s+    }})) *
*
 
 	
r>   c                   U(       Ga#  UR                   (       d  g U(       a3  UR                  U;  a#  [        R                  " SUR                  -  5      eUR                  U R                  ;  d  U(       a  U(       af  [
        (       a  [        U5      (       d   eU[        L a  UR                  U;   a  XR                     nUS [        [        4;  a  UR                  U5      nX0R                  UR                  '   U R                  nUb"  UR                  U;   a  [        XbR                  '   U R                  (       a  U R                  b  U R                  (       Gd  SU l        U R                  5       nU(       a1  [        UR                   5      nUR                   R#                  U 5        OSnU R%                  5       n	U R                  (       a>  Xl        U(       d1   [&        U R                     n
U
R(                  c  U
R+                  5         U	cR  U(       aJ  [.        R0                  " SU R2                  UR                     < S[4        R6                  " U 5      < S35      eg g g ! [,         a     Ncf = f)NzHCan't flag attribute '%s' modified; it's not present in the object stateTFz'Can't emit change event for attribute 'z' - parent object of type z has been garbage collected.)send_modified_eventsr_   sa_excInvalidRequestErrorrZ   r   r   r   r   copyrp   r]   rd   rh   rq   rg   	_modifiedr.  rY   r2   _transaction_autobegin_tr   orm_excObjectDereferencedErrorrX   r   state_class_str)r:   rK   r7  previousr(  is_userlandr   r   has_modifiedr  r   s              r;   _modified_eventInstanceState._modified_eventa  s    ,,txxu400')-2  xxt333{$}1$77779,88u,',XXHh	'BB#'99X#619$$TXX.))C488s? (HH OO 0 0 8 DM //1M#M$;$;<''++D1$
 88:D#' 
 $3"+DOO"< #//7#002|55 ||DHH-t/C/CD/IK  !%|= BO0 $ s   I# #
I0/I0c                t   U H  nU R                   R                  US5        M!     SU l        U R                  R	                  [        U5      R                  U5      5        U R                  (       aH  [        U R                  5      R                  U5      R                  U5       H  nU R                  U	 M     gg)a  Commit attributes.

This is used by a partial-attribute load operation to mark committed
those attributes which were refreshed from the database.

Attributes marked as "expired" can potentially remain "expired" after
this step if a value was not populated in state.dict.

NF)rZ   r  ri   r[   difference_updater{   r!  ru   )r:   rK   rC  r_   s       r;   _commitInstanceState._commit  s     C  $$S$/  11I""5)	
 >>DNN#006CCEJ  NN3' K r>   c                ,    U R                  X4/U5        g)a  commit all attributes unconditionally.

This is used after a flush() or a full load/refresh
to remove all pending state from the instance.

 - all attributes are marked as "committed"
 - the "strong dirty reference" is removed
 - the "modified" flag is set to False
 - any "expired" markers for scalar attributes loaded are removed.
 - lazy load callables for objects / collections *stay*

Attributes marked as "expired" can potentially remain
"expired" after this step if a value was not populated in state.dict.

N)_commit_all_states)r:   rK   r   s      r;   _commit_allInstanceState._commit_all  s    $ 	$?r>   c                >   U H  u  p4UR                   nUR                  R                  5         SU;   a  US	 UR                  R	                  U5        U(       a,  UR
                  (       a  UR                  R                  U5        S=Ul        Ul        SUl	        M     g)z.Mass / highly inlined version of commit_all().r   FN)
rU   rZ   r  r[   rb  rh   rV  r
  ri   rd   )r:   iter_r   rJ   rK   r   s         r;   rf   InstanceState._commit_all_states  s     "LEJ!!'')#z134$$66u=''//6-22ENU] $E "r>   )rp   r   rd   ru   rW   rZ   ri   r[   ro   rb   rX   rh   rY   r   r]   )rY   r   rX   r\   )r?   z'util.ReadOnlyProperties[AttributeState])r?   rg   )r_   strr?   rP   )r?   Optional[Session])r?   zOptional[AsyncSession])r?   zOptional[_O])r?   zOptional[Tuple[Any, ...]])r?   r^   )r?   z4Dict[int, Union[Literal[False], InstanceState[Any]]])r?   zDict[str, PendingCollection])r?   z%Dict[str, _AdaptedCollectionProtocol])r?   z
Mapper[_O])F)r   zIterable[InstanceState[_O]]r   r.   r   rg   r?   rP   r7   )r   rm  r?   rP   r?   rP   )ry   re   r?   rP   )r?   r$   )r   r   r   r   r?   rP   )r_   rl  r   r(   r?   r'   )r_   rl  r?   r&   )r_   rl  r?   r   )r?   rf   )r   rf   r?   rP   )rK   r$   r_   rl  r?   rP   )r  InstanceState[Any]r?   rP   )rX   r\   r  r%   r_   r   r?   z_InstallLoaderCallableProto[_O])rK   r$   r'  zSet[InstanceState[Any]]r?   rP   )rK   r$   r/  Iterable[str]r0  rg   r?   rP   )rJ   rO   r   r(   r?   r   )r?   rt   )rC  rp  r?   rt   )FF)rK   r$   r7  zOptional[AttributeImpl]r\  r   r(  rg   r]  rg   r?   rP   )rK   r$   rC  rp  r?   rP   )rK   r$   r   r@   r?   rP   )rj  z2Iterable[Tuple[InstanceState[Any], _InstanceDict]]r   r@   r?   rP   )RrA   rB   rC   rD   rQ   	__slots____annotations__r]   r_   r`   ra   r   rootrb   rc   rd   rh   ri   rj   rk   rl   rm   ro   rp   r   rq   r    
EMPTY_DICTru   r|   memoized_propertyr   propertyr   r   r   r   r   r   non_memoized_propertypreload_moduler   r   r   r0   rn   r   r   r   r   r   r   r   classmethodr   r   r   rz   r   r   r   r   r   r   r  r  r  r  r)  r1  r>  r:  rD  rG  
deprecatedrJ  rO  r_  rc  rg  rf  rE   r8   r>   r;   rS   rS   c   s
   6I  $J$*.C	'.E=*,L',*//I|/"&L-&$(K!(	##Hd0GT HdM4). $.K!NF!3707&& 	 !  JI	 OO	( 

 
 7 7 3 3 I I:  ( M M ; ; 
	12
 3  
   .  6    & 	 	 
  
  
  
# #   
 #	#%+#% #% 	#%
 
#% #%J62:  $
BL&,
<'6R
*3 &,;BE	( 801"012I01	01l  	<< '< 	<
 
<B&1<	: B B

 
 
 	__	C
  
 
 !!FF &F 	F
 F F 
FP(< LP@"@3H@	@(  04%A% -% 
	% %r>   rS   c                      \ rS rSr% SrSrS\S'   S\S'   SS jr\SS	 j5       r	\SS
 j5       r
\SS j5       rSS jrSrg)r   i  aj  Provide an inspection interface corresponding
to a particular attribute on a particular mapped object.

The :class:`.AttributeState` object is accessed
via the :attr:`.InstanceState.attrs` collection
of a particular :class:`.InstanceState`::

    from sqlalchemy import inspect

    insp = inspect(some_mapped_object)
    attr_state = insp.attrs.some_attribute

rJ   r_   ro  rJ   rl  r_   c                    Xl         X l        g r7   r|  )r:   rJ   r_   s      r;   r|   AttributeState.__init__  s    
r>   c                j    U R                   R                  R                  U R                  [        5      $ )zThe current value of this attribute as loaded from the database.

If the value has not been loaded, or is otherwise not present
in the object's dictionary, returns NO_VALUE.

)rJ   r   r  r_   r   r9   s    r;   loaded_valueAttributeState.loaded_value  s#     zz""488X66r>   c                    U R                   R                  U R                     R                  U R                   R	                  5       U R                   R
                  5      $ )zReturn the value of this attribute.

This operation is equivalent to accessing the object's
attribute directly or via ``getattr()``, and will fire
off any pending loader callables if needed.

)rJ   rX   r_   __get__rY   rW   r9   s    r;   valueAttributeState.value  sD     zz!!$((+33JJNNdjj//
 	
r>   c                V    U R                   R                  U R                  [        5      $ )a  Return the current **pre-flush** change history for
this attribute, via the :class:`.History` interface.

This method will **not** emit loader callables if the value of the
attribute is unloaded.

.. note::

    The attribute history system tracks changes on a **per flush
    basis**. Each time the :class:`.Session` is flushed, the history
    of each attribute is reset to empty.   The :class:`.Session` by
    default autoflushes each time a :class:`_query.Query` is invoked.
    For
    options on how to control this, see :ref:`session_flushing`.


.. seealso::

    :meth:`.AttributeState.load_history` - retrieve history
    using loader callables if the value is not locally present.

    :func:`.attributes.get_history` - underlying function

)rJ   r   r_   r   r9   s    r;   historyAttributeState.history"  s     4 zz%%dhh0EFFr>   c                d    U R                   R                  U R                  [        [        -  5      $ )a  Return the current **pre-flush** change history for
this attribute, via the :class:`.History` interface.

This method **will** emit loader callables if the value of the
attribute is unloaded.

.. note::

    The attribute history system tracks changes on a **per flush
    basis**. Each time the :class:`.Session` is flushed, the history
    of each attribute is reset to empty.   The :class:`.Session` by
    default autoflushes each time a :class:`_query.Query` is invoked.
    For
    options on how to control this, see :ref:`session_flushing`.

.. seealso::

    :attr:`.AttributeState.history`

    :func:`.attributes.get_history` - underlying function

)rJ   r   r_   r   r   r9   s    r;   load_historyAttributeState.load_history>  s$    . zz%%dhhg0EFFr>   )r_   rJ   N)rJ   ro  r_   rl  )r?   r   )r?   r'   )rA   rB   rC   rD   rQ   rq  rr  r|   rv  r  r  r  r  rE   r8   r>   r;   r   r     sb     !I	H 7 7 

 

 G G6Gr>   r   c                  Z    \ rS rSr% SrSrS\S'   S\S'   SS jrSS	 jrSS
 jr	SS jr
Srg)r   iX  a   A writable placeholder for an unloaded collection.

Stores items appended to and removed from a collection that has not yet
been loaded. When the collection is loaded, the changes stored in
PendingCollection are applied to it to produce the final result.

)deleted_itemsadded_itemszutil.IdentitySetr  zutil.OrderedIdentitySetr  c                l    [         R                  " 5       U l        [         R                  " 5       U l        g r7   )r    IdentitySetr  OrderedIdentitySetr  r9   s    r;   r|   PendingCollection.__init__f  s$    !--/224r>   c                N    UR                  U R                  U R                  5      $ r7   )_merger  r  )r:   r  s     r;   merge_with_history$PendingCollection.merge_with_historyj  s    ~~d..0B0BCCr>   c                    XR                   ;   a  U R                   R                  U5        g U R                  R                  U5        g r7   )r  remover  r.  r:   r  s     r;   appendPendingCollection.appendm  s6    &&&%%e,  'r>   c                    XR                   ;   a  U R                   R                  U5        g U R                  R                  U5        g r7   )r  r  r  r.  r  s     r;   r  PendingCollection.removes  s6    $$$##E*""5)r>   )r  r  Nrn  )r  r'   r?   r'   )r  r   r?   rP   )rA   rB   rC   rD   rQ   rq  rr  r|   r  r  r  rE   r8   r>   r;   r   r   X  s/     1I##((5D(*r>   r   )IrQ   
__future__r   typingr   r   r   r   r   r	   r
   r   r   r   rx    r   r   rY  r   _typingr   r   r   r   r   r   r   r   r   r   r   path_registryr   rS  r   r    util.typingr!   r"   r#   r$   r%   
attributesr&   r'   r(   collectionsr)   r   r*   instrumentationr+   r,   r   r-   r   r.   enginer/   ext.asyncio.sessionr0   r   r1   rr  r2   r4   rG   _self_inspectsInspectionAttrInforS   r   r   r8   r>   r;   <module>r     s   #                 '   &   ' #   '    ! ")&()#!7%-% F288 I  O5 5(2,  L%J1172; L% L%^bG bGJ* *r>   