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
U
¸ý°d_½ã    @s¸dZddlmZddlZddlZddlZddlmZddlmZddlmZddlm    Z    ddlm
Z
dd    lm Z dd
lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#dd lm$Z$dd!lm%Z%dd"lm&Z&dd#lm'Z'dd$lm(Z(dd%lm)Z)dd&lm*Z*d'd(lm+Z+d'dlmZ,d'd)lm-Z-d'd*lm.Z.d'd+l/m0Z0d'd,l/m1Z1d'd-l/m2Z2d'd.l3m4Z4d'd/l3m5Z5d'd0l6m7Z7d'd1l8m9Z9d'd2l:m;Z;d'd3l<m=Z=d'd4l>m?Z?d'd5l>m@Z@ejrØdd6lAmBZBdd7lAmCZCdd8lAmDZDdd9lAmEZEdd:lAmFZFdd;lGmHZHdd<lmIZIdd=lJmKZKdd>lJmLZLdd?lJmMZMdd@lNmOZOddAlPmQZQddBlRmSZSddClTmUZUddDlmVZVddElWmXZXddFlYmZZZddGl[m\Z\ddHl]m^Z^ddIl.m_Z_ddJl.m`Z`d'dKlambZbd'dLlcmdZdd'dMlcmeZed'dNlcmfZfd'dOlcmgZgd'dPl8mhZhd'dQlimjZjd'dRl>mkZkeedSfZledTedUZmedVdWdUZnGdXdY„dYe1joƒZpGdZd[„d[e1jqe1jremƒZsGd\d]„d]esemƒZtGd^d_„d_e1juƒZvGd`da„dae@ƒZwGdbdc„dcƒZxGddde„deeƒZyeye4jze4jze4jze4jze4jze4jzƒZ{eydfe4jze4jze4jze4jze4jzƒZ|Gdgdh„dhƒZ}Gdidj„dje}eemƒZ~e-jGdkdl„dle7e}eeme"e.j€ƒƒZe-jGdmdn„dne*eme eme9ƒƒZ‚Gdodp„dpeemƒZƒGdqdr„dre5ƒZ„Gdsdt„dte7e„ƒZ…Gdudv„dve…ƒZ†Gdwdx„dxe…ƒZ‡Gdydz„dze„ƒZˆe.j‰d{d|dd}Gd~d„de„ƒƒZŠGd€d„dƒZ‹dS)‚zî
 
Contains various base classes used throughout the ORM.
 
Defines some key base classes prominent within the internals.
 
This module and the classes within are mostly private, though some attributes
are exposed when inspecting mappings.
 
é)Ú annotationsN)ÚAny)ÚCallable)Úcast)ÚClassVar)ÚDict)ÚGeneric)ÚIterator)ÚList)Ú
NamedTuple)ÚNoReturn)ÚOptional)ÚSequence)ÚSet)ÚTuple)ÚType)Ú TYPE_CHECKING)ÚTypeVar)ÚUnioné)Úexc)Ú path_registry)Ú_MappedAttribute)Ú EXT_CONTINUE)ÚEXT_SKIP)ÚEXT_STOP)ÚInspectionAttr)ÚInspectionAttrInfo)Ú
MANYTOMANY)Ú    MANYTOONE)ÚNO_KEY)ÚNO_VALUE)Ú NotExtension)Ú    ONETOMANY)ÚRelationshipDirection)ÚSQLORMOperationsé)Ú ColumnElement)Ú
inspection)Úutil)Ú    operators)Úroles)Úvisitors)Ú_NoArg)ÚExecutableOption)Ú HasCacheKey)ÚColumnOperators)ÚColumn)Ú
TypeEngine)ÚRODescriptorReference)Ú    TypedDict)Ú _EntityType)Ú_IdentityKeyType)Ú _InstanceDict)Ú_InternalEntityType)Ú_ORMAdapterProto)ÚInstrumentedAttribute)ÚMapped)Ú _MapperEntity)ÚORMCompileState)Ú QueryContext)Ú RegistryType)Ú_ClassScanMapperConfig)Ú_PopulatorDict)ÚMapper)ÚAbstractEntityRegistry)ÚQuery)ÚSession)Ú InstanceState)Ú _LoadElement)Ú AliasedInsp)Ú
ORMAdapter)ÚResult)Ú_ColumnExpressionArgument)Ú_ColumnsClauseArgument)Ú_DMLColumnArgument)Ú    _InfoType)Ú OperatorType)Ú_TraverseInternalsType)Ú_AnnotationScanType.Ú_T)ÚboundÚ_TLSúType[LoaderStrategy]c@seZdZdZdZdS)ÚORMStatementRole©z?Executable SQL or text() construct, including ORM aware objectsN©Ú__name__Ú
__module__Ú __qualname__Ú    __slots__Z
_role_namerWrWrWúPd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/orm/interfaces.pyrVqsÿrVc@seZdZdZdZdS)ÚORMColumnsClauseRolerWz7ORM mapped entity, aliased entity, or Column expressionNrXrWrWrWr]r^xsr^c@seZdZdZdZdS)ÚORMEntityColumnsClauseRolerWzORM mapped or aliased entityNrXrWrWrWr]r_sr_c@seZdZdZdZdS)ÚORMFromClauseRolerWz5ORM mapped entity, aliased entity, or FROM expressionNrXrWrWrWr]r`„sr`c@s6eZdZUded<ded<ded<ded<d    ed
<d S) ÚORMColumnDescriptionÚstrÚnamez!Union[Type[Any], TypeEngine[Any]]ÚtypeÚboolÚaliasedz_ColumnsClauseArgument[Any]Úexprz%Optional[_ColumnsClauseArgument[Any]]ÚentityN)rYrZr[Ú__annotations__rWrWrWr]ra‰s
 
rac @sPeZdZdZddœdd„Zdddd    d
d d d d ddœ
dd„Zd
dddœdd„ZdS)Ú_IntrospectsAnnotationsrWr©ÚreturncCstd|j›dƒ‚dS)zrreturn a copy of this object to use in declarative when the
        object is found inside of an Annotated object.z Use of the z> construct inside of an Annotated object is not yet supported.N)ÚNotImplementedErrorÚ    __class__©ÚselfrWrWr]Úfound_in_pep593_annotated–s ÿz1_IntrospectsAnnotations.found_in_pep593_annotatedr@r?z    Type[Any]ú Optional[str]rbzOptional[Type[Mapped[Any]]]zOptional[_AnnotationScanType]reÚNone)
Ú    decl_scanÚregistryÚclsÚoriginating_moduleÚkeyÚmapped_containerÚ
annotationÚextracted_mapped_annotationÚis_dataclass_fieldrlc
 
CsdS)zyPerform class-specific initializaton at early declarative scanning
        time.
 
        .. versionadded:: 2.0
 
        NrW)
rprtrurvrwrxryrzr{r|rWrWr]Údeclarative_scanŸs z(_IntrospectsAnnotations.declarative_scanr )rxrvrlc    Cs(t d|j›d|›d|jj›d¡‚dS)Nz4Python typing annotation is required for attribute "Ú.z " when primary argument(s) for "z#" construct are None or not present)Úsa_excÚ ArgumentErrorrYrn)rprxrvrWrWr]Ú_raise_for_required²sÿz+_IntrospectsAnnotations._raise_for_requiredN)rYrZr[r\rqr}rrWrWrWr]rj“s     rjc@sjeZdZUdZded<ded<ded<ded<ded    <ded
<d d œd d„Zeddddddœdd„ƒZdS)Ú_AttributeOptionszÀdefine Python-local attribute behavior options common to all
    :class:`.MapperProperty` objects.
 
    Currently this includes dataclass-generation arguments.
 
    .. versionadded:: 2.0
 
    zUnion[_NoArg, bool]Údataclasses_initÚdataclasses_reprzUnion[_NoArg, Any]Údataclasses_defaultz Union[_NoArg, Callable[[], Any]]Údataclasses_default_factoryÚdataclasses_compareÚdataclasses_kw_onlyrrkcCs”i}|jtjk    r|j|d<|jtjk    r0|j|d<|jtjk    rF|j|d<|jtjk    r\|j|d<|jtjk    rr|j|d<|jtjk    rˆ|j|d<tj    f|ŽS)z<Return a ``dataclasses.Field`` object given these arguments.Údefault_factoryÚdefaultÚinitÚreprÚcompareZkw_only)
r†r-ÚNO_ARGr…rƒr„r‡rˆÚ dataclassesÚfield)rpÚkwrWrWr]Ú_as_dataclass_fieldËs 
 
 
 
 
 
z%_AttributeOptions._as_dataclass_fieldrbrQú Optional[Any]rRz_Union[Tuple[str, _AnnotationScanType], Tuple[str, _AnnotationScanType, dataclasses.Field[Any]]])rxrzryÚelemrlcCsTt|tƒr|j ¡}|||fS|tjk    r2|||fS|dk    rHdsPtdƒ‚n||fSdS)z®given attribute key, annotation, and value from a class, return
        the argument tuple we would pass to dataclasses.make_dataclass()
        for this attribute.
 
        NFz/Mapped[] received without a mapping declaration)Ú
isinstanceÚ_DCAttributeOptionsÚ_attribute_optionsr’r-rŽÚAssertionError)rvrxrzryr”Zdc_fieldrWrWr]Ú!_get_arguments_for_make_dataclassÞs
 
 
 
 
    z3_AttributeOptions._get_arguments_for_make_dataclassN)rYrZr[Ú__doc__rir’Ú classmethodr™rWrWrWr]r‚ºs
    r‚Fc@s&eZdZUdZdZded<ded<dS)r–awmixin for descriptors or configurational objects that include dataclass
    field options.
 
    This includes :class:`.MapperProperty`, :class:`._MapsColumn` within
    the ORM, but also includes :class:`.AssociationProxy` within ext.
    Can in theory be used for other descriptors that serve a similar role
    as association proxy.   (*maybe* hybrids, not sure yet.)
 
    rWr‚r—reÚ_has_dataclass_argumentsN)rYrZr[ršr\rirWrWrWr]r–s
 
r–c@s8eZdZdZdZeddœdd„ƒZeddœdd    „ƒZd
S) Ú _MapsColumnszinterface for declarative-capable construct that delivers one or more
    Column objects to the declarative process to be part of a Table.
    rWzOptional[MapperProperty[_T]]rkcCs
tƒ‚dS)zAreturn a MapperProperty to be assigned to the declarative mappingN©rmrorWrWr]Úmapper_property_to_assign8sz&_MapsColumns.mapper_property_to_assignzList[Tuple[Column[_T], int]]cCs
tƒ‚dS)zfA list of Column objects that should be declaratively added to the
        new Table object.
 
        NržrorWrWr]Úcolumns_to_assign=sz_MapsColumns.columns_to_assignN)rYrZr[ršr\ÚpropertyrŸr rWrWrWr]r1s rc
@sreZdZUdZdZdejjfdejjfgZ    de
d<e s:dZ dZ d    e
d
<d e
d<d e
d<d Zde
d<de
d<de
d<ddœdd„Zdddddddœdd„Zdddd d dd!dd"œd#d$„ZdHd d%d&d'd(d)d*œd+d,„Zd ddd-œd.d/„Zd dd0œd1d2„ZdId3ddd4œd5d6„Zddœd7d8„Zed9dœd:d;„ƒZddœd<d=„Zd dd0œd>d?„Zd@d%d&d%d&ddAdBddCœ    dDdE„Zd dœdFdG„ZdS)JÚMapperPropertya Represent a particular class attribute mapped by :class:`_orm.Mapper`.
 
    The most common occurrences of :class:`.MapperProperty` are the
    mapped :class:`_schema.Column`, which is represented in a mapping as
    an instance of :class:`.ColumnProperty`,
    and a reference to another class produced by :func:`_orm.relationship`,
    represented in the mapping as an instance of
    :class:`.Relationship`.
 
    )Ú_configure_startedÚ_configure_finishedr—rœÚparentrxÚinfoÚdocr¥rxrPÚ_cache_key_traversalNTúPropComparator[_T]Ú
comparatorrbú Mapper[Any]FreZ_links_to_entityrrr§rNr¦rkcCsiS)aìInfo dictionary associated with the object, allowing user-defined
        data to be associated with this :class:`.InspectionAttr`.
 
        The dictionary is generated when first accessed.  Alternatively,
        it can be specified as a constructor argument to the
        :func:`.column_property`, :func:`_orm.relationship`, or
        :func:`.composite`
        functions.
 
        .. seealso::
 
            :attr:`.QueryableAttribute.info`
 
            :attr:`.SchemaItem.info`
 
        rWrorWrWr]Ú_memoized_attr_info¢sz"MapperProperty._memoized_attr_infor=r<rCúOptional[ORMAdapter]rrs©ÚcontextÚ query_entityÚpathÚadapterÚkwargsrlcKsdS)aCalled by Query for the purposes of constructing a SQL statement.
 
        Each MapperProperty associated with the target mapper processes the
        statement referenced by the query context, adding columns and/or
        criterion as appropriate.
 
        NrW)rpr¯r°r±r²r³rWrWr]ÚsetupµszMapperProperty.setupú Result[Any]rA©r¯r°r±ÚmapperÚresultr²Ú
populatorsrlcCsdS)zcProduce row processing functions and append to the given
        set of populators lists.
 
        NrW)rpr¯r°r±r·r¸r²r¹rWrWr]Úcreate_row_processorÅs
z#MapperProperty.create_row_processorzInstanceState[Any]r7zSet[InstanceState[Any]]z.Optional[Callable[[InstanceState[Any]], bool]]zGIterator[Tuple[object, Mapper[Any], InstanceState[Any], _InstanceDict]])Útype_ÚstateÚdict_Úvisited_statesÚhalt_onrlcCstdƒS)a–Iterate through instances related to the given instance for
        a particular 'cascade', starting with this MapperProperty.
 
        Return an iterator3-tuples (instance, mapper, state).
 
        Note that the 'cascade' collection on this MapperProperty is
        checked first for the given type before cascade_iterator is called.
 
        This method typically only applies to Relationship.
 
        rW)Úiter)rpr»r¼r½r¾r¿rWrWr]Úcascade_iteratorÔszMapperProperty.cascade_iterator)r¥r‹rlcCs
||_dS)z¹Set the parent mapper that references this MapperProperty.
 
        This method is overridden by some subclasses to perform extra
        setup when the mapper is first known.
 
        N)r¥)rpr¥r‹rWrWr]Ú
set_parentìszMapperProperty.set_parent©r·rlcCsdS)aIHook called by the Mapper to the property to initiate
        instrumentation of the class attribute managed by this
        MapperProperty.
 
        The MapperProperty here will typically call out to the
        attributes module to set up an InstrumentedAttribute.
 
        This step is the first of two steps to set up an InstrumentedAttribute,
        and is called early in the mapper setup process.
 
        The second step is typically the init_class_attribute step,
        called from StrategizedProperty via the post_instrument_class()
        hook.  This step assigns additional state to the InstrumentedAttribute
        (specifically the "impl") which has been determined after the
        MapperProperty has determined what kind of persistence
        management it needs to do (e.g. scalar, object, collection, etc).
 
        NrW©rpr·rWrWr]Úinstrument_classõszMapperProperty.instrument_classzOptional[_AttributeOptions])Úattribute_optionsÚ_assume_readonly_dc_attributesrlcCsDd|_d|_|rt}nt}|r4||kr4d|_||_n d|_||_dS)NFT)r£r¤Ú#_DEFAULT_READONLY_ATTRIBUTE_OPTIONSÚ_DEFAULT_ATTRIBUTE_OPTIONSrœr—)rprÆrÇZ default_attrsrWrWr]Ú__init__    s zMapperProperty.__init__cCsd|_| ¡d|_dS)z¦Called after all mappers are created to assemble
        relationships between mappers and perform other post-mapper-creation
        initialization steps.
 
 
        TN)r£Údo_initr¤rorWrWr]r‹szMapperProperty.initzInstrumentedAttribute[_T]cCst|jj|jƒS)a®Return the class-bound descriptor corresponding to this
        :class:`.MapperProperty`.
 
        This is basically a ``getattr()`` call::
 
            return getattr(self.parent.class_, self.key)
 
        I.e. if this :class:`.MapperProperty` were named ``addresses``,
        and the class to which it is mapped is ``User``, this sequence
        is possible::
 
            >>> from sqlalchemy import inspect
            >>> mapper = inspect(User)
            >>> addresses_property = mapper.attrs.addresses
            >>> addresses_property.class_attribute is User.addresses
            True
            >>> User.addresses.property is addresses_property
            True
 
 
        )Úgetattrr¥Úclass_rxrorWrWr]Úclass_attribute(szMapperProperty.class_attributecCsdS)zºPerform subclass-specific initialization post-mapper-creation
        steps.
 
        This is a template method called by the ``MapperProperty``
        object's init() method.
 
        NrWrorWrWr]rËBszMapperProperty.do_initcCsdS)aPerform instrumentation adjustments that need to occur
        after init() has completed.
 
        The given Mapper is the Mapper invoking the operation, which
        may not be the same Mapper as self.parent in an inheritance
        scenario; however, Mapper will always at least be a sub-mapper of
        self.parent.
 
        This method is typically used by StrategizedProperty, which delegates
        it to LoaderStrategy.init_class_attribute() to perform final setup
        on the class-bound InstrumentedAttribute.
 
        NrWrÄrWrWr]Úpost_instrument_classKsz$MapperProperty.post_instrument_classrEzDict[Any, object]z#Dict[_IdentityKeyType[Any], object])    ÚsessionÚ source_stateÚ source_dictÚ
dest_stateÚ    dest_dictÚloadÚ
_recursiveÚ_resolve_conflict_maprlc        CsdS)zoMerge the attribute represented by this ``MapperProperty``
        from source to destination object.
 
        NrW)    rprÐrÑrÒrÓrÔrÕrÖr×rWrWr]ÚmergeZs zMapperProperty.mergecCsd|jjt|ƒt|ddƒfS)Nz<%s at 0x%x; %s>rxzno key)rnrYÚidrÌrorWrWr]Ú__repr__js
 
ýzMapperProperty.__repr__)N)NF)rYrZr[ršr\r,ZExtendedInternalTraversalZdp_has_cache_keyZ    dp_stringr¨rirZcascadeZ is_propertyZ_is_relationshipr¬r´rºrÁrÂrÅrÊr‹r¡rÎrËrÏrØrÚrWrWrWr]r¢Os@
 
 
þ ú    ý     r¢c@sºeZdZUdZdZdZded<ded<ded    <dJd ddd œd d„Zej    d dœdd„ƒZ
ddœdd„Z dddœdd„Z dddœdd„Z ejddœd d!„ƒZdKd"dd#d$œd%d&„Zejd'dœd(d)„ƒZejd*dœd+d,„ƒZeddddd-œd.d/„ƒZeddddd0œd1d2„ƒZedddd3œd4d5„ƒZeejeƒZeejeƒZeejeƒZejrnd6ddd#d7œd8d9„Zd6ddd#d7œd:d;„Z d<dd=œd>d?„Z!d@dAdBœdCdD„Z"dLd"ddEd$œdFdG„Z#dMd"ddEd$œdHdI„Z$d
S)NÚPropComparatoraÊ Defines SQL operations for ORM mapped attributes.
 
    SQLAlchemy allows for operators to
    be redefined at both the Core and ORM level.  :class:`.PropComparator`
    is the base class of operator redefinition for ORM-level operations,
    including those of :class:`.ColumnProperty`,
    :class:`.Relationship`, and :class:`.Composite`.
 
    User-defined subclasses of :class:`.PropComparator` may be created. The
    built-in Python comparison and math operator methods, such as
    :meth:`.operators.ColumnOperators.__eq__`,
    :meth:`.operators.ColumnOperators.__lt__`, and
    :meth:`.operators.ColumnOperators.__add__`, can be overridden to provide
    new operator behavior. The custom :class:`.PropComparator` is passed to
    the :class:`.MapperProperty` instance via the ``comparator_factory``
    argument. In each case,
    the appropriate subclass of :class:`.PropComparator` should be used::
 
        # definition of custom PropComparator subclasses
 
        from sqlalchemy.orm.properties import \
                                ColumnProperty,\
                                Composite,\
                                Relationship
 
        class MyColumnComparator(ColumnProperty.Comparator):
            def __eq__(self, other):
                return self.__clause_element__() == other
 
        class MyRelationshipComparator(Relationship.Comparator):
            def any(self, expression):
                "define the 'any' operation"
                # ...
 
        class MyCompositeComparator(Composite.Comparator):
            def __gt__(self, other):
                "redefine the 'greater than' operation"
 
                return sql.and_(*[a>b for a, b in
                                  zip(self.__clause_element__().clauses,
                                      other.__composite_values__())])
 
 
        # application of custom PropComparator subclasses
 
        from sqlalchemy.orm import column_property, relationship, composite
        from sqlalchemy import Column, String
 
        class SomeMappedClass(Base):
            some_column = column_property(Column("some_column", String),
                                comparator_factory=MyColumnComparator)
 
            some_relationship = relationship(SomeOtherClass,
                                comparator_factory=MyRelationshipComparator)
 
            some_composite = composite(
                    Column("a", String), Column("b", String),
                    comparator_factory=MyCompositeComparator
                )
 
    Note that for column-level operator redefinition, it's usually
    simpler to define the operators at the Core level, using the
    :attr:`.TypeEngine.comparator_factory` attribute.  See
    :ref:`types_operators` for more detail.
 
    .. seealso::
 
        :class:`.ColumnProperty.Comparator`
 
        :class:`.Relationship.Comparator`
 
        :class:`.Composite.Comparator`
 
        :class:`.ColumnOperators`
 
        :ref:`types_operators`
 
        :attr:`.TypeEngine.comparator_factory`
 
    ©ÚpropÚ _parententityÚ_adapt_to_entityZorm_prop_comparatorz_InternalEntityType[Any]rÞzOptional[AliasedInsp[Any]]rßz)RODescriptorReference[MapperProperty[_T]]rÝNzMapperProperty[_T])rÝÚ parentmapperÚadapt_to_entitycCs||_|p ||_||_dS©NrÜ)rprÝràrárWrWr]rÊÌs
zPropComparator.__init__rkcCs|jS)zÜReturn the :class:`.MapperProperty` associated with this
        :class:`.PropComparator`.
 
 
        Return values here will commonly be instances of
        :class:`.ColumnProperty` or :class:`.Relationship`.
 
 
        )rÝrorWrWr]r¡Ös zPropComparator.propertyzroles.ColumnsClauseRolecCstd|ƒ‚dS)Nz%rržrorWrWr]Ú__clause_element__ãsz!PropComparator.__clause_element__rz(Sequence[Tuple[_DMLColumnArgument, Any]])ÚvaluerlcCstd| ¡ƒ|fgS)zËReceive a SQL expression that represents a value in the SET
        clause of an UPDATE statement.
 
        Return a tuple that can be passed to a :class:`_expression.Update`
        construct.
 
        rM)rrã)rprärWrWr]Ú_bulk_update_tuplesæs z"PropComparator._bulk_update_tupleszAliasedInsp[Any]r©)rárlcCs| |j|j|¡S)zŠReturn a copy of this PropComparator which will use the given
        :class:`.AliasedInsp` to produce corresponding expressions.
        )rnrÝrÞ)rprárWrWr]ráószPropComparator.adapt_to_entityr«cCs|jjS)zZlegacy; this is renamed to _parententity to be
        compatible with QueryableAttribute.)rÞr·rorWrWr]Ú _parentmapperûszPropComparator._parentmapperz)Optional[_ColumnExpressionArgument[bool]]zColumnElement[Any])Ú    criterionr³rlcKs|jjj|f|ŽSrâ)rÝrªÚ_criterion_exists©rprçr³rWrWr]rèsz PropComparator._criterion_existszOptional[_ORMAdapterProto]cCs|jdkrdS|jjSdS)zrProduce a callable that adapts column expressions
        to suit an aliased version of this comparator.
 
        N)rßZ_orm_adapt_elementrorWrWr]r²s
zPropComparator.adapterrNcCs|jjSrâ)rÝr¦rorWrWr]r¦szPropComparator.info)ÚaÚbr³rlcKs|j|f|ŽSrâ)Úany)rêrër³rWrWr]Ú_any_opszPropComparator._any_op)ÚleftÚotherr³rlcKs|j|f|ŽSrâ)Úhas)rîrïr³rWrWr]Ú_has_opszPropComparator._has_op)rêrÍrlcCs
| |¡Srâ)Úof_type)rêrÍrWrWr]Ú _of_type_opszPropComparator._of_type_oprO)Úoprïr³rlcOsdSrârW©rprôrïr³rWrWr]Úoperate)szPropComparator.operatecKsdSrârWrõrWrWr]Úreverse_operate.szPropComparator.reverse_operatez_EntityType[Any])rÍrlcCs| tj|¡S)ažRedefine this object in terms of a polymorphic subclass,
        :func:`_orm.with_polymorphic` construct, or :func:`_orm.aliased`
        construct.
 
        Returns a new PropComparator from which further criterion can be
        evaluated.
 
        e.g.::
 
            query.join(Company.employees.of_type(Engineer)).\
               filter(Engineer.name=='foo')
 
        :param \class_: a class or mapper indicating that criterion will be
            against this specific subclass.
 
        .. seealso::
 
            :ref:`orm_queryguide_joining_relationships_aliased` - in the
            :ref:`queryguide_toplevel`
 
            :ref:`inheritance_of_type`
 
        )rörÛÚ
of_type_op)rprÍrWrWr]rò3szPropComparator.of_typez_ColumnExpressionArgument[bool]zPropComparator[bool])ÚcriteriarlcGs|jtjf|žŽS)a?Add additional criteria to the ON clause that's represented by this
        relationship attribute.
 
        E.g.::
 
 
            stmt = select(User).join(
                User.addresses.and_(Address.email_address != 'foo')
            )
 
            stmt = select(User).options(
                joinedload(User.addresses.and_(Address.email_address != 'foo'))
            )
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :ref:`orm_queryguide_join_on_augmented`
 
            :ref:`loader_option_criteria`
 
            :func:`.with_loader_criteria`
 
        )rör*Úand_)rprùrWrWr]rúNszPropComparator.and_zColumnElement[bool]cKs|jtj|f|ŽS)aReturn a SQL expression representing true if this element
        references a member which meets the given criterion.
 
        The usual implementation of ``any()`` is
        :meth:`.Relationship.Comparator.any`.
 
        :param criterion: an optional ClauseElement formulated against the
          member class' table or attributes.
 
        :param \**kwargs: key/value pairs corresponding to member class
          attribute names which will be compared via equality to the
          corresponding values.
 
        )rörÛÚany_oprérWrWr]rìls ÿÿzPropComparator.anycKs|jtj|f|ŽS)aReturn a SQL expression representing true if this element
        references a member which meets the given criterion.
 
        The usual implementation of ``has()`` is
        :meth:`.Relationship.Comparator.has`.
 
        :param criterion: an optional ClauseElement formulated against the
          member class' table or attributes.
 
        :param \**kwargs: key/value pairs corresponding to member class
          attribute names which will be compared via equality to the
          corresponding values.
 
        )rörÛÚhas_oprérWrWr]rð„s ÿÿzPropComparator.has)N)N)N)N)%rYrZr[ršr\Z__visit_name__rirÊr)Znon_memoized_propertyr¡rãråráZro_non_memoized_propertyrærèr²r¦Ú staticmethodrírñrórr*rOrûrürøÚtypingrrör÷ròrúrìrðrWrWrWr]rÛrsN
Pü
  þ
    þþrÛc    @sþeZdZUdZdZdZded<ded<ded    <d
d œd d „Zdd œdd„Zddddœdd„Z    dddœdd„Z
dddddddœd d!„Z dddd"d#dd$dd%œd&d'„Z dd œd(d)„Z d"dd*œd+d,„Ze e¡Zd-ed.<edd/d0œd1d2„ƒZed3dd4d5œd6d7„ƒZd8S)9ÚStrategizedPropertyaŒA MapperProperty which uses selectable strategies to affect
    loading behavior.
 
    There is a single strategy selected by default.  Alternate
    strategies can be selected at Query time through the usage of
    ``StrategizedOption`` objects via the Query.options() method.
 
    The mechanics of StrategizedProperty are used for every Query
    invocation for every mapped attribute participating in that Query,
    to determine first how the attribute will be rendered in SQL
    and secondly how the attribute will retrieve a value from a result
    row and apply it to a mapped object.  The routines here are very
    performance-critical.
 
    )Ú _strategiesÚstrategyZ_wildcard_tokenÚ_default_path_loader_keyÚ strategy_keyTz ClassVar[str]Ústrategy_wildcard_keyÚ _StrategyKeyrz"Dict[_StrategyKey, LoaderStrategy]rz
Tuple[str]rkcCs|j›dtj›fS)Nú:)rrZ_WILDCARD_TOKENrorWrWr]Ú_memoized_attr__wildcard_token¼sÿz2StrategizedProperty._memoized_attr__wildcard_tokenzTuple[str, Tuple[str]]cCsd|j›dtj›ffS)NÚloaderr)rrZ_DEFAULT_TOKENrorWrWr]Ú'_memoized_attr__default_path_loader_keyÁsþz;StrategizedProperty._memoized_attr__default_path_loader_keyr=rCúOptional[_LoadElement])r¯r±rlcCs>d}||}|j|j|jfD]}||jkr|j|}q:q|Srâ)Z _loader_keyZ_wildcard_path_loader_keyrÚ
attributes)rpr¯r±rÕÚ search_pathZpath_keyrWrWr]Ú_get_context_loaderÉsý
 
    z'StrategizedProperty._get_context_loaderÚLoaderStrategy)rxrlcCsJz |j|WStk
r YnX|j|f|žŽ}|||ƒ|j|<}|Srâ)rÚKeyErrorÚ_strategy_lookup)rprxrvrrWrWr]Ú _get_strategyås z!StrategizedProperty._get_strategyr<r­rrsr®cKsD| ||¡}|r$|jr$| |j¡}n|j}|j|||||f|ŽdSrâ)r rrÚ setup_query)rpr¯r°r±r²r³rÚstratrWrWr]r´ós 
ÿÿzStrategizedProperty.setupr«rµrAr¶c
 
CsF| ||¡}|r$|jr$| |j¡}    n|j}    |     ||||||||¡dSrâ)r rrrº)
rpr¯r°r±r·r¸r²r¹rrrWrWr]rºs
 
øz(StrategizedProperty.create_row_processorcCsi|_| |j¡|_dSrâ)rrrrrorWrWr]rËszStrategizedProperty.do_initrÃcCs&|jjs"|j |j¡s"|j |¡dSrâ)r¥Z non_primaryZ class_managerZ_attr_has_implrxrÚinit_class_attributerÄrWrWr]rÏ"s
ÿ þz)StrategizedProperty.post_instrument_classz\collections.defaultdict[Type[MapperProperty[Any]], Dict[_StrategyKey, Type[LoaderStrategy]]]Ú_all_strategieszCallable[[_TLS], _TLS])r‘rlc sdddœ‡‡fdd„ }|S)NrT)Údec_clsrlcs>d|jkrg|_ttˆ ¡ƒƒ}|ˆjˆ|<|j |¡|S)NÚ_strategy_keys)Ú__dict__rÚtupleÚsortedÚitemsrÚappend)rrx©rvr‘rWr]Údecorate/s 
 z2StrategizedProperty.strategy_for.<locals>.decoraterW)rvr‘rrWrr]Ú strategy_for-s
z StrategizedProperty.strategy_forúMapperProperty[Any]rU)Úrequesting_propertyrxrlc        Gs¨|jj|jD]N}||jkrtr.t|tƒs.t‚|j|}z||WStk
rZYqXq|j     ¡D] \}}||krh|}||}q’qhd}d}t
  |||||¡‚dSrâ) r¥Z_with_polymorphic_mappersÚ__mro__rrÚ
issubclassr¢r˜rrÚorm_excZLoaderStrategyException)    rvr!rxZprop_clsZ
strategiesZ property_typeZstratsZintended_property_typeZactual_strategyrWrWr]r;s0
 
 
ûz$StrategizedProperty._strategy_lookupN)rYrZr[ršr\Z inherit_cacherirr    r rr´rºrËrÏÚ collectionsÚ defaultdictÚdictrr›rrrWrWrWr]rÿs(
    þ
 rÿc@sBeZdZdZdZdZdZdZdZdZ    dZ
dZ ddddœdd„Z dS)    Ú    ORMOptiona´Base class for option objects that are passed to ORM queries.
 
    These options may be consumed by :meth:`.Query.options`,
    :meth:`.Select.options`, or in a more general sense by any
    :meth:`.Executable.options` method.   They are interpreted at
    statement compile time or execution time in modern use.  The
    deprecated :class:`.MapperOption` is consumed at ORM query construction
    time.
 
    .. versionadded:: 1.4
 
    rWFr>)r¯Ú uncached_optrlcCs|dk    r |S|SdS)aÊadapt this option to the "uncached" version of itself in a
        loader strategy context.
 
        given "self" which is an option from a cached query, as well as the
        corresponding option from the uncached version of the same query,
        return the option we should use in a new query, in the context of a
        loader strategy being asked to load related rows on behalf of that
        cached query, which is assumed to be building a new query based on
        entities passed to us from the cached query.
 
        Currently this routine chooses between "self" and "uncached" without
        manufacturing anything new. If the option is itself a loader strategy
        option which has a path, that path needs to match to the entities being
        passed to us by the cached query, so the :class:`_orm.Load` subclass
        overrides this to return "self". For all other options, we return the
        uncached form which may have changing state, such as a
        with_loader_criteria() option which will very often have new state.
 
        This routine could in the future involve
        generating a new option based on both inputs if use cases arise,
        such as if with_loader_criteria() needed to match up to
        ``AliasedClass`` instances given in the parent query.
 
        However, longer term it might be better to restructure things such that
        ``AliasedClass`` entities are always matched up on their cache key,
        instead of identity, in things like paths and such, so that this whole
        issue of "the uncached option does not match the entities" goes away.
        However this would make ``PathRegistry`` more complicated and difficult
        to debug as well as potentially less performant in that it would be
        hashing enormous cache keys rather than a simple AliasedInsp. UNLESS,
        we could get cache keys overall to be reliably hashed into something
        like an md5 key.
 
        .. versionadded:: 1.4.41
 
        NrW)rpr¯r)rWrWr]Ú'_adapt_cached_option_to_uncached_option€s'z1ORMOption._adapt_cached_option_to_uncached_optionN) rYrZr[ršr\Ú_is_legacy_optionÚpropagate_to_loadersZ_is_coreÚ_is_user_definedÚ_is_compile_stateÚ_is_criteria_optionZ_is_strategy_optionr*rWrWrWr]r(]s r(c@s:eZdZdZdZdZdddœdd„Zdd    dd
œd d „Zd S)ÚCompileStateOptionaÎbase for :class:`.ORMOption` classes that affect the compilation of
    a SQL query and therefore need to be part of the cache key.
 
    .. note::  :class:`.CompileStateOption` is generally non-public and
       should not be used as a base class for user-defined options; instead,
       use :class:`.UserDefinedOption`, which is easier to use as it does not
       interact with ORM compilation internals or caching.
 
    :class:`.CompileStateOption` defines an internal attribute
    ``_is_compile_state=True`` which has the effect of the ORM compilation
    routines for SELECT and other statements will call upon these options when
    a SQL string is being compiled. As such, these classes implement
    :class:`.HasCacheKey` and need to provide robust ``_cache_key_traversal``
    structures.
 
    The :class:`.CompileStateOption` class is used to implement the ORM
    :class:`.LoaderOption` and :class:`.CriteriaOption` classes.
 
    .. versionadded:: 1.4.28
 
 
    rWTr=rs)Ú compile_staterlcCsdS)zòApply a modification to a given :class:`.ORMCompileState`.
 
        This method is part of the implementation of a particular
        :class:`.CompileStateOption` and is only invoked internally
        when an ORM query is compiled.
 
        NrW)rpr1rWrWr]Úprocess_compile_stateÉsz(CompileStateOption.process_compile_stateúSequence[_MapperEntity]©r1Úmapper_entitiesrlcCsdS)aqApply a modification to a given :class:`.ORMCompileState`,
        given entities that were replaced by with_only_columns() or
        with_entities().
 
        This method is part of the implementation of a particular
        :class:`.CompileStateOption` and is only invoked internally
        when an ORM query is compiled.
 
        .. versionadded:: 1.4.19
 
        NrW©rpr1r5rWrWr]Ú'process_compile_state_replaced_entitiesÒsz:CompileStateOption.process_compile_state_replaced_entitiesN)rYrZr[ršr\r.r2r7rWrWrWr]r0­s
    r0c@s&eZdZdZdZddddœdd„Zd    S)
Ú LoaderOptionzhDescribe a loader modification to an ORM statement at compilation time.
 
    .. versionadded:: 1.4
 
    rWr=r3rsr4cCs| |¡dSrâ)r2r6rWrWr]r7ísz4LoaderOption.process_compile_state_replaced_entitiesN)rYrZr[ršr\r7rWrWrWr]r8äsr8c@s(eZdZdZdZdZdddœdd„Zd    S)
ÚCriteriaOptionztDescribe a WHERE criteria modification to an ORM statement at
    compilation time.
 
    .. versionadded:: 1.4
 
    rWTzDict[str, Any]rs)r rlcCsdS)z_update additional entity criteria options in the given
        attributes dictionary.
 
        NrW)rpr rWrWr]Úget_global_criteriasz"CriteriaOption.get_global_criteriaN)rYrZr[ršr\r/r:rWrWrWr]r9õsr9c@s0eZdZdZdZdZdZdZd    ddœdd„ZdS)
ÚUserDefinedOptionz~Base class for a user-defined option that can be consumed from the
    :meth:`.SessionEvents.do_orm_execute` event hook.
 
    ©ÚpayloadFTNr“cCs
||_dSrâr<)rpr=rWrWr]rÊszUserDefinedOption.__init__)N)    rYrZr[ršr\r+r-r,rÊrWrWrWr]r;s r;z1.4aKThe :class:`.MapperOption class is deprecated and will be removed in a future release.   For modifications to queries on a per-execution basis, use the :class:`.UserDefinedOption` class to establish state within a :class:`.Query` or other Core statement, then use the :meth:`.SessionEvents.before_orm_execute` hook to consume them.)Ú constructorc@s<eZdZdZdZdZdZdddœdd    „Zdddœd
d „Zd S) Ú MapperOptionz"Describe a modification to a QueryrWTFz
Query[Any]rs)ÚqueryrlcCsdS)z8Apply a modification to the given :class:`_query.Query`.NrW©rpr@rWrWr]Ú process_query7szMapperOption.process_querycCs| |¡dS)aosame as process_query(), except that this option may not
        apply to the given query.
 
        This is typically applied during a lazy load or scalar refresh
        operation to propagate options stated in the original Query to the
        new Query being used for the load.  It occurs for those options that
        specify propagate_to_loaders=True.
 
        N)rBrArWrWr]Úprocess_query_conditionally:s z(MapperOption.process_query_conditionallyN)    rYrZr[ršr\r+r,rBrCrWrWrWr]r?s  r?c
@s„eZdZUdZdZded<dddœdd    „Zd
d d œd d„Zddddddd dœdd„Zddddd
dddd dœ    dd„Z    ddœdd „Z
d!S)"raÈDescribe the loading behavior of a StrategizedProperty object.
 
    The ``LoaderStrategy`` interacts with the querying process in three
    ways:
 
    * it controls the configuration of the ``InstrumentedAttribute``
      placed on a class to handle the behavior of the attribute.  this
      may involve setting up class-level callable functions to fire
      off a select operation when the attribute is first accessed
      (i.e. a lazy load)
 
    * it processes the ``QueryContext`` at statement construction time,
      where it can modify the SQL statement that is being produced.
      For example, simple column attributes will add their represented
      column to the list of selected columns, a joined eager loader
      may establish join clauses to add to the statement.
 
    * It produces "row processor" functions at result fetching time.
      These "row processor" functions populate a particular attribute
      on a particular mapped instance.
 
    )Úparent_propertyÚis_class_levelr¥rxrÚ strategy_optszClassVar[List[_StrategyKey]]rr r)r¥rcCs4||_d|_|jj|_|jj|_||_t|ƒ|_dS)NF)rDrEr¥rxrr'rF)rpr¥rrWrWr]rÊks 
 
zLoaderStrategy.__init__r«rsrÃcCsdSrârWrÄrWrWr]rusz#LoaderStrategy.init_class_attributer=r<rCr
r­r)r1r°r±Úloadoptr²r³rlcKsdS)zïEstablish column and other state for a given QueryContext.
 
        This method fulfills the contract specified by MapperProperty.setup().
 
        StrategizedProperty delegates its setup() method
        directly to this method.
 
        NrW)rpr1r°r±rGr²r³rWrWr]rxs    zLoaderStrategy.setup_queryrµrA)    r¯r°r±rGr·r¸r²r¹rlc        CsdS)aEstablish row processing functions for a given QueryContext.
 
        This method fulfills the contract specified by
        MapperProperty.create_row_processor().
 
        StrategizedProperty delegates its create_row_processor() method
        directly to this method.
 
        NrW)    rpr¯r°r±rGr·r¸r²r¹rWrWr]rºŠs z#LoaderStrategy.create_row_processorrbrkcCs
t|jƒSrâ)rbrDrorWrWr]Ú__str__ŸszLoaderStrategy.__str__N) rYrZr[ršr\rirÊrrrºrHrWrWrWr]rHs
    
r)ŒršÚ
__future__rr%rrþrrrrrrr    r
r r r rrrrrrrÚrr$rÚbaserrrrrrrrr r!r"r#r$r%r'rr(r)Zsqlr*r+r,Zsql.baser-r.Z sql.cache_keyr/Z sql.operatorsr0Z
sql.schemar1Z sql.type_apir2Z util.typingr3r4Ú_typingr5r6r7r8r9r r:r;r¯r<r=r>Zdecl_apir?Z    decl_baser@ZloadingrAr·rBrCr@rDrÐrEr¼rFZstrategy_optionsrGrHrIZ engine.resultrJZ sql._typingrKrLrMrNrOZ sql.visitorsrPrQrrRrTZ StatementRolerVZColumnsClauseRoleZTypedColumnsClauseRoler^r_ZStrictFromClauseRoler`rarjr‚rŽrÉrÈr–rZ_self_inspectsZ MemoizedSlotsr¢rÛrÿr(r0r8r9r;Zdeprecated_clsr?rrWrWrWr]Ú<module>s                                                                                  
ÿ
'Mú    ú
 
û$,AP7ø