
    +h;                        d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ  ej                  dd	      Z ej                  d
d      Z	 ej                  dd      Z
 ej                  dd      Z ej                  dd      ZeZ	  ej                  ddd      Z ej                  ddd      Z ej                  ddd      Z ej                  ddd      Z ej                  ddd      Z ej                  dd d!      Z ej                  d"d#d$      Z ej                  d%d&d'      Z ej                  d(d)d*      Z ej                  d+d,d-      Z ej                  d.d/eez  ez  ez  ez        Z ej                  d0d1eez        Z ej                  d2d3eez        Z ej                  d4d5eez        Z ej                  d6d7eez        Z ej                  d8d9eez        Z ej                  d:d;eez        Zd<Zd=Z  ej                  d>      Z! ej                  d?      Z" ej                  d@      Z# ej                  dAdB      Z$ ej                  dCdD      Z% ej                  dEdF      Z& ej                  dGdH      Z' e(eg      Z) e(deeg      Z* ej                  dI      Z+ ej                  dJ      Z, ej                  dK      Z-dL Z.dM Z/ ej`                  e       Z1 ej`                  dN      Z2dO Z3dP Z4dQ Z5dR Z6dS Z7dT Z8dU Z9 ejt                  e;      dV        Z<dW Z=dX Z>dY Z?dZ Z@d[ ZAd\ ZB ej                  d]      ZD ejt                  eE      dfd^       ZFdgd_ZG G d` dae;      ZH G db dceH      ZI G dd dee;      ZJy)hz=Constants and rudimental functions used throughout the ORM.

    N   )exc   )
inspection)utilPASSIVE_NO_RESULTzSymbol returned by a loader callable or other attribute/history
    retrieval operation when a value could not be determined, based
    on loader callable flags.
    PASSIVE_CLASS_MISMATCHzSymbol indicating that an object is locally present for a given
    primary key identity but it is not of the requested class.  The
    return value is therefore None and no SQL should be emitted.ATTR_WAS_SETzSymbol returned by a loader callable to indicate the
    retrieved value, or values, were assigned to their attributes
    on the target object.
    
ATTR_EMPTYz@Symbol used internally to indicate an attribute had no callable.NO_VALUEzSymbol which may be placed as the 'previous' value of an attribute,
    indicating no value was loaded for an attribute when it was modified,
    and flags indicated we were not to load it.
    	NO_CHANGEz]No callables or SQL should be emitted on attribute access
    and no state should change
    )	canonicalCALLABLES_OKzELoader callables can be fired off if a value
    is not present.
    SQL_OKzBLoader callables can emit SQL at least on scalar value attributes.RELATED_OBJECT_OKzZCallables can use SQL to load related objects as well
    as scalar value attributes.
       INIT_OKzAttributes should be initialized with a blank
    value (None or an empty collection) upon get, if no other
    value can be obtained.
       NON_PERSISTENT_OKz9Callables can be emitted if the parent is not persistent.   LOAD_AGAINST_COMMITTEDzUCallables should use committed values as primary/foreign keys during a
    load.
        NO_AUTOFLUSHz*Loader callables should disable autoflush.@   NO_RAISEz0Loader callables should not raise any assertions   DEFERRED_HISTORY_LOADz<indicates special load of the previous value of an attribute   PASSIVE_OFFz&Callables can be emitted in all cases.PASSIVE_RETURN_NO_VALUEzPASSIVE_OFF ^ INIT_OKPASSIVE_NO_INITIALIZEz&PASSIVE_RETURN_NO_VALUE ^ CALLABLES_OKPASSIVE_NO_FETCHzPASSIVE_OFF ^ SQL_OKPASSIVE_NO_FETCH_RELATEDzPASSIVE_OFF ^ RELATED_OBJECT_OKPASSIVE_ONLY_PERSISTENTzPASSIVE_OFF ^ NON_PERSISTENT_OKzPASSIVE_OFF | NO_RAISEz>Symbol used specifically for session.merge() and similar cases_sa_class_manager_sa_instance_stateEXT_CONTINUEEXT_STOPEXT_SKIP	ONETOMANYzIndicates the one-to-many direction for a :func:`_orm.relationship`.

    This symbol is typically used by the internals but may be exposed within
    certain API features.

    	MANYTOONEzIndicates the many-to-one direction for a :func:`_orm.relationship`.

    This symbol is typically used by the internals but may be exposed within
    certain API features.

    
MANYTOMANYzIndicates the many-to-many direction for a :func:`_orm.relationship`.

    This symbol is typically used by the internals but may be exposed within
    certain API features.

    NOT_EXTENSIONzSymbol indicating an :class:`InspectionAttr` that's
    not part of sqlalchemy.ext.

    Is assigned to the :attr:`.InspectionAttr.extension_type`
    attribute.

    SET_DEFERRED_EXPIREDDEFER_FOR_STATERAISE_FOR_STATEc                  8     t         j                   fd       }|S )Nc                 b    |d   }D ]  } ||| j                            | |g|dd  i | y )Nr   r   )__name__)fnargskwself	assertion
assertionss        F/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/orm/base.pygeneratez_assertions.<locals>.generate   sA    Aw# 	)IdBKK(	)
4!$qr(!b!    )r   	decorator)r9   r;   s   ` r:   _assertionsr>      s     	^^" " Or<   c                 B    | j                   j                  t        d       S N)__dict__getDEFAULT_MANAGER_ATTR)clss    r:   manager_of_classrE      s    <<0$77r<   rA   c                 *    t        t        |             S )z'Return a string describing an instance.)	state_strinstance_stateinstances    r:   instance_strrK      s     ^H-..r<   c                 l    | yd| j                   j                  t        | j                               fz  S )z=Return a string describing an instance via its InstanceState.Nonez<%s at 0x%x>)class_r3   idobjstates    r:   rG   rG     s0     }!6!6599; HHHr<   c                 <    | yd| j                   j                  dS )zNReturn a string describing an instance's class via its
    InstanceState.
    rM   <>)rN   r3   rQ   s    r:   state_class_strrV     s&    
 }  ..00r<   c                 $    t        |       dz   |z   S N.)rK   )rJ   	attributes     r:   attribute_strr[     s    !C')33r<   c                 $    t        |       dz   |z   S rX   )rG   )rR   rZ   s     r:   state_attribute_strr]     s    Uc!I--r<   c                 ,    t        |       j                  S )a  Given an object, return the primary Mapper associated with the object
    instance.

    Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError`
    if no mapping is configured.

    This function is available via the inspection system as::

        inspect(instance).mapper

    Using the inspection system will raise
    :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is
    not part of a mapping.

    )object_statemapperrI   s    r:   object_mapperra     s      !(((r<   c                 J    t        |       }|t        j                  |       |S )a  Given an object, return the :class:`.InstanceState`
    associated with the object.

    Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError`
    if no mapping is configured.

    Equivalent functionality is available via the :func:`_sa.inspect`
    function as::

        inspect(instance)

    Using the inspection system will raise
    :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is
    not part of a mapping.

    )_inspect_mapped_objectr   UnmappedInstanceError)rJ   rR   s     r:   r_   r_   1  s)    " #8,E}''11r<   c                 p    	 t        |       S # t        j                  ft        j                  z   $ r Y y w xY wr@   )rH   r   UnmappedClassErrorNO_STATErI   s    r:   rc   rc   I  s6    h''""$s||3 s   
 %55c                 t    t        j                  | d      }||j                  S t        j                  |       )NF)r   inspectr`   r   rf   )class_or_mapperinsps     r:   _class_to_mapperrl   Q  s5    ou5D{{$$_55r<   c                 L    t        j                  | d      }||j                  S y)z`Return the :class:`_orm.Mapper` for the given class or None if the
    class is not mapped.
    FN)r   ri   r`   entityrk   s     r:   _mapper_or_nonerp   Y  s)    
 fe,D{{r<   c                     t        j                  | d      }|duxr) |j                   xr |j                  xs |j                  S )zlReturn True if the given object is a mapped class,
    :class:`_orm.Mapper`, or :class:`.AliasedClass`.
    FN)r   ri   is_clause_element	is_mapperis_aliased_classrn   s     r:   _is_mapped_classru   e  sK    
 fe,DD 	6&&&	6^^4t44r<   c                     t        j                  | d      }t        |d      r:t        |j                  d      r$|j                  j                  D cg c]  }| c}S | gS c c}w )NF
selectablec)r   ri   hasattrrw   rx   )ro   rk   rx   s      r:   _orm_columnsrz   r  sR    fe,Dt\"wt'D??,,-a--x .s   	A c                 T    t        j                  | d      }|d uxr t        |dd      S )NFrt   )r   ri   getattrrn   s     r:   _is_aliased_classr}   z  s.    fe,DtH.@% HHr<   c           
         t        j                  |       }|j                  r| }|j                  } nB|j                  r|j
                  } | }n't        |d      r|j                  j                  x}} n| }	 t        | |      S # t        $ r;}t        j                  t        j                  d|d|d      |       Y d}~yd}~ww xY w)zReturn a class attribute given an entity and string name.

    May return :class:`.InstrumentedAttribute` or user-defined
    attribute.

    r`   zEntity 'z' has no property '')replace_contextN)r   ri   is_selectablerx   rt   ro   ry   r`   rN   r|   AttributeErrorr   raise_sa_excInvalidRequestError)ro   keyrk   descriptionerrs        r:   _entity_descriptorr     s     f%D				x	 #{{111f
vs## 
&&6A3G  		
 	

s   4B   	C	1B??Czmanager.mapperc                     	 t        |       }|j                  sy |j                  }|r|j                          |S # t        j
                  $ r Y y w xY wr@   )rE   	is_mappedr`   _check_configurer   rg   )rN   	configureclass_managerr`   s       r:   _inspect_mapped_classr     sV    
(0&&%% ##% << s   : : AAc                     t        | |      }|>t        | t              st        j                  d| d      t        j                  |       |S )a  Given a class, return the primary :class:`_orm.Mapper` associated
    with the key.

    Raises :exc:`.UnmappedClassError` if no mapping is configured
    on the given class, or :exc:`.ArgumentError` if a non-class
    object is passed.

    Equivalent functionality is available via the :func:`_sa.inspect`
    function as::

        inspect(some_mapped_class)

    Using the inspection system will raise
    :class:`sqlalchemy.exc.NoInspectionAvailable` if the class is not mapped.

    )r   zClass object expected, got 'z'.)r   
isinstancetyper   ArgumentErrorr   rf   )rN   r   r`   s      r:   class_mapperr     sP    " #6Y?F~&$'&&6<>  $$V,,r<   c                   N    e Zd ZdZdZdZ	 dZ	 dZ	 dZ	 dZ		 dZ
	 dZ	 dZ	 dZ	 eZy)InspectionAttra#  A base class applied to all ORM objects that can be returned
    by the :func:`_sa.inspect` function.

    The attributes defined here allow the usage of simple boolean
    checks to test basic facts about the object returned.

    While the boolean checks here are basically the same as using
    the Python isinstance() function, the flags here can be used without
    the need to import all of these classes, and also such that
    the SQLAlchemy class system can change while leaving the flags
    here intact for forwards-compatibility.

     FN)r3   
__module____qualname____doc__	__slots__r   rt   is_instancers   	is_bundleis_propertyis_attribute_is_internal_proxyrr   r-   extension_typer   r<   r:   r   r     ss     IM( GKHIEIAKIL  + #Nr<   r   c                   4    e Zd ZdZej
                  d        Zy)InspectionAttrInfoa  Adds the ``.info`` attribute to :class:`.InspectionAttr`.

    The rationale for :class:`.InspectionAttr` vs. :class:`.InspectionAttrInfo`
    is that the former is compatible as a mixin for classes that specify
    ``__slots__``; this is essentially an implementation artifact.

    c                     i S )a  Info dictionary associated with the object, allowing user-defined
        data to be associated with this :class:`.InspectionAttr`.

        The dictionary is generated when first accessed.  Alternatively,
        it can be specified as a constructor argument to the
        :func:`.column_property`, :func:`_orm.relationship`, or
        :func:`.composite`
        functions.

        .. versionchanged:: 1.0.0 :attr:`.MapperProperty.info` is also
           available on extension types via the
           :attr:`.InspectionAttrInfo.info` attribute, so that it can apply
           to a wider variety of ORM and extension constructs.

        .. seealso::

            :attr:`.QueryableAttribute.info`

            :attr:`.SchemaItem.info`

        r   )r7   s    r:   infozInspectionAttrInfo.info"  s	    . 	r<   N)r3   r   r   r   r   memoized_propertyr   r   r<   r:   r   r     s!     
 r<   r   c                       e Zd ZdZdZy)_MappedAttributezVMixin for attributes which should be replaced by mapper-assigned
    attributes.

    r   N)r3   r   r   r   r   r   r<   r:   r   r   <  s    
 Ir<   r   )F)T)Kr   operator r   r   r   r   symbolr   r	   r
   r   r   	NEVER_SETr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   PASSIVE_MERGErC   DEFAULT_STATE_ATTRr'   r(   r)   r*   r+   r,   r-   	frozenset
_never_set	_none_set_SET_DEFERRED_EXPIRED_DEFER_FOR_STATE_RAISE_FOR_STATEr>   rE   
attrgetterrH   instance_dictrK   rG   rV   r[   r]   ra   r_   	_inspectsobjectrc   rl   rp   ru   rz   r}   r   dottedgetter_state_mapperr   r   r   r   r   r   r   r<   r:   <module>r      s         DKK  %D  t{{ T[[J

 4;; 	 DKK 	 t{{  
L
  DKK   $++   DKKC  %   t{{4 4;;: $F  dkk,--7,FO	 &$++G# 
 $,%4 
 4;;.+:N  '4;;%-- 
 &$++%--  DH$ + ) t{{>*4;;z"4;;z"DKK	 DKK	 T[[
 	 	{#
tY(9:;	#$:; 4;;01 4;;01 8 %$$%78###J//I14.)&0 f 6	
I

< "!!"23 d 8KV K\   Fv r<   