
    -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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\ \5      r! " S S\!5      r" " S S\#5      r$\$" 5       S?S! j5       r%\%RL                  S" 5       r%\$" 5       S# 5       r'\'RL                  S$ 5       r'\$" 5       S?S% j5       r(\(RL                  S& 5       r(\$" 5       S' 5       r)\)RL                  S( 5       r)\$" 5       S) 5       r*\*RL                  S* 5       r*\$" 5       S+ 5       r+\+RL                  S, 5       r+\$" 5       S- 5       r,\,RL                  S. 5       r,\$" 5       S/ 5       r-\-RL                  S0 5       r-\$" 5       S@S1 j5       r.\.RL                  S2 5       r.\$" 5       S3 5       r/\/RL                  S4 5       r/\$" 5       S@S5 j5       r0\0RL                  S6 5       r0\$" 5       S7 5       r1\1RL                  S8 5       r1\$" 5       S9 5       r2\2RL                  S: 5       r2\$" 5       S; 5       r3\3RL                  S< 5       r3\$" 5       S= 5       r4\4RL                  S> 5       r4g )Az

   )util)QueryableAttribute)_class_to_mapper)_is_aliased_class)_is_mapped_class)InspectionAttr)LoaderOption)MapperProperty)PropComparator)_DEFAULT_TOKEN)_WILDCARD_TOKEN)PathRegistry)TokenRegistry)_orm_full_deannotate   )excinspect)and_)	coercions)roles)
traversals)visitors)_generative)
Generativec                   X  ^  \ rS rSrSrSrS\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S	\R                  R                  4/rS
 r\S 5       rS rS rS rS r\S 5       rU 4S jrSrSrSrSrSrSrS r S r!S r"  S(S jr#S r$S r%S r&\'S 5       r(\' S)S j5       r)\'S*S j5       r*\'S 5       r+\'S  5       r, S+S! jr-S,S" jr.S# r/S$ r0S% r1S& r2S'r3U =r4$ )-Load&   a7  Represents loader options which modify the state of a
:class:`_query.Query` in order to affect how various mapped attributes are
loaded.

The :class:`_orm.Load` object is in most cases used implicitly behind the
scenes when one makes use of a query option like :func:`_orm.joinedload`,
:func:`.defer`, or similar.   However, the :class:`_orm.Load` object
can also be used directly, and in some cases can be useful.

To use :class:`_orm.Load` directly, instantiate it with the target mapped
class as the argument.   This style of usage is
useful when dealing with a :class:`_query.Query`
that has multiple entities::

    myopt = Load(MyClass).joinedload("widgets")

The above ``myopt`` can now be used with :meth:`_query.Query.options`,
where it
will only take effect for the ``MyClass`` entity::

    session.query(MyClass, MyOtherClass).options(myopt)

One case where :class:`_orm.Load`
is useful as public API is when specifying
"wildcard" options that only take effect for a certain class::

    session.query(Order).options(Load(Order).lazyload('*'))

Above, all relationships on ``Order`` will be lazy-loaded, but other
attributes on those descendant objects will load using their normal
loader strategy.

.. seealso::

    :ref:`deferred_options`

    :ref:`deferred_loading_w_multiple`

    :ref:`relationship_loader_options`

Tpathstrategy_of_type_extra_criteria_context_cache_key
local_optsc                     [        U5      nUR                    UR                  U l        [        R
                  " 5       U l        0 U l        SU l        g NF)	r   _post_inspect_path_registryr   r   OrderedDictcontextr$   is_class_strategy)selfentityinsps      tC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/orm/strategy_options.py__init__Load.__init__b   sB    v''	 '')!&    c                 l    U R                  U 5      nXl        0 Ul        0 Ul        S Ul        SUl        U$ N )__new__r   r*   r$   r!   r"   )clsr   loads      r/   for_existing_pathLoad.for_existing_pathm   s7    {{3	!r2   c                 $    U R                  U5      $ N)_adjust_for_extra_criteria)r,   r*   uncached_opts      r/   '_adapt_cached_option_to_uncached_option,Load._adapt_cached_option_to_uncached_optionw   s    ..w77r2   c                     U R                   (       d   S5       eUR                  R                  nUR                  nUR	                  5       nUR	                  5       nUR                  U[        U R                   6 5      $ )a  Apply the current bound parameters in a QueryContext to the
immediate "extra_criteria" stored with this Load object.

Load objects are typically pulled from the cached version of
the statement from a QueryContext.  The statement currently being
executed will have new values (and keys) for bound parameters in the
extra criteria which need to be applied by loader strategies when
they handle this criteria for a result set.

z8this should only be called if _extra_criteria is present)r"   compile_stateselect_statementquery_generate_cache_key_apply_params_to_elementr   )r,   r*   
orig_querycurrent_queryk1k2s         r/   _generate_extra_criteriaLoad._generate_extra_criteriaz   sw       	FE	F  **;;
 ++-..0**2tT5I5I/JKKr2   c                 r   ^^^ TR                   R                  m0 nSS/mUUU4S jnU R                  X#5      $ )zApply the current bound parameters in a QueryContext to all
occurrences "extra_criteria" stored within al this Load object;
copying in place.

Nc                    >^^ U R                   (       d  g TS   c-  TR                  5       TR                  R                  5       4TS S & Tu  mm[        UU4S jU R                    5       5      U l         g )N    c              3   H   >#    U  H  nTR                  TU5      v   M     g 7fr<   )rF   ).0critrI   rJ   s     r/   	<genexpr>CLoad._adjust_for_extra_criteria.<locals>.process.<locals>.<genexpr>   s(      (/D ++B55/   ")r"   rE   rD   tuple)optrI   rJ   ckr*   rG   s    @@r/   process0Load._adjust_for_extra_criteria.<locals>.process   sj    &&!u}224MM5571 FB"' (//( #Cr2   )rB   rC   _deep_clone)r,   r*   appliedrY   rX   rG   s    `  @@r/   r=   Load._adjust_for_extra_criteria   s<     **;;
D\	  11r2   c                 r   X;   a  X   $ U R                  5       nX1U '   U R                  Ul        UR                  U R                  :X  d   eUR                  U R                  :X  d   eUR                  U R                  :X  d   eU R
                  (       ap  [        R                  " U R
                  R                  5        VVs/ s H/  u  pEU[        U[        5      (       a  UR                  X5      OU4PM1     snn5      Ul        UR                  R                  U R                  5        U" U5        U$ s  snnf r<   )	_generater    propagate_to_loadersr+   is_opts_onlyr*   r   r)   items
isinstancer   r[   r$   update)r,   r\   rY   clonedkeyvalues         r/   r[   Load._deep_clone   s   ?= !--**d.G.GGGG''4+A+AAAA""d&7&7777<<!-- '+ll&8&8&: ';
 %eT22 ))';"	 ';
FN 	  1s   6D3
c                     / nU R                   c  / $ U R                   R                  5        H$  u  u  p#nUS:w  a  M  UR                  X44-   5        M&     U$ Nloader)r*   rb   append)r,   
serializedrf   loader_pathobjs        r/   r#   Load._context_cache_key   sZ    
<<I'+||'9'9';#ShkF23 (< r2   c                 :   > [         [        U ]  5       n0 Ul        U$ r<   )superr   r_   r$   )r,   re   	__class__s     r/   r_   Load._generate   s    tT,.r2   FNr5   c                     UR                   R                  (       d  g U R                  UU[        UR                  5      (       + 5        g r<   )compile_options_enable_eagerloads_processboolcurrent_path)r,   rB   mapper_entitiess      r/   'process_compile_state_replaced_entities,Load.process_compile_state_replaced_entities   s;     ,,??
 	]//00	
r2   c                     UR                   R                  (       d  g U R                  UUR                  [	        UR
                  5      (       + =(       a    UR                   R                  (       + 5        g r<   )rv   rw   rx   _lead_mapper_entitiesry   rz   _for_refresh_state)r,   rB   s     r/   process_compile_stateLoad.process_compile_state  sU    ,,??//]//00 E!11DDD		
r2   c                 n   UR                   R                  nUR                  nU(       ag  U R                  R	                  5        HH  u  u  pgnU(       a  UR
                  (       d  M"  U R                  Xu5      n	U	c  M8  UUR                  Xi4'   MJ     g UR                  R                  U R                  5        g r<   )	rv   r   rz   r*   rb   r`   
_chop_path
attributesrd   )
r,   rB   r{   raiseerr
is_refreshrz   token
start_pathrk   chopped_start_paths
             r/   rx   Load._process  s    "22EE
$11/3||/A/A/C+#Vf&A&A%)__Z%N"%1  ",,3 0D $$++DLL9r2   c                 d
   U R                   nS U l         U(       aa  UR                  (       dP  [        U[        5      (       a  [        R
                  " S5      e[        R
                  " SUR                  < S35      e[        U[        R                  5      (       a  UR                  [        5      nUn	UR                  [        5      (       d  U(       a^  U(       a  SU l        U(       a	  U< SU< 3nU(       a   UR                  (       d  UR                  U   nUR                  U5      nXl        U$ U(       a  [#        U5      n
OUR$                  n
[        R&                  " S5         [)        U
R*                  U5      n UR,                  =p+X   nGO[#        U5      nUR6                  (       d  UR                  (       a\  [8        R:                  " UR                  US   5      (       d1  U(       a)  [        R
                  " SU< SUR$                  < S35      eg GOUR<                  (       a	  U=pX   nGOUR>                  (       Ga  UR,                  =p[8        R:                  " UR                  US   5      (       d  U(       a  [        R
                  " SU< SUR$                  < S[A        U5      S:  aX  UR$                  R6                  (       a=  UR                  R                  (       a"  SUS   < SUR*                  RB                  < S3OS< 35      eg URD                  (       a"  U RD                  (       d  URD                  U l"        [)        USS 5      (       a  UR                   n[#        U5      =nnUc  U RF                  nURH                  U   RK                  US5      nUR                  (       dO  [8        RL                  " URN                  RP                  URN                  SSUb  [#        U5      OS S9n[#        U5      nURH                  U   RS                  USU5        X   U   nUU l         OX   nUb  WRU                  U5        UR                  (       a  URH                  nXl        U$ ! [.         a`  n[        U[0        5      (       dE  [        R2                  " [        R
                  " SU	< SU
< S	[5        U5      < S
35      US9   S nAGNHe S nAff = f! [.         aI  nU(       a8  [        R2                  " [        R
                  " SU< SU
< S35      US9   S nAGN S nAg S nAff = f)Nz3Wildcard token cannot be followed by another entityzMapped attribute 'z#' does not refer to a mapped entityF:zUsing strings to indicate column or relationship paths in loader options is deprecated and will be removed in SQLAlchemy 2.0.  Please use the class-bound attribute directly.zExpected attribute "z" on z' to be a mapped attribute; instead got z object.)replace_contextzCan't find property named "z in this Query.zAttribute 'z' does not link from element ''zAttribute "z" does not link from element "".r   z  Did you mean to use z	.of_type(z)? r!   path_with_polymorphicT)aliased_use_mapper_path_existing_alias)+r!   
has_entityrc   r   sa_excArgumentErrorpropr   string_typesendswithr   r   r`   is_aliased_classparentr   r   r   r-   warn_deprecated_20getattrclass_propertyAttributeErrorr
   raise_type	is_mapperorm_util$_entity_corresponds_to_use_path_implis_propertyis_attributelen__name__r"   r*   entity_pathgetwith_polymorphicmapperbase_mapperset_get_strategy)r,   r   attrfor_strategywildcard_keyr   polymorphic_entity_contextexisting_of_typedefault_tokenattr_str_nameentfound_propertyaeerrr.   r   acext_infoof_type_infoexistings                       r/   _generate_pathLoad._generate_path  sZ     ==DOO$..**I  **26))> 
 dD--.. MM.9M M}}_-- 05D-&2D9D $,<,M,M;;'78Dzz$' 	./kk##6 szz40,0MM9D :D4=D~~!6!6  DDKKb   $228<dkkK 
  $ !!(,,z"""(,5DDKKb   $22 !% $
 (+4y1}(,(=(=(,(D(D(D (,Bx1E1E%G *,%, $  $''0D0D ,0+?+?D(4T22B.5bk9H|1959\\2#//59924K H $44%66$OO77$OO$(-1'3 -4H,=!% $+2;$$T*..24KR  :h/D$0DM  :D#((6??##D	Y & %dN;;"00 $1#tDz!C -/   " 
 KK,,37> ),   
 s7   'S >Q/ /
S9ASSS
T/&9T**T/c                 $    SU R                   < S3$ )NzLoad(strategy=))r    r,   s    r/   __str__Load.__str__  s    &*mm55r2   c                 P    Ub"  [        [        UR                  5       5      5      nU$ r<   )rV   sortedrb   )r,   r    s     r/   _coerce_stratLoad._coerce_strat  s#    VHNN$456Hr2   c                     [        S5      e)NzHOnly 'unbound' loader options may be used with the Load.options() method)NotImplementedError)r,   r   r\   bounds       r/   _apply_to_parentLoad._apply_to_parent  s    !$
 	
r2   c           	      F   0 n[        U [        5      (       + nU(       a  [        S5      eU H  n UR                  XU5        M     g! [         aO  n[        U[
        5      (       d4  [        R                  " [        R                  " SU< S35      US9   SnAMn  e SnAff = f)a  Apply a series of options as sub-options to this
:class:`_orm.Load`
object.

E.g.::

    query = session.query(Author)
    query = query.options(
                joinedload(Author.book).options(
                    load_only(Book.summary, Book.excerpt),
                    joinedload(Book.citations).options(
                        joinedload(Citation.author)
                    )
                )
            )

:param \*opts: A series of loader option objects (ultimately
 :class:`_orm.Load` objects) which should be applied to the path
 specified by this :class:`_orm.Load` object.

.. versionadded:: 1.3.6

.. seealso::

    :func:`.defaultload`

    :ref:`relationship_loader_options`

    :ref:`deferred_loading_w_multiple`

zMThe options() method is currently only supported for 'unbound' loader optionszLoader option z2 is not compatible with the Load.options() method.)from_N)
rc   _UnboundLoadr   r   r   r   r   r   r   r   )r,   optsapply_cacher   rW   r   s         r/   optionsLoad.options  s    B t\22%/  C$$T>  " 
!#t,,KK,,8;> !  
s   A
B ABBB c                     U R                  U5      nX0l        U R                  XS5      nUR                  U l        UR                  U l        UR
                  U l        S=Ul        U l        UR                  U l        g )NrelationshipF)r   r`   _clone_for_bind_strategyr   r!   r"   r+   )r,   r   r    r`   re   s        r/   set_relationship_strategyLoad.set_relationship_strategy  sn     %%h/$8!..t~NKK	%55<AA 4#9$*$?$?!r2   c           	      v    U R                  U5      nSU l        U H  nU R                  XRSXCS9nSUl        M     g )NFcolumn)	opts_onlyr   T)r   r+   r   r`   )r,   attrsr    r   r   r   re   s          r/   set_column_strategyLoad.set_column_strategy%  sJ    %%h/!&D22I 3 F +/F'	 r2   c                 j    U R                  U5      nU H  nU R                  X2S 5      nSUl        M     g NT)r   r   r`   )r,   r   r    r   re   s        r/   set_generic_strategyLoad.set_generic_strategy/  s6    %%h/D2244HF*.F' r2   c                     U R                  U5      nU R                  S US 5      nSUl        SUl        UR                  R                  U5        g r   )r   r   r+   r`   r$   rd   )r,   r    r   re   s       r/   set_class_strategyLoad.set_class_strategy6  sJ    %%h/..tXtD#' &*#  &r2   c                 >   U R                  5       nUR                  U R                  XU5        X&l        U R                  Ul        U(       a  UR                  R                  U5        U(       a  SUl        U(       d  UR                  (       a  UR                  5         U$ )zCreate an anonymous clone of the Load/_UnboundLoad that is suitable
to be placed in the context / _to_bind collection of this Load
object.   The clone will then lose references to context/_to_bind
in order to not create reference cycles.

T)r_   r   r   r    r$   rd   ra   _set_path_strategy)r,   r   r    r   r   r   re   s          r/   r   Load._clone_for_bind_strategy>  su     !diiF" OO$$T*"&Fv**%%'r2   c                    U(       d  U(       dz  UR                  US5      nU(       aM  U(       aE  UR                  R                  U R                  5        U=R                  U R                  -  sl        g g UR	                  USU 5        g UR                  US5      nUR	                  USU 5        U(       aW  UR
                  (       aE  U R                  R                  UR                  5        U=R                  U R                  -  sl        g g g rj   )r   r$   rd   r"   r   ra   )r,   r*   r   replace
merge_optsr   s         r/   _set_for_pathLoad._set_for_pathU  s    Wxx2H''..t?,,0D0DD,  (D1xx2HHHWh-H11&&x':':;((D,@,@@( 2xr2   c                    U R                   (       d2  U R                  R                  (       a  U R                  R                  nOU R                  nUR                  (       a>  UR                  5        H)  nU R                  U R                  USU R                  S9  M+     O&U R                  U R                  USU R                  S9  S U l        g )NTr   r   )	r+   r   r   r   is_tokengenerate_for_superclassesr   r*   ra   )r,   effective_pathr   s      r/   r   Load._set_path_strategye  s    %%$))*>*>!YY--N!YYN""&@@B""LL #00	 #  C ,,	   r2   c                     U R                   R                  5       nSUS'   US   b  [        R                  " US   S5      US'   U R                  R                  5       US'   U$ )Nr5   r"   r*   )rk   r   )__dict__copyr   serialize_context_dictr   	serializer,   ds     r/   __getstate__Load.__getstate__  se    MM   "
Y<#'>>)kAiL II'')&	r2   c                     U R                   R                  U5        [        R                  " U R                  5      U l        U R
                  b&  [        R                  " U R
                  5      U l        g g r<   )r   rd   r   deserializer   r*   deserialize_context_dict)r,   states     r/   __setstate__Load.__setstate__  sO    U# ,,TYY7	<<#'@@NDL $r2   c                    Sn[        [        XR                  5      5       H  u  nu  pE[        U[        R
                  5      (       aF  US:X  a!  UR                  S[        -   5      (       a  Us  $ US[        < 3:w  a  XER                  :w  a    g XEL a  Ms  [        U[        5      (       a:  UR                  (       a)  UR                  (       a  UR                  U5      (       a  M    g    XS-   S  $ Nr   rO   r   zrelationship:r   )	enumeratezipr   rc   r   r   r   r   r   rf   r   r   isa)r,   to_chopr   ic_tokenp_tokens         r/   r   Load._chop_path  s    %.s7II/F%G!A!'4#4#455 6g..s^/CDD"NOEE;;.!7N33%%%%KK((/ &H0 1uwr2   )r"   r!   r*   r+   r$   r   r`   )TN)Tr&   )FN)TF)5r   
__module____qualname____firstlineno____doc___is_strategy_optionr   ExtendedInternalTraversaldp_has_cache_keydp_plain_objdp_multiInternalTraversaldp_clauseelement_listdp_has_cache_key_tuplesdp_string_multi_dict_cache_key_traversalr0   classmethodr9   r?   rK   r=   r[   r   r#   r_   ra   r+   r    r`   r!   r"   r|   r   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   __static_attributes____classcell__)rs   s   @r/   r   r   &   s   (T  
33DDE	X77DDE	X77@@A	H66LLM ..FF	

 ..CC	
	'  8#LJ2<B  
 LH HO
	
:* #'sj6

 4 4l 37
@ 
@ / / / / ' ' CG.A 4O   r2   r   c                       \ rS rSrSrS rSS jrSrS rS r	SS	 jr
S
 rS rS rS r\S 5       rS rSS jrS rS rS rSrg)r   i  a(  Represent a loader option that isn't tied to a root entity.

The loader option will produce an entity-linked :class:`_orm.Load`
object when it is passed :meth:`_query.Query.options`.

This provides compatibility with the traditional system
of freestanding options, e.g. ``joinedload('x.y.z')``.

c                 <    SU l         / U l        0 U l        SU l        g r4   )r   _to_bindr$   r"   r   s    r/   r0   _UnboundLoad.__init__  s    	!r2   Nc                 @  ^^^ [        U 5      nU R                  nUT;   a  TU   U4$ TU   n[        R                  nUmTc
  [	        5       mXe4UR                  SU R                  U TT5      -   SU R                  4-   U R                  (       a#  S[        UUU4S jU R                   5       5      4OS-   U R                  (       a"  S[        UU4S jU R                   5       5      4OS-   U R                  (       a!  UR                  SU R                  U TT5      -   $ S-   $ )	a  Inlined gen_cache_key

Original traversal is::


    _cache_key_traversal = [
        ("path", visitors.ExtendedInternalTraversal.dp_multi_list),
        ("strategy", visitors.ExtendedInternalTraversal.dp_plain_obj),
        (
            "_to_bind",
            visitors.ExtendedInternalTraversal.dp_has_cache_key_list,
        ),
        (
            "_extra_criteria",
            visitors.InternalTraversal.dp_clauseelement_list),
        (
            "local_opts",
            visitors.ExtendedInternalTraversal.dp_string_multi_dict,
        ),
    ]

The inlining is so that the "_to_bind" list can be flattened to not
repeat the same UnboundLoad options over and over again.

See #6869

r   r    r'  c              3      >#    U  H6  nUT;  d  M  TR                  U5      (       a  M#  UR                  TTTS 9v   M8     g7f))_unbound_option_seenN)add_gen_cache_key)rQ   elemanon_map
bindparamsseens     r/   rS   ._UnboundLoad._gen_cache_key.<locals>.<genexpr>  sO       %2Dt+	 59HHTN	++$jt ,  %2s   
AAAr5   r"   c              3   H   >#    U  H  nUR                  TT5      v   M     g 7fr<   )r-  )rQ   r.  r/  r0  s     r/   rS   r2    s(      $8D ++HjAA$8rU   r$   )idrs   r   _cache_key_traversal_visitorr   visit_multi_listr   r    r'  rV   r"   r$   visit_string_multi_dict)	r,   r/  r0  r+  idselfr7   id_visr1  s	    ``     @r/   r-  _UnboundLoad._gen_cache_key  sG   : DnnXV$c**6"C55#<5D J""		4: 4==)	*  ==   %)MM	 	 #6 '' & $($8$8  9D ?? ++ $//4:?$&	
H G$&	
r2   Fc                 H    U R                   R                  U 5        S U l         g r<   )r'  rl   r   s    r/   r   _UnboundLoad._set_path_strategy  s    T" r2   c                    X;   a  X   $ U R                  5       nX1U '   U R                  Ul        UR                  U R                  :X  d   eUR                  U R                  :X  d   eUR                  U R                  :X  d   eU R
                  =(       d    S Vs/ s H  oDR                  X5      PM     snUl        UR                  R                  U R                  5        U" U5        U$ s  snf r4   )	r_   r    r`   r+   ra   r'  r[   r$   rd   )r,   r\   rY   re   r.  s        r/   r[   _UnboundLoad._deep_clone  s    ?= !--**d.G.GGGG''4+A+AAAA""d&7&7777 <@==;NB;N
;N4W.;N
 	  1
s   C+c           
      0   X;   a  X    $ Uc  U R                   nU R                  5       nXRU '   U R                  Ul        U R                  (       a  U R                  S   n[	        U[
        R                  5      (       a8  UR                  [        5      (       a  UR                  S5      S   S-   [        -   nUR                  UR                  U R                  SS -   X`R                  S 5        UR                  U R                  :X  d   eUR                  U R                  :X  d   eUR                  U R                  :X  d   e[        5       nUR                   Ul         UR                    Vs/ s H$  nX;  d  M
  UR!                  U5      (       a  M"  UPM&     snU Vs/ s H4  nX;  d  M
  UR!                  U5      (       a  M"  UR#                  XX45      PM6     sn-   UR                   S S & UR$                  R'                  U R$                  5        U$ s  snf s  snf )Nr   r   rO   )r'  r_   r    r   rc   r   r   r   r   splitr   r   r`   r+   ra   r   r,  r   r$   rd   )	r,   r   r\   r   to_bindre   r   uniqr.  s	            r/   r   _UnboundLoad._apply_to_parent5  s   ?= ?mmG!--9999R=D$ 1 122t}}8 8 zz#q)C//A!!dii"o-t]]D **d.G.GGGG''4+A+AAAA""d&7&7777u // 
' (, '
  
 C(, CD!!&5B
	
 	  1

s$   )	H6HH	H'H?Hc                 N   U(       aI  [        U[        R                  5      (       a*  U[        [        4;   a  U[        :X  a  SU l        U< SU< 3nU(       a)  [        US   5      (       a  U R                  (       d  USS nU(       a  X4-   nXl        [        USS5      U l
        U$ )NFr   r   rO   r"   r5   )rc   r   r   r   r   r`   r   r+   r   r   r"   )r,   r   r   r   r   s        r/   r   _UnboundLoad._generate_pathc  s    4!2!233.99~%,1)*D1D$T"X..t7M7M":D'>D	&t->Cr2   c                 ~    U R                   R                  5       nSUS'   U R                  U R                  SS9US'   U$ )Nr5   r"   T)filter_aliased_classr   )r   r   _serialize_pathr   r   s     r/   r  _UnboundLoad.__getstate__u  sC    MM   "
(((N&	r2   c                 6   / nUS    Hz  n[        U[        5      (       aQ  [        U5      S:X  a  Uu  pES nOUu  pEn[        XE5      nU(       a  UR	                  U5      nUR                  U5        Mi  UR                  U5        M|     [        U5      US'   Xl        g )Nr   r   )rc   rV   r   r   of_typerl   r   )r,   r  retrf   r7   propkeyrL  r   s           r/   r  _UnboundLoad.__setstate__~  s    =C#u%%s8q=#&LC"G,/)C's,<<0D

4 

3 ! c
fr2   c                 f   UR                   S   nUR                  R                  nU R                   Hw  nXd;  d  M
  UR	                  U5        U(       a  UR
                  (       d  M5  UR                  U Vs/ s H  owR                  PM     snUR                  UR                   U5        My     g s  snf )N_unbound_load_dedupes)	r   rv   r   r'  r,  r`   _bind_loaderentity_zerorz   )r,   rB   r{   r   dedupesr   valr   s           r/   rx   _UnboundLoad._process  s    **+BC"22EE
==C!C c&>&>  0?@__@!..!,,	 ! As   6B.
c                    [        5       nS nU VVs/ s H  ov" U5        H  oPM     M     n	nnU	SS  H-  nSUl        U(       a  U" XX40 UD6nM  UR                  U5      nM/     U" XYS   40 UD6nSUl        U$ s  snnf )Nc                     [        U [        R                  5      (       aY  U [        :X  a  [        4$ U R                  S[        -   5      (       a  [        R                  " SSS9  U SS  n U R                  S5      $ U 4$ )N.zThe undocumented `.{WILDCARD}` format is deprecated and will be removed in a future version as it is believed to be unused. If you have been using this functionality, please comment on Issue #4390 on the SQLAlchemy project tracker.1.4versionr   )rc   r   r   r   r   
startswithwarn_deprecatedrA  rf   s    r/   
_split_key+_UnboundLoad._from_keys.<locals>._split_key  st    #t0011/)*,,^^C/$9::((# !& ab'Cyy~%vr2   rO   r   TF)r   _is_chain_linkdefaultload)
r7   methkeyschainedkwrW   r`  rf   r   
all_tokenss
             r/   
_from_keys_UnboundLoad._from_keys  s    n	* (,ItCeet
I"%E "&C3,,ooe, & 32-"-"
 Js   A;c                 4   Sn[        [        XR                  5       5      5       H  u  nu  nu  pV[        U[        R
                  5      (       aJ  US:X  a!  UR                  S[        -   5      (       a  Us  $ US[        < 3:w  a  XFR                  :w  a    g Mr  Mt  [        U[        5      (       d  M  UR                  ULdN  UR                  ULd  M  UR                  R                  (       a"  UR                  R                  U5      (       a  M    g    US-  nXS  $ r  )r  r  pairsrc   r   r   r   r   r   rf   r   r   _parententityr   r  )r,   r  r   r  r  p_entityp_props          r/   r   _UnboundLoad._chop_path  s    09&1
,A,+( '4#4#4556g..s^/CDD"NOEE::- . F G^44##61))9#11;;&4488BB  '1
* FAr{r2   c                    / nU GH?  n[        U[        5      (       a  U(       ai  UR                  (       aX  [        UR                  5      R                  (       a4  UR                  UR                  R                  UR                  S 45        M  UR                  UR                  R                  UR                  UR                  (       a  UR                  R                  OS 45        M  [        U[        5      (       a5  UR                  UR                  R                  UR                  S 45        GM.  UR                  U5        GMB     U$ r<   )rc   r   r!   r   r   rl   _parentmapperr   rf   r-   r   )r,   r   rH  rM  r   s        r/   rI  _UnboundLoad._serialize_path  s    E%!344(/@@JJ 3 3 : :EIItLMJJ!//66!II5:^^ENN11 E>22

E//66		4HI

5!' ( 
r2   c           
         U R                   nU R                  (       a  U(       a  XQS   4-  nU(       a  U R                  XR5      nU(       d  gUS   n[        U[        R
                  5      (       a  U R                  XU5      nO[        U[        5      (       a*  UR                  nU R                  XUR                  U5      nOJU R                  (       a#  [        U5      (       a  [        U5      nXq;  a  SnO[        R                  " S5      eU(       d  gUn	[        U	5      n
Uc  U
R                   nU R"                  U
l        U R$                  U
l        U R                  U
l        U R&                  U
l        U
R                   nU
R                  (       dW  [)        U5       HH  u  pU
R+                  U
R                   UU[-        U5      S-
  :X  a  U R"                  OSSUUS9(       a  MH    g   U
R.                  R1                  U R.                  5        U
R                  (       d2  U
R                   R2                  (       a  U
R                   R4                  nOU
R                   nUR6                  (       aD  UR9                  5        H.  nU
R;                  UUU R<                  (       + U R$                  S9  M0     U
$ U
R;                  UUU R<                  (       + U R$                  S9  U
$ )a  Convert from an _UnboundLoad() object into a Load() object.

The _UnboundLoad() uses an informal "path" and does not necessarily
refer to a lead entity as it may use string tokens.   The Load()
OTOH refers to a complete path.   This method reconciles from a
given Query into a Load.

Example::


    query = session.query(User).options(
        joinedload("orders").joinedload("items"))

The above options will be an _UnboundLoad object along the lines
of (note this is not the exact API of _UnboundLoad)::

    _UnboundLoad(
        _to_bind=[
            _UnboundLoad(["orders"], {"lazy": "joined"}),
            _UnboundLoad(["orders", "items"], {"lazy": "joined"}),
        ]
    )

After this method, we get something more like this (again this is
not exact API)::

    Load(
        User,
        (User, User.orders.property))
    Load(
        User,
        (User, User.orders.property, Order, Order.items.property))

rO   Nz6mapper option expects string key or list of attributesr   )r   r   )r   r+   r   rc   r   r   _find_entity_basestringr   r   _find_entity_prop_comparatorrm  r   r   r   r   r   r*   r    ra   r"   r  r   r   r$   rd   r   r   r   r   r   rb  )r,   entitiesrz   r*   r   r   r   r-   r   path_elementrk   r   idxr   s                 r/   rR  _UnboundLoad._bind_loader  s~   H YY
!!lA;.(J
 BJ 1eT..//11(8LF~..>>D66 3 3XF ##(8(?(?U^F%&&K   l#?nnG--"//#'#9#9 !%!5!5{{'''
3
,,KK%(C
Oa,?%?DMMT/6 -    4 	  1''FKK,B,B#[[//N#[[N ""&@@B$$ $ 3 33#00	 %  C     ///,,	 !  r2   c           	         [        U5      (       a  UnO[        U5      nU H"  n[        R                  " Xe5      (       d  M   Us  $    U(       a  [	        U5      (       d<  [
        R                  " S[        R                  " [        U5      5      < SU< S35      e[
        R                  " SU< SSR                  S U 5       5      < S35      eg )	Nz@Query has only expression-based entities, which do not apply to z ""zMapped attribute "zA" does not apply to any of the root entities in this query, e.g. , c              3   8   #    U  H  n[        U5      v   M     g 7fr<   str)rQ   xs     r/   rS   <_UnboundLoad._find_entity_prop_comparator.<locals>.<genexpr>  s     *D8a3q668   zV. Please specify the full path from one of the root entities to the target attribute. )r   r   r   _entity_corresponds_tolistr   r   r   clsname_as_plain_namer   join)r,   rw  r   r   r   	searchforr   s          r/   rv  )_UnboundLoad._find_entity_prop_comparator  s    V$$I(0IC..s>>
  H~~ ..  55d4jA4I  !..  *D8*D!DF  r2   c           	         UR                  S[        -   5      (       ak  [        [        U5      5      S:w  aR  U(       aK  [        R
                  " SSR                  S U 5       5      < SSR                  S U 5       5      < S35      eOUR                  [        5      (       a  S	nU H  nUs  $    U(       a  [        R
                  " S
U< S35      eg )Nr   r   zMCan't apply wildcard ('*') or load_only() loader option to multiple entities r}  c              3   8   #    U  H  n[        U5      v   M     g 7fr<   r  rQ   r   s     r/   rS   7_UnboundLoad._find_entity_basestring.<locals>.<genexpr>  s     %C(3c#hh(r  z?. Specify loader options for each entity individually, such as c              3   ,   #    U  H
  nS U-  v   M     g7f)zLoad(%s).some_option('*')Nr5   r  s     r/   rS   r    s      &+3C !<c A+3s   rY  FzFQuery has only expression-based entities - can't find property named "r   )r   r   r   r  r   r   r  r   )r,   rw  r   r   r   s        r/   ru  $_UnboundLoad._find_entity_basestring  s    >>#/004>"a' .. !II%C(%CC II &+3& 
  ^^N++HC J	  **:?B 
 r2   )r   r"   r'  r$   r   r`   r<   F)r   r  r  r  r  r0   r-  rb  r   r[   r   r   r  r  rx   r"  ri  r   rI  rR  rv  ru  r#  r5   r2   r/   r   r     sn    "Q
f N0,\$& % %N60BH8 r2   r   c                   ,    \ rS rSrS rS rS rS rSrg)loader_optioni  c                     g r<   r5   r   s    r/   r0   loader_option.__init__  s    r2   c                     UR                   =U l        nXl        [        [        U5      (       a  [        SU-  5      e[        [        X!5        U $ )Nz#Load class already has a %s method.)r   namefnhasattrr   	TypeErrorsetattr)r,   r  r  s      r/   __call__loader_option.__call__  sD    ;;&	D4ATJKKdr2   c                     Xl         U R                  R                  nSSU R                  0-  U R                  l        X!l        U $ )NzProduce a new :class:`_orm.Load` object with the
:func:`_orm.%(name)s` option applied.

See :func:`_orm.%(name)s` for usage examples.

r  )_unbound_fnr  r  r  )r,   r  fn_docs      r/   _add_unbound_fnloader_option._add_unbound_fn  sC     DII

 
r2   c                     SSU R                   0-  Ul        [        R                  " SSSU R                   0-  SS9" U5      nXl        U $ )Na}  Produce a standalone "all" option for
:func:`_orm.%(name)s`.

.. deprecated:: 0.9

    The :func:`_orm.%(name)s_all` function is deprecated, and will be removed
    in a future release.  Please use method chaining with
    :func:`_orm.%(name)s` instead, as in::

        session.query(MyClass).options(
            %(name)s("someattribute").%(name)s("anotherattribute")
        )

r  z0.9zThe :func:`.%(name)s_all` function is deprecated, and will be removed in a future release.  Please use method chaining with :func:`.%(name)s` insteadF)add_deprecation_to_docstring)r  r  r   
deprecated_unbound_all_fn)r,   r  s     r/   _add_unbound_all_fn!loader_option._add_unbound_all_fn  sg     DII


  __ (+1499*=> */
   "r2   )r  r  r  r  N)	r   r  r  r  r0   r  r  r  r#  r5   r2   r/   r  r    s    r2   r  Nc                 :   UbC  [        U[        5      (       d  [        U5      nUR                  nOI[        R
                  " SSS9  O3[        USS5      (       a!  [        UR                  5      nUR                  nU R                  USS0SS	9nX%R                  S
'   U$ )a  Indicate that the given attribute should be eagerly loaded from
columns stated manually in the query.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

The option is used in conjunction with an explicit join that loads
the desired rows, i.e.::

    sess.query(Order).\
            join(Order.user).\
            options(contains_eager(Order.user))

The above query would join from the ``Order`` entity to its related
``User`` entity, and the returned ``Order`` objects would have the
``Order.user`` attribute pre-populated.

It may also be used for customizing the entries in an eagerly loaded
collection; queries will normally want to use the
:meth:`_query.Query.populate_existing` method assuming the primary
collection of parent objects may already have been loaded::

    sess.query(User).\
        join(User.addresses).\
        filter(Address.email_address.like('%@aol.com')).\
        options(contains_eager(User.addresses)).\
        populate_existing()

See the section :ref:`contains_eager` for complete usage details.

.. seealso::

    :ref:`loading_toplevel`

    :ref:`contains_eager`

NzPassing a string name for the 'alias' argument to 'contains_eager()` is deprecated, and will not work in a future release.  Please use a sqlalchemy.alias() or sqlalchemy.orm.aliased() construct.rZ  r[  r!   lazyjoinedF)r`   eager_from_alias)
rc   r  r   
selectabler   r^  r   r!   r   r$   )loadoptr   aliasinfootre   s         r/   contains_eagerr    s    N %%%5>DOOE   6  
z4	(	(T]]#..vx u / F -2()Mr2   c                  V    [        5       R                  [         R                  U SU5      $ r   )r   ri  r  re  rg  s     r/   r  r  9  s&    >$$##T4 r2   c                 `    U R                  USSS.5      nUR                  SSSS.SS05        U$ )a  Indicate that for a particular entity, only the given list
of column-based attribute names should be loaded; all others will be
deferred.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

Example - given a class ``User``, load only the ``name`` and ``fullname``
attributes::

    session.query(User).options(load_only(User.name, User.fullname))

Example - given a relationship ``User.addresses -> Address``, specify
subquery loading for the ``User.addresses`` collection, but on each
``Address`` object load only the ``email_address`` attribute::

    session.query(User).options(
            subqueryload(User.addresses).load_only(Address.email_address)
    )

For a :class:`_query.Query` that has multiple entities,
the lead entity can be
specifically referred to using the :class:`_orm.Load` constructor::

    session.query(User, Address).join(User.addresses).options(
                Load(User).load_only(User.name, User.fullname),
                Load(Address).load_only(Address.email_address)
            )

 .. note:: This method will still load a :class:`_schema.Column` even
    if the column property is defined with ``deferred=True``
    for the :func:`.column_property` function.

.. versionadded:: 0.9.0

FTdeferred
instrument*undefer_pksr   )r  r   re   s      r/   	load_onlyr  @  sG    L ((E6F $d3mT5J Mr2   c                  0    [        5       R                  " U 6 $ r<   )r   r  )r   s    r/   r  r  o  s    >##U++r2   c                 P    U R                  USS05      nUb  X#R                  S'   U$ )aC  Indicate that the given attribute should be loaded using joined
eager loading.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

examples::

    # joined-load the "orders" collection on "User"
    query(User).options(joinedload(User.orders))

    # joined-load Order.items and then Item.keywords
    query(Order).options(
        joinedload(Order.items).joinedload(Item.keywords))

    # lazily load Order.items, but when Items are loaded,
    # joined-load the keywords collection
    query(Order).options(
        lazyload(Order.items).joinedload(Item.keywords))

:param innerjoin: if ``True``, indicates that the joined eager load should
 use an inner join instead of the default of left outer join::

    query(Order).options(joinedload(Order.user, innerjoin=True))

 In order to chain multiple eager joins together where some may be
 OUTER and others INNER, right-nested joins are used to link them::

    query(A).options(
        joinedload(A.bs, innerjoin=False).
            joinedload(B.cs, innerjoin=True)
    )

 The above query, linking A.bs via "outer" join and B.cs via "inner" join
 would render the joins as "a LEFT OUTER JOIN (b JOIN c)".   When using
 older versions of SQLite (< 3.7.16), this form of JOIN is translated to
 use full subqueries as this syntax is otherwise not directly supported.

 The ``innerjoin`` flag can also be stated with the term ``"unnested"``.
 This indicates that an INNER JOIN should be used, *unless* the join
 is linked to a LEFT OUTER JOIN to the left, in which case it
 will render as LEFT OUTER JOIN.  For example, supposing ``A.bs``
 is an outerjoin::

    query(A).options(
        joinedload(A.bs).
            joinedload(B.cs, innerjoin="unnested")
    )

 The above join will render as "a LEFT OUTER JOIN b LEFT OUTER JOIN c",
 rather than as "a LEFT OUTER JOIN (b JOIN c)".

 .. note:: The "unnested" flag does **not** affect the JOIN rendered
    from a many-to-many association table, e.g. a table configured
    as :paramref:`_orm.relationship.secondary`, to the target table; for
    correctness of results, these joins are always INNER and are
    therefore right-nested if linked to an OUTER join.

 .. versionchanged:: 1.0.0 ``innerjoin=True`` now implies
    ``innerjoin="nested"``, whereas in 0.9 it implied
    ``innerjoin="unnested"``.  In order to achieve the pre-1.0 "unnested"
    inner join behavior, use the value ``innerjoin="unnested"``.
    See :ref:`migration_3008`.

.. note::

    The joins produced by :func:`_orm.joinedload` are **anonymously
    aliased**.  The criteria by which the join proceeds cannot be
    modified, nor can the :class:`_query.Query`
    refer to these joins in any way,
    including ordering.  See :ref:`zen_of_eager_loading` for further
    detail.

    To produce a specific SQL JOIN which is explicitly available, use
    :meth:`_query.Query.join`.
    To combine explicit JOINs with eager loading
    of collections, use :func:`_orm.contains_eager`; see
    :ref:`contains_eager`.

.. seealso::

    :ref:`loading_toplevel`

    :ref:`joined_eager_loading`

r  r  	innerjoin)r   r$   )r  r   r  rk   s       r/   
joinedloadr  t  s5    p ..tfh5GHF)2+&Mr2   c                  N    [         R                  [         R                  U SU5      $ r&   )r   ri  r  r  s     r/   r  r    s    ""<#:#:D%LLr2   c                 *    U R                  USS05      $ )a  Indicate that the given attribute should be loaded using
subquery eager loading.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

examples::

    # subquery-load the "orders" collection on "User"
    query(User).options(subqueryload(User.orders))

    # subquery-load Order.items and then Item.keywords
    query(Order).options(
        subqueryload(Order.items).subqueryload(Item.keywords))

    # lazily load Order.items, but when Items are loaded,
    # subquery-load the keywords collection
    query(Order).options(
        lazyload(Order.items).subqueryload(Item.keywords))


.. seealso::

    :ref:`loading_toplevel`

    :ref:`subquery_eager_loading`

r  subqueryr   r  r   s     r/   subqueryloadr    s    < ,,TFJ3GHHr2   c                  N    [         R                  [         R                  U S0 5      $ r&   )r   ri  r  re  s    r/   r  r        ""<#<#<dE2NNr2   c                 *    U R                  USS05      $ )a  Indicate that the given attribute should be loaded using
SELECT IN eager loading.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

examples::

    # selectin-load the "orders" collection on "User"
    query(User).options(selectinload(User.orders))

    # selectin-load Order.items and then Item.keywords
    query(Order).options(
        selectinload(Order.items).selectinload(Item.keywords))

    # lazily load Order.items, but when Items are loaded,
    # selectin-load the keywords collection
    query(Order).options(
        lazyload(Order.items).selectinload(Item.keywords))

.. versionadded:: 1.2

.. seealso::

    :ref:`loading_toplevel`

    :ref:`selectin_eager_loading`

r  selectinr  r  s     r/   selectinloadr    s    > ,,TFJ3GHHr2   c                  N    [         R                  [         R                  U S0 5      $ r&   )r   ri  r  r  s    r/   r  r    r  r2   c                 *    U R                  USS05      $ )a  Indicate that the given attribute should be loaded using "lazy"
loading.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

.. seealso::

    :ref:`loading_toplevel`

    :ref:`lazy_loading`

r  selectr  r  s     r/   lazyloadr  $  s     ,,TFH3EFFr2   c                  N    [         R                  [         R                  U S0 5      $ r&   )r   ri  r  r  s    r/   r  r  6  s    ""<#8#8$rJJr2   c                 .    U R                  USS05      nU$ )a]  Indicate that the given attribute should be loaded using
an immediate load with a per-attribute SELECT statement.

The load is achieved using the "lazyloader" strategy and does not
fire off any additional eager loaders.

The :func:`.immediateload` option is superseded in general
by the :func:`.selectinload` option, which performs the same task
more efficiently by emitting a SELECT for all loaded objects.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

.. seealso::

    :ref:`loading_toplevel`

    :ref:`selectin_eager_loading`

r  	immediater  )r  r   rk   s      r/   immediateloadr  ;  s     , ..tfk5JKFMr2   c                  N    [         R                  [         R                  U S0 5      $ r&   )r   ri  r  r  s    r/   r  r  U  s    ""<#=#=tUBOOr2   c                 *    U R                  USS05      $ )a  Indicate that the given relationship attribute should remain unloaded.

The relationship attribute will return ``None`` when accessed without
producing any loading effect.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

:func:`_orm.noload` applies to :func:`_orm.relationship` attributes; for
column-based attributes, see :func:`_orm.defer`.

.. note:: Setting this loading strategy as the default strategy
    for a relationship using the :paramref:`.orm.relationship.lazy`
    parameter may cause issues with flushes, such if a delete operation
    needs to load related objects and instead ``None`` was returned.

.. seealso::

    :ref:`loading_toplevel`

r  noloadr  r  s     r/   r  r  Z  s    0 ,,TFH3EFFr2   c                  N    [         R                  [         R                  U S0 5      $ r&   )r   ri  r  r  s    r/   r  r  u  s    ""<#6#6eRHHr2   c                 F    U R                  USU(       a  S05      $ S05      $ )a&  Indicate that the given attribute should raise an error if accessed.

A relationship attribute configured with :func:`_orm.raiseload` will
raise an :exc:`~sqlalchemy.exc.InvalidRequestError` upon access.   The
typical way this is useful is when an application is attempting to ensure
that all relationship attributes that are accessed in a particular context
would have been already loaded via eager loading.  Instead of having
to read through SQL logs to ensure lazy loads aren't occurring, this
strategy will cause them to raise immediately.

:func:`_orm.raiseload` applies to :func:`_orm.relationship`
attributes only.
In order to apply raise-on-SQL behavior to a column-based attribute,
use the :paramref:`.orm.defer.raiseload` parameter on the :func:`.defer`
loader option.

:param sql_only: if True, raise only if the lazy load would emit SQL, but
 not if it is only checking the identity map, or determining that the
 related value should just be None due to missing keys.  When False, the
 strategy will raise for all varieties of relationship loading.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.


.. versionadded:: 1.1

.. seealso::

    :ref:`loading_toplevel`

    :ref:`prevent_lazy_with_raiseload`

    :ref:`deferred_raiseload`

r  raise_on_sqlraiser  )r  r   sql_onlys      r/   	raiseloadr  z  s4    N ,,v~? 7>? r2   c                  N    [         R                  [         R                  U SU5      $ r&   )r   ri  r  r  s     r/   r  r    s    ""<#9#94KKr2   c                 &    U R                  US5      $ )a  Indicate an attribute should load using its default loader style.

This method is used to link to other loader options further into
a chain of attributes without altering the loader style of the links
along the chain.  For example, to set joined eager loading for an
element of an element::

    session.query(MyClass).options(
        defaultload(MyClass.someattribute).
        joinedload(MyOtherClass.someotherattribute)
    )

:func:`.defaultload` is also useful for setting column-level options
on a related class, namely that of :func:`.defer` and :func:`.undefer`::

    session.query(MyClass).options(
        defaultload(MyClass.someattribute).
        defer("some_column").
        undefer("some_other_column")
    )

.. seealso::

    :meth:`_orm.Load.options` - allows for complex hierarchical
    loader option structures with less verbosity than with individual
    :func:`.defaultload` directives.

    :ref:`relationship_loader_options`

    :ref:`deferred_loading_w_multiple`

Nr  r  s     r/   rc  rc    s    D ,,T488r2   c                  N    [         R                  [         R                  U S0 5      $ r&   )r   ri  rc  r  s    r/   rc  rc    s    ""<#;#;T5"MMr2   c                 J    SSS.nU(       a  SUS'   U R                  U4U5      $ )a  Indicate that the given column-oriented attribute should be deferred,
e.g. not loaded until accessed.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

e.g.::

    from sqlalchemy.orm import defer

    session.query(MyClass).options(
                        defer("attribute_one"),
                        defer("attribute_two"))

    session.query(MyClass).options(
                        defer(MyClass.attribute_one),
                        defer(MyClass.attribute_two))

To specify a deferred load of an attribute on a related class,
the path can be specified one token at a time, specifying the loading
style for each link along the chain.  To leave the loading style
for a link unchanged, use :func:`_orm.defaultload`::

    session.query(MyClass).options(defaultload("someattr").defer("some_column"))

A :class:`_orm.Load` object that is present on a certain path can have
:meth:`_orm.Load.defer` called multiple times,
each will operate on the same
parent entity::


    session.query(MyClass).options(
                    defaultload("someattr").
                        defer("some_column").
                        defer("some_other_column").
                        defer("another_column")
        )

:param key: Attribute to be deferred.

:param raiseload: raise :class:`.InvalidRequestError` if the column
 value is to be loaded from emitting SQL.   Used to prevent unwanted
 SQL from being emitted.

 .. versionadded:: 1.4

 .. seealso::

    :ref:`deferred_raiseload`

:param \*addl_attrs: This option supports the old 0.8 style
 of specifying a path as a series of attributes, which is now superseded
 by the method-chained style.

    .. deprecated:: 0.9  The \*addl_attrs on :func:`_orm.defer` is
       deprecated and will be removed in a future release.   Please
       use method chaining in conjunction with defaultload() to
       indicate a path.


.. seealso::

    :ref:`deferred`

    :func:`_orm.undefer`

Tr  r  r  )r  rf   r  r    s       r/   deferr    s1    J !5H $&&vx88r2   c                     U(       a  [         R                  " SSS9  [        R                  [        R                  U 4U-   SU5      $ )Nz}The *addl_attrs on orm.defer is deprecated.  Please use method chaining in conjunction with defaultload() to indicate a path.1.3r[  F)r   r^  r   ri  r  )rf   
addl_attrsrg  s      r/   r  r     sH     		
 ""SFZ/ r2   c                 .    U R                  U4SSS.5      $ )a  Indicate that the given column-oriented attribute should be undeferred,
e.g. specified within the SELECT statement of the entity as a whole.

The column being undeferred is typically set up on the mapping as a
:func:`.deferred` attribute.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

Examples::

    # undefer two columns
    session.query(MyClass).options(undefer("col1"), undefer("col2"))

    # undefer all columns specific to a single class using Load + *
    session.query(MyClass, MyOtherClass).options(
        Load(MyClass).undefer("*"))

    # undefer a column on a related object
    session.query(MyClass).options(
        defaultload(MyClass.items).undefer('text'))

:param key: Attribute to be undeferred.

:param \*addl_attrs: This option supports the old 0.8 style
 of specifying a path as a series of attributes, which is now superseded
 by the method-chained style.

    .. deprecated:: 0.9  The \*addl_attrs on :func:`_orm.undefer` is
       deprecated and will be removed in a future release.   Please
       use method chaining in conjunction with defaultload() to
       indicate a path.

.. seealso::

    :ref:`deferred`

    :func:`_orm.defer`

    :func:`_orm.undefer_group`

FTr  r  )r  rf   s     r/   undeferr  .  s$    X &&	U$7 r2   c                     U(       a  [         R                  " SSS9  [        R                  [        R                  U 4U-   S0 5      $ )NzThe *addl_attrs on orm.undefer is deprecated.  Please use method chaining in conjunction with defaultload() to indicate a path.r  r[  F)r   r^  r   ri  r  )rf   r  s     r/   r  r  _  sH     		
 ""sfz15" r2   c                 0    U R                  SSSU-  S0SS9$ )a  Indicate that columns within the given deferred group name should be
undeferred.

The columns being undeferred are set up on the mapping as
:func:`.deferred` attributes and include a "group" name.

E.g::

    session.query(MyClass).options(undefer_group("large_attrs"))

To undefer a group of attributes on a related entity, the path can be
spelled out using relationship loader options, such as
:func:`_orm.defaultload`::

    session.query(MyClass).options(
        defaultload("someattr").undefer_group("large_attrs"))

.. versionchanged:: 0.9.0 :func:`_orm.undefer_group` is now specific to a
   particular entity load path.

.. seealso::

    :ref:`deferred`

    :func:`_orm.defer`

    :func:`_orm.undefer`

r  Nzundefer_group_%sT)r   r  )r  r  s     r/   undefer_groupr  m  s0    > &&T&-t4 '  r2   c                 4    [        5       R                  U 5      $ r<   )r   r  )r  s    r/   r  r    s    >''--r2   c                     [         R                  " [        R                  [	        U5      5      nU R                  U4SS0SU0S9$ )a  Apply an ad-hoc SQL expression to a "deferred expression" attribute.

This option is used in conjunction with the :func:`_orm.query_expression`
mapper-level construct that indicates an attribute which should be the
target of an ad-hoc SQL expression.

E.g.::


    sess.query(SomeClass).options(
        with_expression(SomeClass.x_y_expr, SomeClass.x + SomeClass.y)
    )

.. versionadded:: 1.2

:param key: Attribute to be populated.

:param expr: SQL expression to be applied to the attribute.

.. versionchanged:: 1.4  Loader options such as
   :func:`_orm.with_expression`
   take effect only at the **outermost** query used, and should not be used
   within subqueries or inner elements of a UNION. See the change notes at
   :ref:`change_8879` for background on how to correctly add arbitrary
   columns to subqueries.

.. note:: the target attribute is populated only if the target object
   is **not currently loaded** in the current :class:`_orm.Session`
   unless the :meth:`_query.Query.populate_existing` method is used.
   Please refer to :ref:`mapper_querytime_expression` for complete
   usage details.

.. seealso::

    :ref:`mapper_querytime_expression`

query_expressionT
expressionr   )r   expectr   LabeledColumnExprRoler   r   )r  rf   r  s      r/   with_expressionr    sT    P !!##%9*%EJ &&	#T*,
1K '  r2   c                 T    [         R                  [         R                  U 4SSU05      $ )NFr  )r   ri  r  )rf   r  s     r/   r  r    s+    ""$$sfelJ5O r2   c                 f    U R                  SS0S[        [        S U 5       [        S95      0S9  U $ )a^  Indicate an eager load should take place for all attributes
specific to a subclass.

This uses an additional SELECT with IN against all matched primary
key values, and is the per-query analogue to the ``"selectin"``
setting on the :paramref:`.mapper.polymorphic_load` parameter.

.. versionadded:: 1.2

.. seealso::

    :ref:`polymorphic_selectin`

selectinload_polymorphicTrw  c              3   8   #    U  H  n[        U5      v   M     g 7fr<   r   )rQ   r7   s     r/   rS   'selectin_polymorphic.<locals>.<genexpr>  s     8r  r_  r  )r   rV   r   r4  )r  classess     r/   selectin_polymorphicr    sE      	#T*88bA
   Nr2   c                 l    [        5       nSUl        [        U 5      4Ul        UR	                  U5        U$ r   )r   r+   r   r   r  )base_clsr  uls      r/   r  r    s3    	BBx "BGG$Ir2   r<   r  )5r  r   r   r   r   r   baser   r   r   r   
interfacesr	   r
   r   path_registryr   r   r   r   r   r   r   r   sqlr   r   r   r   r   sql.baser   r   r   r   objectr  r  r  r  r  r  r  r  r  r  r  rc  r  r  r  r  r  r5   r2   r/   <module>r     sx    * " # "   $ & & ) * ' ( &         " !G
 :| G
 TK4 K\8F 8v < <~    + +\ , , Z Zz M M I I@ O O I IB O O G G" 
K K  2 P P G G4 I I ( (V L L !9 !9H N N G9 G9T 
 
 - -` 	
 
    F . . - -`    !  4 %% &r2   