zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
U
¸ý°d¶Hã@s,UdZddlmZddlZddlmZddlmZddlmZddlmZddlmZdd    lm    Z    dd
lm
Z
dd lm Z dd lm Z dd lm Z ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%dd lm&Z&d!d"lm'Z(d!d#lm)Z)d!dlmZd!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*m0Z0d!d*l1m2Z2d!d+l3m4Z4d!d,l3m5Z5d!d-l3m6Z6d.Z7d/e8d0<d1Z9d2e8d3<ed4d5d6Z:ej;rÚdd7lm<Z<dd8lm=Z=dd9l>m?Z?dd:l>m@Z@dd;l>mAZAdd<lmBZBdd=lmCZCdd>lmDZDdd?lEmFZFdd@lmGZGd!dAlHmIZId!dBlHmJZJd!dClKmLZLd!dDlKmMZMeeNdEfZOe5dFZPeeNefZQeeNefZRe eOdGfZSGdHdI„dIe/jTeƒZUGdJdK„dKeUƒZVGdLdM„dMeUƒZWGdNdO„dOe,jXe/jYe0jZƒZ[GdPdQ„dQe[ƒZ\GdRdS„dSe[ƒZ]GdTdU„dUe[ƒZ^dVdWdXdYdIdZœd[d\„Z_d]d^d_œd`da„Z`d4d4dbœdcdd„Zaead]dYdIdeœdfdg„ƒZbeadhdiœd]dXdIdjœdkdl„ƒZcead]dYdIdeœdmdn„ƒZdead]dIdoœdpdq„ƒZeeaddrœd]dsdIdtœdudv„ƒZfead]dIdoœdwdx„ƒZgeaddrœd]dsdIdtœdydz„ƒZhead]dIdoœd{d|„ƒZiead]dYdIdeœd}d~„ƒZjead]dIdoœdd€„ƒZkeadhdiœd]d]dXdIdœd‚dƒ„ƒZlead]d]dId„œd…d†„ƒZmead‡dIdˆœd‰dŠ„ƒZnead]d‹dIdŒœddŽ„ƒZoeadddId‘œd’d“„ƒZpd”d•„ZqdS)–z
 
é)Ú annotationsN)ÚAny)ÚCallable)Úcast)ÚDict)ÚIterable)ÚOptional)Úoverload)ÚSequence)ÚTuple)ÚType)ÚTypeVar)ÚUnioné)Úutil)Úinsp_is_aliased_class)Úinsp_is_attribute)Úinsp_is_mapper)Úinsp_is_mapper_property)ÚQueryableAttribute)ÚInspectionAttr)Ú LoaderOption)Ú_DEFAULT_TOKEN)Ú_WILDCARD_TOKEN)ÚAbstractEntityRegistry)Úpath_is_property)Ú PathRegistry)Ú TokenRegistry)Ú_orm_full_deannotate)Ú AliasedInspé)Úexc©Úinspect)Úand_)Ú    cache_key)Ú    coercions)Úroles)Ú
traversals)Úvisitors)Ú _generative)ÚFinal)ÚLiteral)ÚSelfÚ relationshipzFinal[Literal['relationship']]Ú_RELATIONSHIP_TOKENÚcolumnzFinal[Literal['column']]Ú _COLUMN_TOKENÚ_FNzCallable[..., Any])Úbound)Ú _EntityType)Ú_InternalEntityType)Ú _MapperEntity)ÚORMCompileState)Ú QueryContext)Ú _StrategyKey)ÚMapperProperty)Ú    ORMOption)ÚMapper)Ú_PathRepresentation)Ú_ColumnExpressionArgument)Ú_FromClauseArgument)Ú_CacheKeyTraversalType)ÚCacheKeyzQueryableAttribute[Any])r.r0.c
@s`eZdZUdZdZded<dqdddd    d
œd d „Zdd œddd    dœdd„Zdrddd    dœdd„Zdd    dœdd„Z    dsddd    dœdd„Z
dd    dœdd„Z dtddd    dœdd„Z dd    dœd d!„Z duddd    d"œd#d$„Zdd    dœd%d&„Zdvddd    d'œd(d)„Zdd    d*œd+d,„Zd-d    d.œd/d0„Zdd1d    d2œd3d4„Zd5d    d6œd7d8„Zed9d:d;œd<d=„ƒZed>d?d;œd@d=„ƒZdAdBd;œdCd=„ZedwddAddDdd    dEœdFdG„ƒZedxdHdAdDd    dIœdJdK„ƒZedydHd9dd    dLœdMdN„ƒZed9dOd    dPœdQdR„ƒZdSd?dTœdUdV„Zdd    dWœdXdY„ZdzdZdBd[dDd\ddd    d]œd^d_„Zd`dad?dbœdcdd„Zd`d?deœdfdg„Z d`dadd?dhœdidj„Z!e"d{dkdlddmdnœdodp„ƒZ#dS)|Ú _AbstractLoad)Úpropagate_to_loadersTÚboolrCNFÚ    _AttrTypezOptional[_FromClauseArgument]r-)ÚattrÚaliasÚ    _is_chainÚreturncCsš|dk    r6t|tƒs"t tj|¡}qrtjddd|}n<t|ddƒrnt|t    ƒsPt
‚t |j ƒ}|dk    sft
‚|j }nd}|j|ddidd    |i|rŽd
ndd }|S) adIndicate 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
        :ref:`orm_queryguide_populate_existing` execution option 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`
 
        NzÂPassing 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.ú1.4©ÚversionÚ_of_typeÚlazyÚjoinedFZeager_from_aliasT)rCÚoptsÚ_reconcile_to_other)Ú
isinstanceÚstrr&Úexpectr'ZFromClauseRolerÚwarn_deprecatedÚgetattrrÚAssertionErrorr#rMZ
selectableÚ_set_relationship_strategy)ÚselfrFrGrHZ coerced_aliasZotÚcloned©r[úVd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/orm/strategy_options.pyÚcontains_eager^s,+
û 
 
ûz_AbstractLoad.contains_eager©Ú    raiseload©Úattrsr_rIcGs8| |dddœ¡}dddœ}|r(d|d<| d|¡}|S)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 statement that has multiple entities,
        the lead entity can be
        specifically referred to using the :class:`_orm.Load` constructor::
 
            stmt = select(User, Address).join(User.addresses).options(
                        Load(User).load_only(User.name, User.fullname),
                        Load(Address).load_only(Address.email_address)
                    )
 
        :param \*attrs: Attributes to be loaded, all others will be deferred.
 
        :param raiseload: raise :class:`.InvalidRequestError` rather than
         lazy loading a value when a deferred attribute is accessed. Used
         to prevent unwanted SQL from being emitted.
 
         .. versionadded:: 2.0
 
        .. seealso::
 
            :ref:`orm_queryguide_column_deferral` - in the
            :ref:`queryguide_toplevel`
 
        :param \*attrs: Attributes to be loaded, all others will be deferred.
 
        :param raiseload: raise :class:`.InvalidRequestError` rather than
         lazy loading a value when a deferred attribute is accessed. Used
         to prevent unwanted SQL from being emitted.
 
         .. versionadded:: 2.0
 
        FT©ÚdeferredZ
instrumentr_)Ú*©Ú_set_column_strategy)rYr_rarZZwildcard_strategyr[r[r\Ú    load_only§s4þ
þz_AbstractLoad.load_onlyúOptional[bool])rFÚ    innerjoinrIcCs*|j|ddi|dk    rd|intjd}|S)a 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.
 
        .. note::
 
            The joins produced by :func:`_orm.joinedload` are **anonymously
            aliased**. The criteria by which the join proceeds cannot be
            modified, nor can the ORM-enabled :class:`_sql.Select` or legacy
            :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:`_sql.Select.join` and :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`
 
        rNrONri©rP)rXrÚ
EMPTY_DICT)rYrFriÚloaderr[r[r\Ú
joinedloadêsTÿ
ûz_AbstractLoad.joinedload©rFrIcCs| |ddi¡S)abIndicate 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`
 
        rNZsubquery©rX©rYrFr[r[r\Ú subqueryloadGsz_AbstractLoad.subqueryloadú Optional[int])rFÚrecursion_depthrIcCs|j|ddid|idS)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))
 
        :param recursion_depth: optional int; when set to a positive integer
         in conjunction with a self-referential relationship,
         indicates "selectin" loading will continue that many levels deep
         automatically until no items are found.
 
         .. note:: The :paramref:`_orm.selectinload.recursion_depth` option
            currently supports only self-referential relationships.  There
            is not yet an option to automatically traverse recursive structures
            with more than one relationship involved.
 
            Additionally, the :paramref:`_orm.selectinload.recursion_depth`
            parameter is new and experimental and should be treated as "alpha"
            status for the 2.0 series.
 
         .. versionadded:: 2.0 added
            :paramref:`_orm.selectinload.recursion_depth`
 
 
        .. seealso::
 
            :ref:`loading_toplevel`
 
            :ref:`selectin_eager_loading`
 
        rNZselectinrsrjro)rYrFrsr[r[r\Ú selectinloadfs
2ýz_AbstractLoad.selectinloadcCs| |ddi¡S)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`
 
        rNÚselectrorpr[r[r\Úlazyloadžsz_AbstractLoad.lazyloadcCs|j|ddid|id}|S)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.
 
        :param recursion_depth: optional int; when set to a positive integer
         in conjunction with a self-referential relationship,
         indicates "selectin" loading will continue that many levels deep
         automatically until no items are found.
 
         .. note:: The :paramref:`_orm.immediateload.recursion_depth` option
            currently supports only self-referential relationships.  There
            is not yet an option to automatically traverse recursive structures
            with more than one relationship involved.
 
         .. warning:: This parameter is new and experimental and should be
            treated as "alpha" status
 
         .. versionadded:: 2.0 added
            :paramref:`_orm.immediateload.recursion_depth`
 
 
        .. seealso::
 
            :ref:`loading_toplevel`
 
            :ref:`selectin_eager_loading`
 
        rNZ    immediatersrjro)rYrFrsrlr[r[r\Ú immediateload®s *ýz_AbstractLoad.immediateloadcCs| |ddi¡S)aIndicate 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
        only.
 
        .. 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`
 
        rNÚnoloadrorpr[r[r\rxßsz_AbstractLoad.noload)rFÚsql_onlyrIcCs| |d|rdndi¡S)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.
 
        .. seealso::
 
            :ref:`loading_toplevel`
 
            :ref:`prevent_lazy_with_raiseload`
 
            :ref:`orm_queryguide_deferred_raiseload`
 
        rNZ raise_on_sqlÚraisero)rYrFryr[r[r\r_ùs"ÿz_AbstractLoad.raiseloadcCs | |d¡S)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::
 
            :ref:`orm_queryguide_relationship_sub_options`
 
            :meth:`_orm.Load.options`
 
        Nrorpr[r[r\Ú defaultloadsz_AbstractLoad.defaultload)Úkeyr_rIcCs$dddœ}|rd|d<| |f|¡S)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(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(MyClass.someattr).defer(RelatedClass.some_column)
            )
 
        Multiple deferral options related to a relationship can be bundled
        at once using :meth:`_orm.Load.options`::
 
 
            session.query(MyClass).options(
                defaultload(MyClass.someattr).options(
                    defer(RelatedClass.some_column),
                    defer(RelatedClass.some_other_column),
                    defer(RelatedClass.another_column)
                )
            )
 
        :param key: Attribute to be deferred.
 
        :param raiseload: raise :class:`.InvalidRequestError` rather than
         lazy loading a value when the deferred attribute is accessed. Used
         to prevent unwanted SQL from being emitted.
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :ref:`orm_queryguide_column_deferral` - in the
            :ref:`queryguide_toplevel`
 
            :func:`_orm.load_only`
 
            :func:`_orm.undefer`
 
        Trbr_re)rYr|r_Ústrategyr[r[r\Údefer>s7
z_AbstractLoad.defer)r|rIcCs| |fdddœ¡S)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(MyClass.col1), undefer(MyClass.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(MyClass.text))
 
        :param key: Attribute to be undeferred.
 
        .. seealso::
 
            :ref:`orm_queryguide_column_deferral` - in the
            :ref:`queryguide_toplevel`
 
            :func:`_orm.defer`
 
            :func:`_orm.undefer_group`
 
        FTrbre)rYr|r[r[r\Úundeferzs&ÿz_AbstractLoad.undeferrS©ÚnamerIcCs| tfdd|›di¡S)aIndicate 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"))
 
        .. seealso::
 
            :ref:`orm_queryguide_column_deferral` - in the
            :ref:`queryguide_toplevel`
 
            :func:`_orm.defer`
 
            :func:`_orm.undefer`
 
        NZundefer_group_T)rfr)rYrr[r[r\Ú undefer_group¤s
 ÿz_AbstractLoad.undefer_groupú_ColumnExpressionArgument[Any]©r|Ú
expressionrIcCs,tt tj|¡ƒ}|j|fddid|idS)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.::
 
            stmt = select(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.
 
        .. seealso::
 
            :ref:`orm_queryguide_with_expression` - background and usage
            examples
 
        Zquery_expressionTr…rj)rr&rTr'ZLabeledColumnExprRolerf)rYr|r…r[r[r\Úwith_expressionÄs ÿÿz_AbstractLoad.with_expressionúIterable[Type[Any]])ÚclassesrIcCs0|jddidttdd„|Dƒtdƒid}|S)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`
 
        Zselectinload_polymorphicTÚentitiescss|]}t|ƒVqdS©Nr")Ú.0Úclsr[r[r\Ú    <genexpr>þsz5_AbstractLoad.selectin_polymorphic.<locals>.<genexpr>)r|rj)Ú_set_class_strategyÚtupleÚsortedÚid)rYrˆr[r[r\Úselectin_polymorphicësÿÿþz"_AbstractLoad.selectin_polymorphicÚ _StrategySpecr9)r}rIcCsdSrŠr[©rYr}r[r[r\Ú _coerce_stratsz_AbstractLoad._coerce_stratz Literal[None]ÚNonecCsdSrŠr[r”r[r[r\r•szOptional[_StrategySpec]úOptional[_StrategyKey]cCs"|dk    rtt| ¡ƒƒ}nd}|SrŠ)rrÚitems)rYr}Ú strategy_keyr[r[r\r• súOptional[_OptsType])rFr}rCrPrQrIcCs&| |¡}|j|f|t|||d|S)N)rPrCÚreconcile_to_other)r•Ú_clone_for_bind_strategyr/)rYrFr}rCrPrQr™r[r[r\rXs    
úz(_AbstractLoad._set_relationship_strategyúTuple[_AttrType, ...])rar}rPrIcCs"| |¡}|j||t||d|S)N)rPÚ
attr_group)r•rœr1)rYrar}rPr™r[r[r\rf*s
ûz"_AbstractLoad._set_column_strategy)rar}rQrIcCs"| |¡}|j||dd|d|S)NT)rCr›©r•rœ)rYrar}rQr™r[r[r\Ú_set_generic_strategy<s
ûz#_AbstractLoad._set_generic_strategyÚ    _OptsType)r}rPrIcCs | |¡}|jd|d|d|S)NrjrŸ)rYr}rPr™r[r[r\rŽMs
z!_AbstractLoad._set_class_strategyÚLoad©ÚparentrIcCs
tƒ‚dS)z¡apply this :class:`_orm._AbstractLoad` object as a sub-option o
        a :class:`_orm.Load` object.
 
        Implementation is provided by subclasses.
 
        N©ÚNotImplementedError)rYr¤r[r[r\Ú_apply_to_parentVsz_AbstractLoad._apply_to_parent©rPrIcGs
tƒ‚dS)z™Apply a series of options as sub-options to this
        :class:`_orm._AbstractLoad` object.
 
        Implementation is provided by subclasses.
 
        Nr¥©rYrPr[r[r\Úoptions_sz_AbstractLoad.optionsúOptional[Tuple[_AttrType, ...]]úOptional[_WildcardKeyType]úOptional[_AttrGroupType]©rar}Ú wildcard_keyrPržrCr›rIcCs
tƒ‚dSrŠr¥)rYrar}r¯rPržrCr›r[r[r\rœhs
z&_AbstractLoad._clone_for_bind_strategyr7úSequence[_MapperEntity])Ú compile_stateÚmapper_entitiesrIcCs&|jjs dS| ||t|jƒ ¡dSrŠ)Úcompile_optionsÚ_enable_eagerloadsÚ_processrDÚ current_path)rYr±r²r[r[r\Ú'process_compile_state_replaced_entitiests
ýz5_AbstractLoad.process_compile_state_replaced_entities)r±rIcCs2|jjs dS| ||jt|jƒ o*|jj ¡dSrŠ)r³r´rµZ_lead_mapper_entitiesrDr¶Ú_for_refresh_state)rYr±r[r[r\Úprocess_compile_state…s üz#_AbstractLoad.process_compile_state©r±r²ÚraiseerrrIcCs
tƒ‚dS)zimplemented by subclassesNr¥)rYr±r²r»r[r[r\rµsz_AbstractLoad._processr=rzOptional[_PathRepresentation])Úto_chopÚpathÚdebugrIcCs¸d}tt||jƒƒD]’\}\}}t|tƒrl|dkrJ| dt›¡rJ|S|t›dt›krl||j    krldS||krxqqt|t
ƒr t |ƒr t |ƒr |  |¡r qqdSq||dd…S)Néÿÿÿÿrú:r) Ú    enumerateÚzipÚ natural_pathrRrSÚendswithrr/rr|rrZisa)rŒr¼r½r¾ÚiZc_tokenZp_tokenr[r[r\Ú
_chop_path™s2
ÿ
ÿþÿþýüz_AbstractLoad._chop_path)NF)N)N)N)F)F)TNN)N)N)NNTN)F)$Ú__name__Ú
__module__Ú __qualname__Ú    __slots__Z_is_strategy_optionÚ__annotations__r]rgrmrqrtrvrwrxr_r{r~rr‚r†r’r    r•r*rXrfr rŽr§rªrœr·r¹rµÚ classmethodrÆr[r[r[r\rBXsl
üIFý]"ý8ý1&<* '    úüü    ø      ürBc
@s eZdZUdZdZdejjfdejj    fdejj
fgZ dZ de d<de d<d    d
œd d „Zd dœdd„Zedddœdd„ƒZddddœdd„Zdddœdd„Zdd„Zddd d!d"œd#d$„Zdd!d%œd&d'„Zed(d)d*œd+d,„ƒZd;d.d/d0d1d2d d3d)d4œd5d6„Zd7d8„Zd9d:„ZdS)<r¢a„Represents loader options which modify the state of a
    ORM-enabled :class:`_sql.Select` or a legacy :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:`_orm.defer`, or similar.   It typically is not instantiated directly
    except for in some very specific cases.
 
    .. seealso::
 
        :ref:`orm_queryguide_relationship_per_entity_wildcard` - illustrates an
        example where direct use of :class:`_orm.Load` may be useful
 
    )r½Úcontextr½rÍrCNrzTuple[_LoadElement, ...]ú_EntityType[Any])ÚentitycCs,tdt|ƒƒ}|j|j|_d|_d|_dS)Nz$Union[Mapper[Any], AliasedInsp[Any]]r[F)rr#Z _post_inspectÚ_path_registryr½rÍrC)rYrÏÚinspr[r[r\Ú__init__às
z Load.__init__rS©rIcCsd|jd›dS)NúLoad(rú))r½©rYr[r[r\Ú__str__èsz Load.__str__)r½rIcCs | |¡}||_d|_d|_|S)Nr[F)Ú__new__r½rÍrC)rŒr½Úloadr[r[r\Ú_construct_for_existing_pathës
 
z!Load._construct_for_existing_pathr8r;)rÍÚ uncached_optrIcCs
| |¡SrŠ)Ú_adjust_for_extra_criteria)rYrÍrÛr[r[r\Ú'_adapt_cached_option_to_uncached_optionósz,Load._adapt_cached_option_to_uncached_option)rÍrIcsfˆjj‰d‰d‰d‰dddœ‡‡‡‡‡fdd„ ‰t‡fdd„|jDƒƒ}ˆr^| ¡}||_|S|SdS)    zÈApply the current bound parameters in a QueryContext to all
        occurrences "extra_criteria" stored within this ``Load`` object,
        returning a new instance of this ``Load`` object.
 
        NFÚ _LoadElement)ÚoptrIcsh|js
|Sd‰ˆdksˆdkrHˆ ¡‰ˆj ¡‰ˆdk    s<t‚ˆdk    sHt‚t‡‡fdd„|jDƒƒ|_|S)NTc3s|]}ˆ ˆ|¡VqdSrŠ)Ú_apply_params_to_element)r‹Úcrit)Úorig_cache_keyÚreplacement_cache_keyr[r\rs
ýÿzCLoad._adjust_for_extra_criteria.<locals>.process.<locals>.<genexpr>)Ú_extra_criteriaÚ_generate_cache_keyÚqueryrWr)rß)rÍÚ
found_critrâÚ
orig_queryrãr[r\Úprocesss
  ü
z0Load._adjust_for_extra_criteria.<locals>.processc3s$|]}|jrˆ| ¡ƒn|VqdSrŠ)räÚ_clone©r‹Úvalue)rér[r\rsÿz2Load._adjust_for_extra_criteria.<locals>.<genexpr>)r±Úselect_statementrrÍrê)rYrÍZ new_contextrZr[)rÍrçrârèrérãr\rÜøs þzLoad._adjust_for_extra_criteriacCs@|j}d}|D],}|j}|rt |td|dƒ¡r|SqdS)zocalled at process time to allow adjustment of the root
        entity inside of _LoadElement objects.
 
        Nú_InternalEntityType[Any]r)r½Ú entity_zeroÚorm_utilÚ_entity_corresponds_tor)rYr²r»r½ÚezeroÚentr[r[r\Ú!_reconcile_query_entities_with_us*s ü
z&Load._reconcile_query_entities_with_usr7r°rDr–rºcCs.| ||¡}|jD]}| |||||¡qdSrŠ)rôrÍr¹)rYr±r²r»Úreconciled_lead_entityrlr[r[r\rµ>sÿ
ûz Load._processr£csà| ¡}|j|jkst‚t tdˆjdƒtd|jdƒ¡s‚t|jƒdkr`|jd}|jd}n|jd}|jd}tˆj||ƒt     
ˆjdd…|jdd…¡|_|j rÆt ‡fdd„|j Dƒƒ|_ |j r܈j |j 7_ dS)z²apply this :class:`_orm.Load` object as a sub-option of another
        :class:`_orm.Load` object.
 
        This method is used by the :meth:`_orm.Load.options` method.
 
        rîr¿rrNc3s|]}| ˆ¡VqdSrŠ)Ú_prepend_path_fromrë©r¤r[r\rlsz(Load._apply_to_parent.<locals>.<genexpr>) Z    _generaterCrWrðÚ$_entity_corresponds_to_use_path_implrr½ÚlenÚ_raise_for_does_not_linkrÚcoercerÍr)rYr¤rZÚattrnameÚ parent_entityr[r÷r\r§Rs&þ
 
 
$ ÿ
zLoad._apply_to_parentrBr-r¨c Gsb|D]X}z| |¡Wqtk
rZ}z&t|tƒsHt d|›d¡|‚n‚W5d}~XYqXq|S)acApply 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:`orm_queryguide_relationship_sub_options`
 
        zLoader option z2 is not compatible with the Load.options() method.N)r§ÚAttributeErrorrRrBÚsa_excÚ ArgumentError)rYrPrßZaer[r[r\rªss
 
ÿýz Load.optionsTr«r—r¬ršr­rhr®c Cs2|r
d|_|jjrt d¡‚n>t|jƒr\|rF|jj |jj|d¡nt d|jj›d¡‚|dkr–tj    |jd||||||d}|r”|j
|f7_
n˜|D]’}    t |    t ƒrÆt j    |j|    ||||||d}ntj    |j|    ||||||d}|rš|tkrö|j|_|j
|f7_
|j dd¡rš| ¡}
|j
|
f7_
qš|S)    NTú3Wildcard token cannot be followed by another entityrzMapped attribute 'z#' does not refer to a mapped entity)ržr›rsF)rCr½Úis_tokenrÿrrÚpropZ_strategy_lookupÚ_ClassStrategyLoadÚcreaterÍrRrSÚ_TokenStrategyLoadÚ_AttributeStrategyLoadr/Ú
local_optsÚgetÚ_recurse) rYrar}r¯rPržrCr›Ú load_elementrFZr1r[r[r\rœŸsn ÿ
ÿø
 
ø ø zLoad._clone_for_bind_strategycCs| ¡}|j ¡|d<|S©Nr½©Ú_shallow_to_dictr½Ú    serialize©rYÚdr[r[r\Ú __getstate__÷szLoad.__getstate__cCs t |d¡|d<| |¡dSr ©rÚ deserializeÚ_shallow_from_dict©rYÚstater[r[r\Ú __setstate__üszLoad.__setstate__)NNTN)rÇrÈrÉÚ__doc__rÊr)ÚExtendedInternalTraversalÚdp_has_cache_keyÚInternalTraversalZdp_has_cache_key_listZ
dp_booleanÚ_traverse_internalsÚ_cache_key_traversalrËrÒr×rÌrÚrÝrÜrôrµr§r*rªrœrrr[r[r[r\r¢½s:
 
þ
ú2!0øXr¢c@sÒeZdZUdZdZdejjfdejjfdejjfgZ    dZ
de d<d    e d<d
e d<d e d<d Z d dœdd„Z d,dd„Zdddœdd„Zdd dœdd„Zdd„Zdd d!d"d#œd$d%„Zd&dœd'd(„Zd&d d)œd*d+„ZdS)-Ú _WildcardLoadz)represent a standalone '*' load operation)r}r½rr}r½rNr@Úcache_key_traversalzOptional[Tuple[Any, ...]]r¡zUnion[Tuple[()], Tuple[str]]Fr–rÓcCsd|_d|_tj|_dS)Nr[)r½r}rrkrrÖr[r[r\rÒsz_WildcardLoad.__init__Tc    Csb|dk    s t‚|d}|r.t|tƒr.|ttfks2t‚|›d|›}||_|f|_|r^t |¡|_    dS)NrrÀ)
rWrRrSrrr}r½rÚ immutabledictr)    rYrar}r¯rPržrCr›rFr[r[r\rœs
ÿþ
ýz&_WildcardLoad._clone_for_bind_strategyrBr-r¨cGs tdƒ‚dS)Nz(Star option does not support sub-optionsr¥r©r[r[r\rª3sz_WildcardLoad.optionsr¢r£cCs€|js
t‚|jd}| t¡r6| d¡d›dt›}tt|jƒ |¡}|j    sRt‚t
  |d|j d|j |j¡}|j|f7_dS)aPapply this :class:`_orm._WildcardLoad` object as a sub-option of
        a :class:`_orm.Load` object.
 
        This method is used by the :meth:`_orm.Load.options` method.   Note
        that :class:`_orm.WildcardLoad` itself can't have sub-options, but
        it may be used as the sub-option of a :class:`_orm.Load` object.
 
        rrÀN)r½rWrÄrÚsplitrrrÚtokenrrrr}rrCrÍ)rYr¤rFÚeffective_pathrlr[r[r\r§6s    
 
 
 
ú    z_WildcardLoad._apply_to_parentc     Csô|jj}|r|jsdSdd„|Dƒ}|j}|j}|rX| ||¡}|dkrLdS||ksXt‚|rht|ƒdkslt‚|d}    t|    t    ƒs‚t‚| 
||    |¡}
|
s˜dS|
} t|    t    ƒsªt‚t j | j |    |jd|j|j|d} | sÒdS| jjsÞt‚|  |||d|¡| S)NcSsg|]
}|j‘qSr[)rï©r‹rór[r[r\Ú
<listcomp>Ysz*_WildcardLoad._process.<locals>.<listcomp>rr)r»)r³r¸rCr¶r½rÆrWrùrRrSÚ_find_entity_basestringrrrÐr}rrr¹) rYr±r²r»Ú
is_refreshr‰r¶Ú
start_pathÚnew_pathr#rÏZ path_elementrlr[r[r\rµSsN
  ù     ÿz_WildcardLoad._processz"Iterable[_InternalEntityType[Any]]rSrDz"Optional[_InternalEntityType[Any]])r‰r#r»rIc    Csœ| dt›¡r^tt|ƒƒdkrl|rlt dd dd„|Dƒ¡›dd dd„|Dƒ¡›d    ¡‚n| t¡rld
}|D]
}|S|r”t d |›d ¡‚ndSdS) NrÀrzMCan't apply wildcard ('*') or load_only() loader option to multiple entities ú, css|]}t|ƒVqdSrŠ)rSr%r[r[r\ršsz8_WildcardLoad._find_entity_basestring.<locals>.<genexpr>z?. Specify loader options for each entity individually, such as css|]}d|›dVqdS)rÔz).some_option('*')Nr[r%r[r[r\r›sÿÚ.FzFQuery has only expression-based entities - can't find property named "ú".)rÄrrùÚlistrÿrÚjoinr)rYr‰r#r»rór[r[r\r's&
þÿÿ
 
ÿz%_WildcardLoad._find_entity_basestringúDict[str, Any]cCs | ¡}|SrŠ)rrr[r[r\r¶sz_WildcardLoad.__getstate__©rrIcCs| |¡dSrŠ)rrr[r[r\rºsz_WildcardLoad.__setstate__)NNTN)rÇrÈrÉrrÊr)rÚ dp_plain_objÚdp_string_multi_dictrr rËrCrÒrœrªr§rµr'rrr[r[r[r\rs2
 
 
þý 
ø
=&rc @sžeZdZUdZdZdZdejjfdejj    fdejj
fdej j fdej j    fd    ej j    fgZ d
Zd ed<d ed    <d ed<ded<ded<ded<ded<ded<ddœdd„Zdd„Zeddœdd„ƒZdddœdd„Zdddœdd „Zd!dœd"d#„Zd!d$d%œd&d'„Zd(d)„Zddd*d+œd,d-„Zd.d/„Zd0d1„Zd2d3„ZedGdd5d d6d7ddd8d dd9œ
d:d;„ƒZd$dœd<d=„Zddœd>d?„Z d@ddAœdBdC„Z!e"ddddDœdEdF„ƒZ#d
S)HrÞaArepresents strategy information to select for a LoaderStrategy
    and pass options to it.
 
    :class:`._LoadElement` objects provide the inner datastructure
    stored by a :class:`_orm.Load` object and are also the object passed
    to methods like :meth:`.LoaderStrategy.setup_query`.
 
    .. versionadded:: 2.0
 
    )r½r}rCrrärQr r½r}rrärCrQNzTuple[Any, ...]rhr—rrDzutil.immutabledict[str, Any]Úis_token_strategyÚis_class_strategyÚintrÓcCst|ƒSrŠ)r‘rÖr[r[r\Ú__hash__ïsz_LoadElement.__hash__cCs t ||¡SrŠ)r(Úcompare)rYÚotherr[r[r\Ú__eq__òsz_LoadElement.__eq__cCst|jo|jdkƒSrŠ)rDrr}rÖr[r[r\Ú is_opts_onlyõsz_LoadElement.is_opts_onlyr)ÚkwrIcKs|j}| |¡}| |¡|SrŠ)Ú    __class__rØZ_shallow_copy_to)rYr<rŒÚsr[r[r\rêùs
 
z_LoadElement._clonecKs| ¡}|j |¡|_|SrŠ)rêrÚunion)rYr<Únewr[r[r\Ú _update_optssz_LoadElement._update_optsr0cCs| ¡}|j ¡|d<|Sr r rr[r[r\rsz_LoadElement.__getstate__r–r1cCs t |d¡|d<| |¡dSr rrr[r[r\r
sz_LoadElement.__setstate__c    Csr|j}d}|D]}|j}|rd}q&q|sBt d|d›d¡‚n,t d|d›dd d    d
„|Dƒ¡›d ¡‚dS) NFTzGQuery has only expression-based entities; attribute loader options for rz can't be applied here.z Mapped class z@ does not apply to any of the root entities in this query, e.g. r+css|]}|jrt|jƒVqdSrŠ)rïrS)r‹Úxr[r[r\r!sÿz3_LoadElement._raise_for_no_match.<locals>.<genexpr>zV. Please specify the full path from one of the root entities to the target attribute. )r½rïrÿrr/)rYÚ parent_loaderr²r½Zfound_entitiesróròr[r[r\Ú_raise_for_no_matchs$ÿ 
ÿÿÿz _LoadElement._raise_for_no_matchúOptional[PathRegistry])r$r¶rIcCsLt |j|¡}|sdSt|ƒt|ƒ}|j|}t |f|dd…¡}|S)aúreceives the 'current_path' entry from an :class:`.ORMCompileState`
        instance, which is set during lazy loads and secondary loader strategy
        loads, and adjusts the given path to be relative to the
        current_path.
 
        E.g. given a loader path and current path::
 
            lp: User -> orders -> Order -> items -> Item -> keywords -> Keyword
 
            cp: User -> orders -> Order -> items
 
        The adjusted path would be::
 
            Item -> keywords -> Keyword
 
 
        Nr)r¢rÆrÃrùr½rrû)rYr$r¶Zchopped_start_pathZtokens_removed_from_start_pathZloader_lead_path_elementr[r[r\Ú'_adjust_effective_path_for_current_path+sÿÿ
ÿz4_LoadElement._adjust_effective_path_for_current_pathcCs
tƒ‚dS)z×Apply ORM attributes and/or wildcard to an existing path, producing
        a new path.
 
        This method is used within the :meth:`.create` method to initialize
        a :class:`._LoadElement` object.
 
        Nr¥©rYr½rFr¯ržr»r[r[r\Ú
_init_pathQsz_LoadElement._init_pathcCs
tƒ‚dS)zimplemented by subclasses.Nr¥)rYrCr±r²rõr»r[r[r\Ú_prepare_for_compile_state[s    z'_LoadElement._prepare_for_compile_statecCsN| |||||¡}|D]2}||jkr>t ||j|¡|j|<q||j|<qdS)z^populate ORMCompileState.attributes with loader state for this
        _LoadElement.
 
        N)rIÚ
attributesrÞÚ
_reconcile)rYrCr±r²rõr»Úkeysr|r[r[r\r¹fs û
ÿ z"_LoadElement.process_compile_stateTzOptional[_AttrType]r¬ršr­)
r½rFr}r¯rrCr»ržr›rIc
Cs–| |¡}
||
_||
_||
_|r*t |¡ntj|
_d|
_|    dk    rH|    |
_    n|dkr\|s\d|
_    nd|
_    |
 
|||||¡}|s|dS|
j |j ksŒt ‚||
_|
S)z+Create a new :class:`._LoadElement` object.r[NT)rØr½r}rCrr!rkrrärQrHr4rrW) rŒr½rFr}r¯rrCr»ržr›rßr[r[r\rs$
ÿ z_LoadElement.createcCs
tƒ‚dSrŠr¥rÖr[r[r\rÒªsz_LoadElement.__init__cCs0| ¡}t |jdd…|jdd…¡|_|S)Néþÿÿÿ)rêrrûr½)rYrZr[r[r\r
­s$z_LoadElement._recursezUnion[Load, _LoadElement]r£cCs¨| ¡}|j|jkst‚|j|jks(t‚|j|jks8t‚t td|jdƒtd|jdƒ¡s€t     
d|jd›d|jd›d¡‚t   |jdd…|jdd…¡|_|S)    a%adjust the path of this :class:`._LoadElement` to be
        a subpath of that of the given parent :class:`_orm.Load` object's
        path.
 
        This is used by the :meth:`_orm.Load._apply_to_parent` method,
        which is in turn part of the :meth:`_orm.Load.options` method.
 
        rîr¿rz Attribute "rz" does not link from element "r-N) rêr}rWrr5rðrørr½rÿrrrû)rYr¤rZr[r[r\rö³s þÿ$z_LoadElement._prepend_path_from)Ú replacementÚexistingrIcCsà|jr
|S|jdkr|S|jr"|S|jdkr0|S||kr<|S|j|jkrX|j|jkrX|S|jrŠ| ¡}|j |j¡|_|j|j7_|S|jr¼| ¡}|j |j¡|_|j|j7_|S|jjrÈ|St     
d|j›d¡‚dS)adefine behavior for when two Load objects are to be put into
        the context.attributes under the same key.
 
        :param replacement: ``_LoadElement`` that seeks to replace the
         existing one
 
        :param existing: ``_LoadElement`` that is already present.
 
        FzLoader strategies for z     conflictN) rQr}rr;rêr?rär½rrÿZInvalidRequestError)rNrOr[r[r\rKÑsD
 
 
ÿ
þÿÿ ÿz_LoadElement._reconcile)TNN)$rÇrÈrÉrrÊÚ__visit_name__r)rrr2r3rZdp_clauseelement_listrrrËr7r:Úpropertyr;rêrArrrDrFrHrIr¹rÌrrÒr
röÚ staticmethodrKr[r[r[r\rÞ¾sX
 
 
þ
 
 
÷ &
     ö$(rÞcsŒeZdZUdZdZdZejdej    j
fdej    j fgZde d<de d<dZ dZd    d
„Zd d „Zd d„Zdd„Z‡fdd„Z‡fdd„Z‡ZS)rzÈLoader strategies against specific relationship or column paths.
 
    e.g.::
 
        joinedload(User.addresses)
        defer(Order.name)
        selectinload(User.orders).lazyload(Order.items)
 
    )rMÚ_path_with_polymorphic_pathZattribute_strategy_load_elementrMrSz*Union[Mapper[Any], AliasedInsp[Any], None]rEFc Csú|dk    s t‚d|_d|_t|ƒ\}}}|jrH|}||}|jrD|j}|S|jsVdsVt‚t     |d|j
¡s |rœ|rˆ||dk    rˆt   d¡‚q t |t|ƒ|j
ƒndS|j|_t|ddƒrâ|j}    t|    ƒ}
|
|_|j||_|||
}n||}|jrö|j}|S)NFr¿rzCan't apply wildcard ('*') or load_only() loader option to multiple entities in the same option. Use separate options per entity.rM)rWrMrSÚ_parse_attr_argumentZ is_propertyÚ
has_entityZ entity_pathZ is_attributerðrør¤rÿrrúrSrärVr#) rYr½rFr¯ržr»rÑÚ_rÚacZext_infor[r[r\rH(sD ÿÿ
  z!_AttributeStrategyLoad._init_pathcCs>|jstdƒ‚|jj}|j}| ¡}| ¡}| |t|jŽ¡S)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ärWr±ríræråràr$)rYrÍrèZ current_queryZk1Zk2r[r[r\Ú_generate_extra_criteriais ÿþz/_AttributeStrategyLoad._generate_extra_criteriac
Cs¢|js
t‚|j}|st‚|js>ttjj|jj    |jfdddƒ}|j}|rd| 
||¡}|dkr`dS|}d|j f}||kr–||}|}|  |¡}    |    ||<n|||<dS)NT)ÚaliasedZ_use_mapper_pathZpath_with_polymorphic) rSrWrMÚis_aliased_classr#rðrZ_with_polymorphic_factoryÚmapperZ base_mapperrFrÃZ _merge_with)
rYrÍr¶Zpwpir)r*r|Zexisting_aliased_inspZthis_aliased_inspZnew_aliased_inspr[r[r\Ú_set_of_type_infoŽs<
üÿÿ
ÿ
z(_AttributeStrategyLoad._set_of_type_infoc    Cs²|j}|jj}|jjrt‚|r(|js(gS|jr<| |j    |¡|j
sL|j sLgS|r`|s`|  ||¡|jj rr|jj}n|j}|r |dk    sˆt‚| ||¡}|dkr gSdtt|ƒjfgS©Nrl)r¶r³r¸r½rrWrCrMr\rJr}rrDrUr¤rFrrrÃ)    rYrCr±r²rõr»r¶r(r$r[r[r\rI±s.
 
 
 ÿz1_AttributeStrategyLoad._prepare_for_compile_statecsdtƒ ¡}d|d<|jr&|j ¡|d<|jr`|jjr>d|d<n"|jjrT|jj|d<n ds`tdƒ‚|S)Nr[rärSrMFzunexpected object for _of_type)    ÚsuperrrSrrMrZZ    is_mapperÚclass_rWr©r=r[r\rÝs
þÿ
 z#_AttributeStrategyLoad.__getstate__csVtƒ |¡| dd¡r*t |d¡|_nd|_| dd¡rLt|dƒ|_nd|_dS)NrSrM)r^rr    rrrSr#rMrr`r[r\rõs  ÿ z#_AttributeStrategyLoad.__setstate__)rÇrÈrÉrrÊrPrÞrr)rZdp_multirrËr5r4rHrXr\rIrrÚ __classcell__r[r[r`r\r s&
 
 
þþA%#, rc@s0eZdZdZdZdZdZdZdd„Zdd„Z    d    S)
raLoader strategies against wildcard attributes
 
    e.g.::
 
        raiseload('*')
        Load(User).lazyload('*')
        defer('*')
        load_only(User.name, User.email)  # will create a defer('*')
        joinedload(User.addresses).raiseload('*')
 
    Ztoken_strategy_load_elementTFcCsN|dk    rJ| t¡}| t¡s |r@|r2|›d|›}| |¡}|St d¡‚|S)NrÀúkStrings are not accepted for attribute names in loader options; please use class-bound attributes directly.)rÄrrr#rÿr)rYr½rFr¯ržr»Z default_tokenr[r[r\rHs
 
ÿz_TokenStrategyLoad._init_pathc
Cs”|j}|jj}|jjst‚|r(|js(gS|js8|js8gS|j}|r\t     
|f|jdd…¡}|r||  ||¡}    |    dkrxgS|    }dd„t t |ƒ ¡DƒS)NrcSsg|]}d|jf‘qS)rl)rÃ)r‹Ú_pathr[r[r\r&RsÿzA_TokenStrategyLoad._prepare_for_compile_state.<locals>.<listcomp>)r¶r³r¸r½rrWrCr}rrrûrFrrZgenerate_for_superclasses©
rYrCr±r²rõr»r¶r(r$Znew_effective_pathr[r[r\rI)s4
 
 ÿÿÿþz-_TokenStrategyLoad._prepare_for_compile_stateN)
rÇrÈrÉrrPÚ inherit_cacher5r4rHrIr[r[r[r\rs rc@s0eZdZdZdZdZdZdZdd„Zdd„Z    d    S)
rzÐLoader strategies that deals with a class as a target, not
    an attribute path
 
    e.g.::
 
        q = s.query(Person).options(
            selectin_polymorphic(Person, [Engineer, Manager])
        )
 
    TFZclass_strategy_load_elementcCs|SrŠr[rGr[r[r\rHlsz_ClassStrategyLoad._init_pathc
Cs^|j}|jj}|r|jsgS|js,|js,gS|j}|rR| ||¡}    |    dkrNgS|    }d|jfgSr])    r¶r³r¸rCr}rr½rFrÃrdr[r[r\rIos 
 
 ÿz-_ClassStrategyLoad._prepare_for_compile_stateN)
rÇrÈrÉrrer5r4rPrHrIr[r[r[r\rZs rzCallable[..., _AbstractLoad]rrDr)ÚmethrLÚchainedr<rIc
Csd}d|dd…fd|dd…ffD]Ü\}}|D]Î}t|tƒr¦| dt¡rftjddd|d    d…}|tkrš|r|t d
¡‚|dkrŠtƒ}||t    f|Ž}qþt d ¡‚q0|dkrÄt
|ƒ\}}    }t |    ƒ}|rð|sØ|  |¡}qþ|||fd di|—Ž}q0|||f|Ž}q0q$|s t ‚|S) NTrr¿Fr,zçThe 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.rJrKrrrbrH)rRrSÚ
startswithrrrUrÿrrrrTr¢r{rW)
rfrLrgr<Ú lead_elementZ
is_defaultÚ_keysrFrVÚ lead_entityr[r[r\Ú_generate_from_keyssL(
    ö ÿÿ ÿÿÿ
rlrEzDTuple[InspectionAttr, _InternalEntityType[Any], MapperProperty[Any]]rnc
Cs|z t|ƒ}Wn0tjk
r<}zt d¡|‚W5d}~XYnXt|ƒrR|j}|}n t|ƒrh|j}|j}n
t d¡‚|||fS)aparse an attribute or wildcard argument to produce an
    :class:`._AbstractLoad` instance.
 
    This is used by the standalone loader strategy functions like
    ``joinedload()``, ``defer()``, etc. to produce :class:`_orm.Load` or
    :class:`._WildcardLoad` objects.
 
    z:expected ORM mapped attribute for loader strategy argumentN)r#rÿZNoInspectionAvailablerrr¤rr)rFrÑÚerrrkrr[r[r\rTÐs$  ÿþÿrT)ÚfnrIcCs4tt|jƒ}|j}d|j›d|j›d|_||_|S)z‚decorator that applies docstrings between standalone loader functions
    and the loader methods on :class:`._AbstractLoad`.
 
    z=Produce a new :class:`_orm.Load` object with the
:func:`_orm.z#` option applied.
 
See :func:`_orm.z` for usage examples.
 
)rVrBrÇr)rnZbound_fnZfn_docr[r[r\Úloader_unbound_fnõs ÿÿ
ro)rLr<rIcOsttj|d|ƒS)NT)rlr¢r]©rLr<r[r[r\r]     sr]Fr^r`cGs&t|dƒ\}}}t|ƒj|d|iŽS)Nrr_)rTr¢rg)r_rarVrir[r[r\rg    srgcOsttj|d|ƒS©NF)rlr¢rmrpr[r[r\rm    srm)rLrIcGsttj|diƒSrq)rlr¢rq©rLr[r[r\rq    srq)rsrr)rLrsrIcGsttj|dd|iƒS©NFrs)rlr¢rt©rsrLr[r[r\rt"    s ÿrtcGsttj|diƒSrq)rlr¢rvrrr[r[r\rv+    srvcGsttj|dd|iƒSrs)rlr¢rwrtr[r[r\rw0    s ÿrwcGsttj|diƒSrq)rlr¢rxrrr[r[r\rx9    srxcOsttj|d|ƒSrq)rlr¢r_rpr[r[r\r_>    sr_cGsttj|diƒSrq)rlr¢r{rrr[r[r\r{C    sr{)r|Ú
addl_attrsr_rIcGs:|rtjddd|r d|i}ni}ttj|f|d|ƒS)Nz}The *addl_attrs on orm.defer is deprecated.  Please use method chaining in conjunction with defaultload() to indicate a path.ú1.3rKr_F)rrUrlr¢r~)r|r_rur<r[r[r\r~H    sü
r~)r|rurIcGs(|rtjdddttj|f|diƒS)NzThe *addl_attrs on orm.undefer is deprecated.  Please use method chaining in conjunction with defaultload() to indicate a path.rvrKF)rrUrlr¢r)r|rur[r[r\r\    s ürrSr€cCstƒ}| |¡SrŠ)rr‚)rÚelementr[r[r\r‚h    sr‚rƒr„cCsttj|fdd|iƒS)NFr…)rlr¢r†)r|r…r[r[r\r†n    s ÿr†rÎr‡)Úbase_clsrˆrIcCst|ƒ}| |¡SrŠ)r¢r’)rxrˆÚulr[r[r\r’w    sr’c    CsÎt|ƒdkr®|dj|djjk    }t|ƒr4t|ƒ}n|jj}t d|›d|d›d|rhd|d›dnd    |s¢|dj    s¢t
  |jt |ƒj¡r¢d
|d›d|›d nd    f¡‚nt d |›d |d›d¡‚dS)Nrr¿rMz ORM mapped entity or attribute "z#" does not link from relationship "z%s".%sz    .of_type(rÕÚz  Did you mean to use "z)"?zORM mapped attribute "z" does not link mapped class "ú") rùrÏr[r_rrSrÇrÿrrZrðrñr#)r½rürýZpath_is_of_typeZparent_entity_strr[r[r\rú    s0 
ýüÿûõþÿÿrú)rrÚ
__future__rÚtypingrrrrrrr    r
r r r rrzrrðÚ_typingrrrrrJrÚbaserZ
interfacesrZ path_registryrrrrrrrrr!rÿr#Zsqlr$r%r&r'r(r)Zsql.baser*Z util.typingr+r,r-r/rËr1r2Ú TYPE_CHECKINGr4r5rÍr6r7r8r9r:r;r[r<r=Z sql._typingr>r?Z sql.cache_keyr@rArSrEZ_WildcardKeyTyper“r¡Z_AttrGroupTypeZGenerativeOnTraversalrBr¢rZ HasCacheKeyZHasShallowCopyZ TraversiblerÞrrrrlrTror]rgrmrqrtrvrwrxr_r{r~rr‚r†r’rúr[r[r[r\Ú<module>sü                                                               kF>
ÿO{U6@%ÿÿÿ