
    +h*                        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 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! 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. dd&lm/Z/ dd'lm0Z0 dd(lm1Z1 dd)l2m3Z3 dd*l4m5Z5 dd+l4m6Z6 dd,l4m7Z7 dd-l8m9Z9 dd.l8m:Z: dd/l8m;Z; dd0l<m=Z= dd1l>m?Z? dd2l>m@Z@ dd3l>mAZA dd4l>mBZB dd5l>mCZC dd6l>mDZD dd7l>mEZE dd8l>mFZF dd9lGmHZH dd:lGmIZI dd;lmJZJ dd<lKmLZL dd=lMmNZN dd>lMmOZO dd?lMmPZP dd@lMmQZQ ddAlMmRZR ddBlMmSZS ddClMmTZT ddDlMmUZU ddElMmVZV ddFlMmWZW ddGlMmXZX dHdIlmYZZ dHdJlmMZ[ dHdKl\m]Z] dgdMZ^ e]eRdN      Z_ e]e:dO      Z` e[j                  dPdQ      dR        ZbdS Zc e]e3dT      Zd e]edU      ZedV ZfdW Zg eZj                         fdXZi e]e/dY      Z e]edZ      Zjd[ Zkej                  j                  Zlej                  j                  Znej                  j                  Zoej                  j                  Zpej                  j                  Zqej                  j                  Zrej                  j                  Zsej                  j                  Ztej                  j                  Zuej                  j                  Zvej                  j                  Zwej                  j                  Zxej                  j                  Zyej                  j                  Zzej                  j                  Z{ e[j                  d\d]      d^        Z| e]e5d_      Z}	 dd`l~mZ ddal~mZ ddbl~mZ ddcl~mZ dddl~mZ ddel~mZ df Z e e              yL)hz
Functional constructs for ORM configuration.

See the SQLAlchemy object relational tutorial and mapper configuration
documentation for an overview of how this module is used.

   )exc)mapper)strategy_options)AttributeEvent)InstrumentedAttribute)Mapped)QueryableAttribute)QueryContext)as_declarative)declarative_base)declarative_mixin)DeclarativeMeta)declared_attr)has_inherited_table)registry)synonym_for)CompositeProperty)SynonymProperty)IdentityMap)ClassManager)EXT_CONTINUE)EXT_SKIP)EXT_STOP)InspectionAttr)InspectionAttrInfo)
MANYTOMANY)	MANYTOONE)MapperProperty)NOT_EXTENSION)	ONETOMANY)PropComparator)UserDefinedOption)merge_frozen_result)merge_result)class_mapper)configure_mappers)Mapper)reconstructor)	validatesColumnProperty)AliasOption)FromStatement)Query)foreign)RelationshipProperty)remote)scoped_session)close_all_sessions)make_transient)make_transient_to_detached)object_session)ORMExecuteState)Session)sessionmaker)SessionTransaction)AttributeState)InstanceState)Load)UOWTransaction)aliased)Bundle)CascadeOptions)join)LoaderCriteriaOption)object_mapper)	outerjoin)polymorphic_union)was_deleted)with_parent)with_polymorphic   )sqlutil)public_factoryNc                     |j                  dd      r|j                  dd       n|j                  dd       |j                  dd       |j                  dd       t        dd| i|S )	a  Create a new :class:`.Session`
    with no automation enabled by default.

    This function is used primarily for testing.   The usual
    route to :class:`.Session` creation is via its constructor
    or the :func:`.sessionmaker` function.

    :param bind: optional, a single Connectable to use for all
      database access in the created
      :class:`~sqlalchemy.orm.session.Session`.

    :param \*\*kwargs: optional, passed through to the
      :class:`.Session` constructor.

    :returns: an :class:`~sqlalchemy.orm.session.Session` instance

    The defaults of create_session() are the opposite of that of
    :func:`sessionmaker`; ``autoflush`` and ``expire_on_commit`` are
    False, ``autocommit`` is True.  In this sense the session acts
    more like the "classic" SQLAlchemy 0.3 session with these.

    .. deprecated:: 1.4  The "autocommit" parameter will be removed in
       SQLAlchemy 2.0.  :func:`_orm.create_session` will return a
       :class:`_orm.Session` that does not include "autocommit' behavior
       in release 2.0.

    Usage::

      >>> from sqlalchemy.orm import create_session
      >>> session = create_session()

    It is recommended to use :func:`sessionmaker` instead of
    create_session().

    futureF
autocommitT	autoflushexpire_on_commitbind )get
setdefaultr8   )rT   kwargss     J/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/orm/__init__.pycreate_sessionrZ   [   sg    J zz(E",.,-
k5)
(%0''''    z.ormz.orm.relationshiprelationz!Please use :func:`.relationship`.c                      t        | i |S )z#A synonym for :func:`relationship`.relationship)argkws     rY   r\   r\      s     ###r[   c                 $    d|d<   t        | fi |S )ai  Construct a dynamically-loading mapper property.

    This is essentially the same as
    using the ``lazy='dynamic'`` argument with :func:`relationship`::

        dynamic_loader(SomeClass)

        # is the same as

        relationship(SomeClass, lazy="dynamic")

    See the section :ref:`dynamic_relationship` for more details
    on dynamic loading.

    dynamiclazyr^   )argumentra   s     rY   dynamic_loaderrf      s      BvJ'B''r[   z.orm.column_propertyz.orm.compositec                 
    | |fS )a  When using the :paramref:`_orm.relationship.backref` parameter,
    provides specific parameters to be used when the new
    :func:`_orm.relationship` is generated.

    E.g.::

        'items':relationship(
            SomeItem, backref=backref('parent', lazy='subquery'))

    The :paramref:`_orm.relationship.backref` parameter is generally
    considered to be legacy; for modern applications, using
    explicit :func:`_orm.relationship` constructs linked together using
    the :paramref:`_orm.relationship.back_populates` parameter should be
    preferred.

    .. seealso::

        :ref:`relationships_backref` - background on backrefs

    rU   )namerX   s     rY   backrefri      s    , &>r[   c                      t        | ddi|S )a  Indicate a column-based mapped attribute that by default will
    not load unless accessed.

    :param \*columns: columns to be mapped.  This is typically a single
     :class:`_schema.Column` object,
     however a collection is supported in order
     to support multiple columns mapped under the same attribute.

    :param raiseload: boolean, if True, indicates an exception should be raised
     if the load operation is to take place.

     .. versionadded:: 1.4

     .. seealso::

        :ref:`deferred_raiseload`

    :param \**kw: additional keyword arguments passed to
     :class:`.ColumnProperty`.

    .. seealso::

        :ref:`deferred`

    deferredTr*   )columnsra   s     rY   rk   rk      s    4 '848R88r[   c                 *    t        |       }d|_        |S )a  Indicate an attribute that populates from a query-time SQL expression.

    :param default_expr: Optional SQL expression object that will be used in
        all cases if not assigned later with :func:`_orm.with_expression`.
        E.g.::

            from sqlalchemy.sql import literal

            class C(Base):
                #...
                my_expr = query_expression(literal(1))

        .. versionadded:: 1.3.18


    .. versionadded:: 1.2

    .. seealso::

        :ref:`mapper_querytime_expression`

    ))query_expressionT)r+   strategy_key)default_exprprops     rY   rn   rn      s    . ,'D5DKr[   z.orm.mapperz.orm.synonymc                  T    t        j                  t        j                         d       y)a  Remove all mappers from all classes.

    .. versionchanged:: 1.4  This function now locates all
       :class:`_orm.registry` objects and calls upon the
       :meth:`_orm.registry.dispose` method of each.

    This function removes all instrumentation from classes and disposes
    of their associated mappers.  Once called, the classes are unmapped
    and can be later re-mapped with new mappers.

    :func:`.clear_mappers` is *not* for normal use, as there is literally no
    valid usage for it outside of very specific testing scenarios. Normally,
    mappers are permanent structural components of user-defined classes, and
    are never discarded independently of their class.  If a mapped class
    itself is garbage collected, its mapper is automatically disposed of as
    well. As such, :func:`.clear_mappers` is only for usage in test suites
    that re-use the same classes with different mappings, which is itself an
    extremely rare use case - the only such use case is in fact SQLAlchemy's
    own test suite, and possibly the test suites of other ORM extension
    libraries which intend to test various combinations of mapper construction
    upon a fixed set of classes.

    FN)	mapperlib_dispose_registries_all_registriesrU   r[   rY   clear_mappersrv     s    2 !!)";";"=uEr[   	eagerloadz#Please use :func:`_orm.joinedload`.c                      t        | i |S )z#A synonym for :func:`joinedload()`.)
joinedload)argsrX   s     rY   rw   rw   2  s     t&v&&r[   z.orm.contains_alias)AttributeEvents)MapperEvents)InstanceEvents)InstrumentationEvents)QueryEvents)SessionEventsc                 
   ddl m} ddl m} ddl m} ddl m} dd lddlma t        fd	| j                         D              a	t        j                  j                  d
       t        j                  j                  d       y )NrJ   rL   r   )rc   )events)loading    )AppenderQueryc              3   l   K   | ]+  \  }}|j                  d       sj                  |      s| - yw)_N)
startswithismodule).0rh   obj_inspects      rY   	<genexpr>z__go.<locals>.<genexpr>N  s6      D#$(9(9#(> 	s   14zsqlalchemy.ormzsqlalchemy.ext) rM   rc   r   r   inspectr   sorteditems__all___sa_util	preloadedimport_prefix)lclssa_utilrc   r   r   r   s        @rY   __gor   C  s`     #&  G $$%56$$%56r[   )N)__doc__r   r   r   rs   r   
attributesr   r   r   r	   contextr
   decl_apir   r   r   r   r   r   r   r   descriptor_propsr   r   identityr   instrumentationr   
interfacesr   r   r   r   r   r   r   r   r   r    r!   r"   r   r#   r$   r%   r&   r'   r(   r)   
propertiesr+   queryr,   r-   r.   relationshipsr/   r0   r1   scopingr2   sessionr3   r4   r5   r6   r7   r8   r9   r:   stater;   r<   r=   
unitofworkr>   rM   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rK   _sqlr   util.langhelpersrN   rZ   with_loader_criteriar_   deprecated_20r\   rf   column_property	compositeri   rk   nullrn   synonymrv   ry   _unbound_fncontains_eagerdeferundeferundefer_groupwith_expression	load_onlylazyloadsubqueryloadselectinloadimmediateloadnoload	raiseloaddefaultloadselectin_polymorphicrw   contains_aliasr   r{   r|   r}   r~   r   r   r   localsrU   r[   rY   <module>r      s    !  & -  * ! $ & ' % # )  ! / - ! ) $     & * " ! & % ! & ) ( !   %  !  &     " / ! # ' # / # $  ! ' !   " &      &   #   "   -,(^ &&:FC 24GH 
$GH$ I$(( !1GH,.>?	29: #,$))+ 8 
	.
.
9F8 ((44
!00<<**

"
"
.
. ..::"22>>&&22	$$00,,88,,88 ..::		 	 	,	,&&22	**66'<<HH  %JK' L'
  -BC'$&-#%7* VXr[   