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
U
¸ý°dã¶ã@s*ddlmZddlZddlmZddlmZddlmZddlmZddlmZddlm    Z    dd    lm
Z
dd
lm Z dd lm Z dd lm Z dd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z#dd lm$Z$dd!lm%Z%dd"lm&Z&dd#lmZdd$l&m'Z'dd%l&m(Z(dd&l&m)Z)dd#l&mZ*dd'l&m+Z+dd(l,m-Z-dd)l,m.Z.dd*l,m/Z/dd+l,m0Z0dd,l1m2Z2dd-l1m3Z3dd.l1m4Z4dd/l1m5Z5dd0l1m6Z6dd1l1m7Z7dd2l8m9Z9dd3l:m;Z;dd4l:m<Z<dd5l=m>Z>dd6l=m?Z?dd7l=m@Z@dd8l=mAZAdd9l=mBZBdd:l=mCZCdd;l=mDZDdd<lEmFZFe rªdd=lGmHZHdd>lGmIZIdd?lmJZJdd@lKmLZLddAlMmNZNddBlOmPZPddClOmQZQddDlRmSZSddElTmUZUddFl,mVZVddGlWmXZXddHl8mYZYddIl:mZZZddJl=m[Z[ddKl=m\Z\ddLl=m]Z]ddMl=m^Z^ddNl=m_Z_ddOl`maZaedPedQZbejcZde e¡ZfeBjgZgGdRdS„dSƒZhe edTdUi¡ZiGdVdW„dWe4ƒZjGdXdY„dYejƒZkGdZd[„d[ƒZle&jj4 md\d]¡Gd^d_„d_ekƒƒZnGd`da„dae;e6eDe-ƒZoe&jj4 md\db¡Gdcdd„ddekeCƒƒZpd‡dfdgdhdidjœdkdl„Zqdmdndoœdpdq„Zrdmdndoœdrds„Zsdˆdtdndudvœdwdx„ZtGdydz„dzƒZuGd{d|„d|euƒZvGd}d~„d~euƒZwGdd€„d€euƒZxGdd‚„d‚exƒZyGdƒd„„d„exƒZzGd…d†„d†ezƒZ{dS)‰é)Ú annotationsN)ÚAny)Úcast)ÚDict)ÚIterable)ÚList)ÚOptional)ÚSet)ÚTuple)ÚType)Ú TYPE_CHECKING)ÚTypeVar)ÚUnioné)Ú
attributes)Ú
interfaces)Úloading)Ú_is_aliased_class)ÚORMColumnDescription)ÚORMColumnsClauseRole)Ú PathRegistry)Ú_entity_corresponds_to)Ú_ORMJoin)Ú_TraceAdaptRole)Ú AliasedClass)ÚBundle)Ú
ORMAdapter)ÚORMStatementAdapteré)Úexc)Úfuture)Úinspect)Úsql)Úutil)Ú    coercions)Ú
expression)Úroles)Úvisitors)Ú_TP)Úis_dml)Úis_insert_update)Úis_select_base)Ú_select_iterables)ÚCacheableOptions)Ú CompileState)Ú
Executable)Ú
Generative)ÚOptions)Ú
UpdateBase)ÚGroupedElement)Ú
TextClause)ÚLABEL_STYLE_DISAMBIGUATE_ONLY)ÚLABEL_STYLE_NONE)ÚLABEL_STYLE_TABLENAME_PLUS_COL)ÚSelect)ÚSelectLabelStyle)Ú SelectState)ÚTypedReturnsRows)ÚInternalTraversal)Ú_InternalEntityType)ÚOrmExecuteOptionsParameter)ÚPostLoad)ÚMapper)ÚQuery)Ú_BindArguments)ÚSession)ÚResult)Ú_CoreSingleExecuteParams)Ú_ColumnsClauseArgument)Ú SQLCompiler)Ú_DMLTableElement)Ú ColumnElement)Ú_JoinTargetElement)Ú_LabelConventionCallable)Ú_SetupJoinsElement)ÚExecutableReturnsRows)Ú
SelectBase)Ú
TypeEngineÚ_T)Úboundc    @sdeZdZUdZded<ded<ded<Gdd    „d    eƒZdd d d dddddœdd„Zddœdd„Zd
S)Ú QueryContext)Útop_level_contextÚ compile_stateÚqueryÚparamsÚ load_optionsÚbind_argumentsÚexecution_optionsÚsessionÚ    autoflushÚpopulate_existingÚinvoke_all_eagersÚ version_checkÚ refresh_stateÚcreate_eager_joinsÚpropagated_loader_optionsrÚrunidZpartialsÚpost_load_pathsÚidentity_tokenÚ    yield_perÚloaders_require_bufferingÚloaders_require_uniquingÚintrbzDict[PathRegistry, PostLoad]rcÚORMCompileStaterTc@s<eZdZdZdZdZdZdZdZdZ    dZ
dZ dZ dZ dZdS)z!QueryContext.default_load_optionsFTN)Ú__name__Ú
__module__Ú __qualname__Z_only_return_tuplesÚ_populate_existingÚ_version_checkÚ_invoke_all_eagersÚ
_autoflushÚ_identity_tokenÚ
_yield_perÚ_refresh_stateZ_lazy_loaded_fromZ_legacy_uniquingÚ_sa_top_level_orm_contextZ_is_user_refresh©ruruúMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/orm/context.pyÚdefault_load_options„srwNr.ú&Union[Select[Any], FromStatement[Any]]rErCzQUnion[Type[QueryContext.default_load_options], QueryContext.default_load_options]z$Optional[OrmExecuteOptionsParameter]zOptional[_BindArguments])rTÚ    statementrVrZrWrYrXc
sº|ˆ_|p tˆ_|ptˆ_|ˆ_|ˆ_|ˆ_dˆ_dˆ_|ˆ_    |j
ˆ_ |j j }|j }    t‡fdd„t||    ƒDƒƒˆ_t|jƒˆ_|jˆ_|jˆ_|jˆ_|jˆ_|jˆ_|jˆ_|jˆ_ dS)NFc3s$|]\}}|jr| ˆ|¡VqdS©N)Zpropagate_to_loadersZ'_adapt_cached_option_to_uncached_option)Ú.0ÚoptZ uncached_opt©ÚselfrurvÚ    <genexpr>¸sþz(QueryContext.__init__.<locals>.<genexpr>)!rWÚ _EMPTY_DICTrYrXrTrUrZrfrgrVrtrSÚselect_statementÚ _with_optionsÚtupleÚzipraÚdictrrpr[rmr\ror]rnr^rsr_rrrerqrd)
r~rTryrVrZrWrYrXZcached_optionsZuncached_optionsrur}rvÚ__init__’s. 
 
 þ
 zQueryContext.__init__©ÚreturncCs
|jp|Srz)rSr}rururvÚ_get_top_level_contextÈsz#QueryContext._get_top_level_context)NN)    rjrkrlÚ    __slots__Ú__annotations__r1rwr†r‰rurururvrRes
õ6rRZ _result_disable_adapt_to_contextTcsbeZdZdZdd„Zedddddœ‡fdd    „ ƒZed
d „ƒZed d œdd„ƒZedd„ƒZ    ‡Z
S)ÚAbstractORMCompileStateFc    CsÊi|_|dkr$i|_}|s t‚dS|j|_}|r`d|d<|r\|jD]}|jrF| |¡qFdS| dd¡rpdS|jd}z |d}Wnt    k
ršYn$X|jD]}|j
r¢|jr¢| |¡q¢d|d<dS)NTZ toplevel_ormFrÚ
selectable) rÚglobal_attributesÚAssertionErrorZ_global_attributesr‚Z_is_criteria_optionÚprocess_compile_stateÚgetÚstackÚKeyErrorÚ_is_compile_state)    r~ryÚcompilerÚtoplevelÚprocess_criteria_for_toplevelÚgar|Zstack_0Z toplevel_stmtrururvÚ_init_global_attributesÔs0
 
 
 
  z/AbstractORMCompileState._init_global_attributesúUnion[Select, FromStatement]úOptional[SQLCompiler]r©ryr•Úkwrˆc stƒj||f|ŽS)aÇCreate a context for a statement given a :class:`.Compiler`.
 
        This method is always invoked in the context of SQLCompiler.process().
 
        For a Select object, this would be invoked from
        SQLCompiler.visit_select(). For the special FromStatement object used
        by Query to indicate "Query.from_statement()", this is called by
        FromStatement._compiler_dispatch() that would be called by
        SQLCompiler.process().
        )ÚsuperÚcreate_for_statement©Úclsryr•r©Ú    __class__rurvrŸûsz,AbstractORMCompileState.create_for_statementcCs
tƒ‚dSrz©ÚNotImplementedError)r¡rZryrVrYrXÚ is_pre_eventrururvÚorm_pre_session_execs
z,AbstractORMCompileState.orm_pre_session_execrDr‡cCs(|j||p i|d}| ||||||¡S)N)rY)ÚexecuteÚorm_setup_cursor_result)r¡rZryrVrYrXÚconnÚresultrururvÚorm_execute_statements
ÿúz-AbstractORMCompileState.orm_execute_statementcCs
tƒ‚dSrzr¤)r¡rZryrVrYrXr«rururvr©0s
z/AbstractORMCompileState.orm_setup_cursor_result) rjrkrlÚis_dml_returningr™Ú classmethodrŸr§r¬r©Ú __classcell__rurur¢rvrŒÑs'
rŒc@s,eZdZUGdd„deƒZded<ded<ded<ded<d    ed
<d ed <d ed<ded<ded<ded<ded<ded<ded<ded<eZded<dZdd „Z    e
r¾e d!d"d#dd$œd%d&„ƒZ d'd(„Z e d)ddd*œd+d,„ƒZe d-d.„ƒZe d/d0„ƒZe d1d2„ƒZed3d4„ƒZd5d6„Zd7d8„Ze d9d:„ƒZd;S)<ric @s”eZdZdejfdejfdejfdejfdejfdejfdejfdejfd    ejfd
ejfd ejfg Zd Zd Z    d Z
e Z d Z d ZdZd Zd Zd Zd ZdS)z'ORMCompileState.default_compile_optionsÚ_use_legacy_query_styleÚ_for_statementÚ_bake_okÚ _current_pathÚ_enable_single_critÚ_enable_eagerloadsÚ_only_load_propsÚ_set_base_aliasÚ_for_refresh_stateÚ_render_for_subqueryÚ_is_starFTN)rjrkrlr<Z
dp_booleanÚdp_has_cache_keyZ dp_plain_objÚ_cache_key_traversalr°r±r²Ú_path_registryr³r´rµr¶r·r¸r¹rºrurururvÚdefault_compile_options>s.õr¾zDict[Any, Any]rrŽrxryrúList[_QueryEntity]Ú    _entitiesz%Dict[_InternalEntityType, ORMAdapter]Ú_polymorphic_adaptersz=Union[Type[default_compile_options], default_compile_options]Úcompile_optionszOptional[_QueryEntity]Ú_primary_entityÚboolÚuse_legacy_query_stylerKÚ_label_conventionzList[ColumnElement[Any]]Úprimary_columnsÚsecondary_columnszSet[ColumnElement[Any]]Údedupe_columnszList[Tuple[Any, ...]]r`rÚ current_pathFcOs
tƒ‚dSrzr¤)r~Úargrrururvr†zszORMCompileState.__init__ršr›rrœcKsdSrzrur rururvrŸsz$ORMCompileState.create_for_statementcCs&|j}||kr"| |¡| |¡dSrz)rÉÚaddÚappend)r~ÚobjZcol_collectionZdeduperururvÚ_append_dedupe_col_collectionˆs
z-ORMCompileState._append_dedupe_col_collectionr9)Ú label_styleÚlegacyrˆcCs |rddd„}|St |¡SdS)NcSs|r|St|dƒSdS)NÚkey)Úgetattr)ÚcolÚcol_namerururvÚname•sz7ORMCompileState._column_naming_convention.<locals>.name)N)r:Ú_column_naming_convention)r¡rÐrÑrÖrururvr׎s
z)ORMCompileState._column_naming_conventioncCst|ƒSrz)Ú_column_descriptions©r¡ryrururvÚget_column_descriptionsŸsz'ORMCompileState.get_column_descriptionsc    Csòtj ddddddh||j¡\}}|s,t}n
| t¡}|jrL| d|ji¡}t|jddƒr’t    |jj
ƒdkr’|  d    d
¡dk    r’t   d ¡| d    di¡}||d <z|jd }Wn tk
rÈdsÄtdƒ‚YnX|rØ|j|d<|sê|jrê| ¡||fS)NÚ_sa_orm_load_optionsr\r[rerdZsa_top_level_orm_contextr³é
Zcompiled_cacheTz³Loader depth for query is excessively deep; caching will be disabled for additional loaders.  Consider using the recursion_depth feature for deeply nested recursive eager loaders.ÚclauseÚplugin_subjectFz0statement had 'orm' plugin but no plugin_subjectÚmapper)rRrwZfrom_execution_optionsÚ_execution_optionsÚ_orm_load_exec_optionsÚunionrrrÓÚ_compile_optionsÚlenr³r‘r#ÚwarnÚ_propagate_attrsr“rrßrp)    r¡rZryrVrYrXr¦rWrÞrururvr§£sVûöý
ÿ ÿþýÿÿ 
 
z$ORMCompileState.orm_pre_session_execc CsH|j}|jj}| dtj¡}    |jjr(|St|||||    ||ƒ}
t     ||
¡S)NrÛ)
ÚcontextZcompiledrTr‘rRrwrÂrºrZ    instances) r¡rZryrVrYrXr«Zexecution_contextrTrWZ querycontextrururvr©÷s$
ÿù    z'ORMCompileState.orm_setup_cursor_resultcCsdd„|jDƒS)zºreturn all _MapperEntity objects in the lead entities collection.
 
        Does **not** include entities that have been replaced by
        with_entities(), with_only_columns()
 
        cSsg|]}t|tƒr|‘qSru©Ú
isinstanceÚ _MapperEntity©r{ÚentrururvÚ
<listcomp>#s
z9ORMCompileState._lead_mapper_entities.<locals>.<listcomp>)rÀr}rururvÚ_lead_mapper_entitiessÿz%ORMCompileState._lead_mapper_entitiesc
CsD|js@|jj|jkr@|j ¡D] }| |ttj||j    |d¡qdS)a5given MapperEntity or ORMColumnEntity, setup polymorphic loading
        if called for by the Mapper.
 
        As of #8168 in 2.0.0rc1, polymorphic adapters, which greatly increase
        the complexity of the query creation process, are not used at all
        except in the quasi-legacy cases of with_polymorphic referring to an
        alias and/or subquery. This would apply to concrete polymorphic
        loading, and joined inheritance where a subquery is
        passed to with_polymorphic (which is completely unnecessary in modern
        use).
 
        )Ú equivalentsrN)
Úis_aliased_classrßÚpersist_selectablerÁÚiterate_to_rootÚ"_mapper_loads_polymorphically_withrrZWITH_POLYMORPHIC_ADAPTERÚ_equivalent_columns)r~Úext_inforÚmprururvÚ _create_with_polymorphic_adapter's ÿÿþüþz0ORMCompileState._create_with_polymorphic_adaptercCs:|jp
|gD](}||j|<| ¡D]}||j|j<q"q dSrz)Ú_with_polymorphic_mappersrÁròÚ local_table)r~rßÚadapterÚm2ÚmrururvróDs
 z2ORMCompileState._mapper_loads_polymorphically_withcCs tdƒ‚dS)Nz0this method only works for ORMSelectCompileStater¤)r¡rUrÑrururvÚ_create_entities_collectionKsÿz+ORMCompileState._create_entities_collectionN)rjrkrlr-r¾r‹r½rÊÚ_has_mapper_entitiesr†r r®rŸrÏr×rÚr§r©Úpropertyrîr÷rórýrurururvri=sH
% 
 
S
#
ric@s,eZdZdZdZdd„Zdd„Zdd„Zd    S)
ÚDMLReturningColFilterzðan adapter used for the DML RETURNING case.
 
    Has a subset of the interface used by
    :class:`.ORMAdapter` and is used for :class:`._QueryEntity`
    instances to set up their columns as used in RETURNING for a
    DML statement.
 
    )rßÚcolumnsÚ __weakref__cCs:|dk    r|j|jk    r||_n||_t |j¡|_|_dSrz)rùrßr#ZWeakPopulateDictÚadapt_check_presentr)r~Ú target_mapperZimmediate_dml_mapperrururvr†^sÿÿþÿzDMLReturningColFilter.__init__cCs.t |¡D]}| |¡}|dk    r
|Sq
dSrz)Úsql_utilZ _find_columnsr)r~rÔÚ    as_filterÚccÚc2rururvÚ__call__ms
 
 
zDMLReturningColFilter.__call__cCs.|j}|j |d¡}|dkr dS|jj |¡Srz)rßZ_columntopropertyr‘rùÚcZcorresponding_column)r~rÔrßÚproprururvrus
z)DMLReturningColFilter.adapt_check_presentN)rjrkrlÚ__doc__rŠr†r    rrurururvrRs
    rZormÚorm_from_statementc@szeZdZUdZdZded<ded<dZded<dZdZdZ    dZ
e Z e Z ed    d
d dd œd d„ƒZdd„Zdd„Zdd„ZdS)ÚORMFromStatementCompileStateNFÚ FromStatementÚstatement_containerz)Union[SelectBase, TextClause, UpdateBase]Úrequested_statementzOptional[_DMLTableElement]Ú    dml_tableršr›r)rr•rrˆc Ksüt|tƒst‚|dk    r&|jr&t d¡‚| |¡}d|_|jj    |_
||_ |_ |j |_}|jrl|j|_d|_g|_i|_|j|_|j
r¶t|tjƒr¶|js¶|js¶|jtkr¶| t¡|_n||_| |jsÒ|jsÒ|jnt|j
¡|_t j!||j"|jdd|jj#|_$|j%||ddd|j&r8|j&D]}|j'r| (|¡q|j)rZ|j)D]\}}||ƒqFg|_*g|_+t,ƒ|_-g|_.g|_/d|_0t|jtj1ƒrâi|_2|jD]}    |     3|¡qœd|_4|_5d|_6|j*D]}
|j7|
d|j8dqÆnt9t:j;|j|j<d|_=|S)NzšThe ORM FromStatement construct only supports being invoked as the topmost statement, as it is only intended to define how result rows should be returned.T©Úis_current_entitiesF)r—r–)Zwithin_columns_clauseZadd_to_result_map)Zadapt_on_names)>rérrr’Úsa_excÚ CompileErrorÚ__new__rÃrãr°rÅrrÚelementrr)Útablerr­rÀrÁrÂr%rNZ _is_textualÚ _label_styler6Zset_label_styler7ryr×rÆÚ _QueryEntityÚto_compile_stateÚ _raw_columnsr³rÊr™r‚r”rÚ_with_context_optionsrÇrÈÚsetrÉr`Ú_fallback_from_clausesÚorder_byr4Úextra_criteria_entitiesÚsetup_compile_stateZ_ordered_columnsZ_textual_ordered_columnsZ_loose_column_name_matchingÚprocessZ_add_to_result_maprrZADAPT_FROM_STATEMENTÚ_adapt_on_namesÚ_from_obj_alias) r¡rr•rr~ryr|ÚfnrÒÚentityr
rururvrŸŽsªÿ
ÿ  ÿ
þýüûÿÿÿüü
ü
 
þ
ý ýz1ORMFromStatementCompileState.create_for_statementcCs|Srzru©r~ÚcolsÚcurrent_adapterrururvÚ_adapt_col_listsz,ORMFromStatementCompileState._adapt_col_listcCsdSrzrur}rururvÚ_get_current_adaptersz1ORMFromStatementCompileState._get_current_adaptercCs6|jj dd¡}t||ƒ}|jD]}| ||¡q dS)z†used by BulkORMInsert (and Update / Delete?) to set up a handler
        for RETURNING to return ORM objects and expressions
 
        rÞN)ryrær‘rrÀÚ!setup_dml_returning_compile_state)r~Z
dml_mapperrrúr(rururvr.sÿ
 
z>ORMFromStatementCompileState.setup_dml_returning_compile_state)rjrkrlr&rþr‹rÚ_has_orm_entitiesÚmulti_row_eager_loadersÚeager_adding_joinsÚcompound_eager_adapterr€r"Ú eager_joinsr®rŸr,r-r.rurururvr}s"
 rcsÐeZdZUdZdZejZejZ    dZ
de d<de d<de j fde jfgejZed    e jfgZdd ddd œd d„Zdd„Zedd„ƒZdd„Z‡fdd„Zedd„ƒZedd„ƒZedd„ƒZedd„ƒZ‡ZS) ra*Core construct that represents a load of ORM objects from various
    :class:`.ReturnsRows` and other classes including:
 
    :class:`.Select`, :class:`.TextClause`, :class:`.TextualSelect`,
    :class:`.CompoundSelect`, :class`.Insert`, :class:`.Update`,
    and in theory, :class:`.Delete`.
 
    r Nz(Union[ExecutableReturnsRows, TextClause]rrÄr%rrãTz%Iterable[_ColumnsClauseArgument[Any]])Úentitiesrr%csF‡fdd„t |¡Dƒˆ_|ˆ_|jˆ_t|ƒr6|jndˆ_|ˆ_dS)Ncs g|]}tjtj|ˆdd‘qS)T)Úapply_propagate_attrsZ post_inspect)r$Úexpectr&ZColumnsClauseRolerër}rurvríGsúüz*FromStatement.__init__.<locals>.<listcomp>)r#Zto_listrrr)r+rr%)r~r4rr%rur}rvr†As
ù    ÿzFromStatement.__init__cKs2|j||f|Ž}|j }|r"||_|j|jf|ŽS)z›provide a fixed _compiler_dispatch method.
 
        This is roughly similar to using the sqlalchemy.ext.compiler
        ``@compiles`` extension.
 
        )Ú_compile_state_factoryr’rTr$ry)r~r•rrTr–rururvÚ_compiler_dispatchWs
    z FromStatement._compiler_dispatchcCsttt |¡ƒj}||ƒS)a@Return a :term:`plugin-enabled` 'column descriptions' structure
        referring to the columns which are SELECTed by this statement.
 
        See the section :ref:`queryguide_inspection` for an overview
        of this feature.
 
        .. seealso::
 
            :ref:`queryguide_inspection` - ORM background
 
        )rÚORMSelectCompileStater:Zget_plugin_classrÚ)r~ÚmethrururvÚcolumn_descriptionsis
ÿz!FromStatement.column_descriptionscCs|Srzrur}rururvÚ_ensure_disambiguated_names{sz)FromStatement._ensure_disambiguated_namesc+s6tj dd„|jDƒ¡EdHtƒjf|ŽEdHdS)Ncss|] }|jVqdSrz)Ú _from_objects©r{rrururvrsz-FromStatement.get_children.<locals>.<genexpr>)Ú    itertoolsÚchainÚ from_iterablerržÚ get_children)r~rr¢rurvrB~s ÿzFromStatement.get_childrencCs|jjSrz)rÚ_all_selected_columnsr}rururvrC„sz#FromStatement._all_selected_columnscCst|jƒr|jjSdSrz)r)rÚ_return_defaultsr}rururvrDˆszFromStatement._return_defaultscCst|jƒr|jjSdSrz)r)rÚ
_returningr}rururvrEŒszFromStatement._returningcCst|jƒr|jjSdSrz)r*rÚ_inliner}rururvrFszFromStatement._inline)T)rjrkrlr Z__visit_name__rr¾rãrŸr7Ú_for_update_argr‹r<Zdp_clauseelement_listZdp_clauseelementr/Z_executable_traverse_internalsZ_traverse_internalsr»r¼r†r8rÿr;r<rBrCrDrErFr¯rurur¢rvr"s<
    þýÿü
 
 
 
rÚselectc@sZeZdZdZeZdZdZdZdZ    dZ
dZ dZ dZ dZdZedddddœdd    „ƒZd
d „Zd d „Zedd„ƒZedd„ƒZedd„ƒZedd„ƒZedd„ƒZdd„Zdd„Zdd„Zdd„Zd d!„ZdDd"d#„Zd$d%„Zd&d'„Z d(d)„Z!d*d+„Z"d,d-„Z#d.d/„Z$d0d1„Z%d2d3„Z&d4d5„Z'd6d7„Z(d8d9„Z)d:d;„Z*e+d<d=„ƒZ,e+d>d?„ƒZ-d@dA„Z.dBdC„Z/dS)Er9ruNFršr›rrœc
 s4| |¡‰|dk    r|j }nd}|}|j |j¡|_|jrR| ¡ˆ_t     ¡ˆj_n|ˆ_|jj
ˆ_ |jj ˆ_ gˆ_dˆ_iˆ_|jˆ_|sžˆjdddœ7_ˆj rƈjjtkrƈj s¾tˆ_qÐtˆ_n
ˆjjˆ_|jrì‡fdd„|jDƒˆ_ˆ |jˆj ¡ˆ_tjˆ|jˆjdd|jjˆ_dˆ_ ˆj!|||dd    |r®|j"sL|jr®|jD]8}|j"D]*}|j#r\| $ˆd
d „ˆj|Dƒ¡q\qRˆjj"D]}|j#r”| %ˆ¡q”|j&rÐ|j&D]\}}    |ˆƒq¼gˆ_'gˆ_(t)ƒˆ_*iˆ_+iˆ_,gˆ_-gˆ_.ˆ /d d „|j0Dƒ¡ˆ_1ˆ 2¡t3j4ˆˆj5|f|ŽˆS)z@compiler hook, we arrive here from compiler.visit_select() only.NTF)rµr¹c    s"i|]}|tjˆ|jgdd“qS)Fr)rrr)r{Úmemoized_entitiesr}rurvÚ
<dictcomp>ïsúüz>ORMSelectCompileState.create_for_statement.<locals>.<dictcomp>rru)r–r—cSsg|]}t|tƒr|‘qSrurèrërururvrí!s
üz>ORMSelectCompileState.create_for_statement.<locals>.<listcomp>css|] }|jVqdSrz)r)r{ÚinforururvrDsz=ORMSelectCompileState.create_for_statement.<locals>.<genexpr>)6rr’r¾Z
safe_mergerãràZ_clonerr#Ú immutabledictr±Ú for_statementr°rÅrÀrÃrÁrÂrÚLABEL_STYLE_LEGACY_ORMr7rÐr5Ú_memoized_select_entitiesÚ_memoized_entitiesr×rÆrrrr³rÊÚeager_order_byr™r‚r”Z'process_compile_state_replaced_entitiesrrrÇrÈrrÉr3r"r`r Ú_normalize_fromsÚ    _from_objÚ from_clausesÚ_setup_for_generater:r†ry)
r¡ryr•rr–rrIr|r'rÒrur}rvrŸ¨s¶    
 
ÿ
 
ÿþ
 
ÿ
þ
 
øÿü
üÿþþ
ÿþþ  
ÿ
z*ORMSelectCompileState.create_for_statementcCsÄtdƒtd|j›ƒ|jD] }t|tƒr||ddkr|tdt |d¡›ƒtd|j|›ƒtd|j|j›ƒqt|tƒr|ddkrtd    t |d¡›ƒtd|j|›ƒqdS)
Nz5
---------------------------------------------------
zcurrent path: rÚloaderz
Loader:           rz    Zpath_with_polymorphicz
With Polymorphic: )ÚprintrÊrrérƒrZcoerceÚ__dict__)r~rÒrururvÚ_dump_option_structPs
z)ORMSelectCompileState._dump_option_structcsÞ|j}d|_d|_|jjr"| ¡|jD]}|jr(| |j|j    |¡q(|jr^| |j|j
¡|  ¡‰|j r’|j |_ ˆr’t ‡fdd„|j Dƒƒ|_ ˆr®|jdkr®| |jˆ¡n|j|_|jrÖt ‡fdd„|jDƒƒ|_ˆrø|jdkrø| t |j¡ˆ¡n
|jpd|_|jr(|jdj}| |j¡|_|jrB| |jˆ¡|_nd|_|j|_|jrvt t dd„|jDƒ¡ƒ|_n8|j dk    r t t dd„|j Dƒ¡ƒ|_!n|j"s®d    |_|j#|_#|jj$rÚt%|j
ƒd
krÚt& 'd ¡‚|j
D]}| (|¡qà|j)D]$}|d}||f|d
d…žŽqø|jj*r0| +¡|j,sZ|jj-rPd sPt.d ƒ‚t& /d¡‚|jsnt0|j1ƒ|_|jd kr€d|_|j2r¤|j3r¤|j4r¤| 5¡|_n
| 6¡|_|j7rÚ| 8¡}|dk    rÚ|j 9d|i¡|_dS)Nruc3s|]}ˆ|dƒVqdS©TNru©r{Úcrit©r+rurvrvsÿz<ORMSelectCompileState._setup_for_generate.<locals>.<genexpr>©NFc3s |]}ˆrˆ|dƒn|VqdSrZrur[r]rurvr…sÿrcss$|]}|dk    rt |¡ndVqdSrz©rZsurface_selectables©r{Úsrururvr¤sÿcss$|]}|dk    rt |¡ndVqdSrzr_r`rururvr«sÿrzrzsCan't generate ORM query that includes multiple expressions at the same time as '*'; query for '*' alone if presentFz,no columns were included in _only_load_propsz4Query contains no columns with which to SELECT from.Z
deepentity):rryÚ_join_entitiesrÂr·Ú_set_select_from_aliasrOÚ _setup_joinsÚ_joinrPrÀr-Ú_where_criteriarƒÚ_order_by_clausesr,r!Ú_having_criteriaÚ_group_by_clausesr#Zflatten_iteratorÚgroup_byrQrTZ_target_adapterÚcopy_and_processZ _distinct_onÚ distinct_onZ    _distinctÚdistinctZ
_correlateÚ    correlateZ_correlate_exceptÚcorrelate_exceptZ_auto_correlaterGrºrärrr#r`r´Ú_adjust_for_extra_criteriarÇr¶rÚInvalidRequestErrorÚlistr r0r1Ú_should_nest_selectableÚ_compound_eager_statementÚ_simple_statementrMÚ _mapper_zeroZ    _annotate)r~rUrIrúr(ZrecZstrategyÚezerorur]rvrU\sÆ
þ þ
 
ÿÿý þ
    ýý
ÿ
û ÿ
þÿ 
þÿÿ
 
 
 
ÿ  ÿþý 
 
ÿz)ORMSelectCompileState._setup_for_generatecCsF| |¡}g|_d|_i|_| |j|¡|_tj||j    |jdd|S)aCreates a partial ORMSelectCompileState that includes
        the full collection of _MapperEntity and other _QueryEntity objects.
 
        Supports a few remaining use cases that are pre-compilation
        but still need to gather some of the column  / adaption information.
 
        NTr)
rrÀrÃrÁr×rrÆrrr)r¡rUrÑr~rururvrýés    
ÿÿz1ORMSelectCompileState._create_entities_collectioncCs|j}t|dƒSrz)rdÚ_determine_last_joined_entity)r¡ryÚ setup_joinsrururvÚdetermine_last_joined_entitysz2ORMSelectCompileState.determine_last_joined_entityccsj|jD]^}|jrTd|jkrT|jd}|jsB|jsBt|gƒEdHqdt|jƒEdHqt|gƒEdHqdS)NZentity_namespace)rÚ is_selectableÚ _annotationsZ    is_mapperrðr,Z_all_column_expressions)r¡ryrZensrururvÚall_selected_columns    s
ÿþ
 z*ORMSelectCompileState.all_selected_columnscCs| tj dd„|jDƒ¡¡S)Ncss.|]&}d|jkr|jn|jd ¡gVqdS)Ú parententityN)r|r=Ú__clause_element__r>rururvrs
üÿ ÿzAORMSelectCompileState.get_columns_clause_froms.<locals>.<genexpr>)rRr?r@rArrÙrururvÚget_columns_clause_fromss
 úÿz.ORMSelectCompileState.get_columns_clause_fromscCs>tjtj||d}t|j|ƒ}|jj|j|j    |j
|j d|S)N)r5)r‚rràræ) r$r6r&ZReturnsRowsRolerrrXÚupdater‚rràræ)r¡ryÚfrom_statementZstmtrururvr‚%sý üz$ORMSelectCompileState.from_statementcCsT|j}|jjst‚t|jƒdks$t‚| |jd¡}|rP|jddi7_||_dS)ú used only for legacy Query casesrrr´FN)rrÂr·rrärSÚ_get_select_from_alias_from_objr&)r~rUrúrururvrc8s z,ORMSelectCompileState._set_select_from_aliascCs||}d|jkr|jd}t|dƒr<|js4t d¡‚qx|jSn<t|jtjj    ƒrt| 
¡}||jksbt ‚t t j|j|dSdSdS)rƒr~rßzPA selectable (FromClause) instance is expected when the base alias is being set.©rïN)r|ÚhasattrrðrÚ ArgumentErrorÚ_adapterrérr"ZAliasedReturnsRowsÚ _all_equivsrrrZLEGACY_SELECT_FROM_ALIAS)r~Úfrom_objrKÚequivsrururvr„Es$
 
 
ÿýz5ORMSelectCompileState._get_select_from_alias_from_objcCs |jdjS)z8return the Mapper associated with the first QueryEntity.r)rÀrßr}rururvrvasz"ORMSelectCompileState._mapper_zerocCsD|jD]}d|jkr|jdSq|jD]}|jr*|jSq*dS)z›Return the 'entity' (mapper or AliasedClass) associated
        with the first QueryEntity, or alternatively the 'select from'
        entity if specified.r~N)rTr|rÀÚ entity_zero)r~rìZqentrururvÚ _entity_zeroes
 
 
 z"ORMSelectCompileState._entity_zerocCs$|j|jgkrt d|¡‚|jjS)Nz4%s() can only be used against a single mapped class.)rÀrÃrrqrŒ)r~ZmethnamerururvÚ_only_full_mapper_zerossÿÿz,ORMSelectCompileState._only_full_mapper_zerocCs$t|jƒdkrt |pd¡‚| ¡S)Nrz8This operation requires a Query against a single mapper.)rärÀrrqr)r~Z    rationalerururvÚ_only_entity_zero{s þz'ORMSelectCompileState._only_entity_zerocCs^i}|j ¡D]&}dd„|DƒD]}| |jj¡q qdd„|jDƒD]}| |jj¡qF|S)NcSsg|]}t|tƒr|‘qSrurèrërururvríˆs
þz5ORMSelectCompileState._all_equivs.<locals>.<listcomp>cSsg|]}t|tƒr|‘qSrurèrërururvrís
)rPÚvaluesrrßrôrÀ)r~r‹rIrìrururvr‰„sþ
ÿ
z!ORMSelectCompileState._all_equivscsHˆjr&dd„ˆjDƒ}t ˆj|¡}ng}d}ˆjˆj‡fdd„|Dƒˆjˆjˆjˆjˆjfˆj    ˆj
j ˆj
j ˆj ˆjdœˆj—Ž}| ¡}ˆ ¡}ttj||dˆ_tj|gˆjŽ}ˆj|_ˆj    dk    rވj    jdkrވj    |_    |}ˆj ¡D]}t |||j¡}qì|j  ||¡|r0|jj |fˆj !|¡žŽ|jj |fˆj"žŽ|S)NcSs$g|]}t|tjjƒr|jn|‘qSru)rér"ÚelementsZ_label_referencer)r{Úelemrururvrí¡sþ ÿzCORMSelectCompileState._compound_eager_statement.<locals>.<listcomp>csg|]}|ˆjkr|‘qSru)rÉ)r{r
r}rurvrí³s
©Ú
for_updateÚhintsÚstatement_hintsrnror…)#r!rZ expand_column_list_from_order_byrÇÚ_select_statementrTrfrhrÐrGrÚ_hintsÚ_statement_hintsrnroÚ _select_argsÚaliasr‰rrZCOMPOUND_EAGER_STATEMENTr2r rHrÈrZofr3rZ splice_joinsZstop_onÚ select_fromÚnon_generativerkrQ)r~Zunwrapped_order_byZorder_by_col_exprÚinnerr‹ryZ from_clauseZ
eager_joinrur}rvrt•s|üÿÿùô óÿ
ÿÿ
þÿÿÿþz/ORMSelectCompileState._compound_eager_statementcCsz|j|j|jt|jƒt|j ¡ƒ|j|j|j    |j
f|j |j j |j j|j|jdœ|j—Ž}|jrv|j
j|f|jžŽ|S)Nr“)r—rÇrÈrƒrTr3rrfrhrÐr!rGrr˜r™rnroršrQr)r~ryrururvruîs&
úõ ôz'ORMSelectCompileState._simple_statementcCsòtj|||d}|r||_|r$||_|r:|jt|ƒ7_|rR|jj|f|žŽn|rb|j |¡|rx|jt|ƒ7_| |_    | |_
||_ ||_ |rš||_ |r¤||_||_|r´||_|    r¾|    |_|
rÔ|jj|f|
žŽ| dk    rî|jj|f| žŽ|S)N)rrSr)r8Z_create_raw_selectrfrhrgrƒrmrriÚ _limit_clauseÚ_offset_clauseÚ _fetch_clauseÚ_fetch_clause_optionsÚ    _prefixesÚ    _suffixesrGr˜r™rnro)r~Z raw_columnsrŠZwhere_criteriaZhaving_criteriarÐr!r”r•r–rnroÚ limit_clauseÚ offset_clauseÚ fetch_clauseÚfetch_clause_optionsrmrlÚprefixesÚsuffixesrjryrururvr—sNý ÿÿz'ORMSelectCompileState._select_statementcCsxd|jkr0|jd}|j |d¡}|r0| |¡St|tjƒrB|}nt|dƒrT|j}ndS|j |d¡}|rt| |¡SdS)Nr~r)    r|rÁr‘Z adapt_clauserér%Z
FromClauser†r)r~rÚsearchr›rururvÚ_adapt_polymorphic_elementMs
 
 
 
z0ORMSelectCompileState._adapt_polymorphic_elementcsˆr‡fdd„|DƒS|SdS)Ncsg|]}ˆ|dƒ‘qS)Tru)r{Úor]rurvríasz9ORMSelectCompileState._adapt_col_list.<locals>.<listcomp>rur)rur]rvr,_sz%ORMSelectCompileState._adapt_col_listcsJg‰|jrˆ d|jjf¡|jr2ˆ d|jf¡ˆs:dS‡fdd„}|S)NTFcs‡fdd„}t |i|¡S)NcsFd|jkpd|jk}ˆD](\}}|s(|r||ƒ}|dk    r|SqdS)NÚ
_orm_adaptr~)r|)r’Z is_orm_adaptZ always_adaptrúÚe©ÚadaptersrurvÚreplace‡s
þ zRORMSelectCompileState._get_current_adapter.<locals>._adapt_clause.<locals>.replace)r'Zreplacement_traverse)rÝrr²r°rurvÚ _adapt_clauseƒs zAORMSelectCompileState._get_current_adapter.<locals>._adapt_clause)r&rÍr²rÁr¬)r~r³rur°rvr-es
þÿ
 z*ORMSelectCompileState._get_current_adapterc CsÂ|D]¶\}}}}|d}|d}t|ƒ}|dk    r:t|ƒ}t|tjƒrb|dk    rXt d¡‚|}d}nd|jkrv|jd}|dkr˜|js˜t|dƒs˜t     d¡‚d}    t|tjƒrŠt
|ddƒ}    |dkr|    rÊ|    }nF|j }z
|j }Wn4t k
r}
zt     d|¡|
‚W5d}
~
XYnX|j} |j } t|tjƒs.| }| || jf|jkrDq|dk    r¦|| k    r¦|j dd¡| k    r¦t d    |j d|¡|f¡‚n|dk    ržd} |} nd} } | || ||| ||¡qdS)
NÚisouterÚfullzUNo 'on clause' argument may be passed when joining to a relationship path as a targetr~rßz9Expected mapped entity or selectable/table as join targetZ_of_typez0Join target %s does not refer to a mapped entityzMexplicit from clause %s does not match left side of relationship attribute %s)r!rérÚPropComparatorrrqr|r{r†r‡rÓrÿr(ÚAttributeErrorZ _parententityrÚQueryableAttributerÒÚ_already_joined_edgesr‘Ú_join_left_to_right) r~ÚargsÚentities_collectionÚrightÚonclauseÚfrom_Úflagsr´rµZof_typeÚerrÚleftr rururvre–sŒ ÿ
 
ÿ 
 
ÿÿý
ÿ ÿþ þþÿ
ùzORMSelectCompileState._joinc     Cs|dkr,|dkst‚| ||||¡\}}}    n| ||¡\}}    ||krVt d||f¡‚| ||||¡\}
}}|
js~| |
¡} nd} |dk    rÎ|j|} |jd|…t    | ||||| dg|j|dd…|_nH|    dk    rôt
||    t ƒsèt‚||    j } n|} |jt    | |
|||| dg|_dS)zÆgiven raw "left", "right", "onclause" parameters consumed from
        a particular key within _join(), add a real ORMJoin object to
        our _from_obj list (or augment an existing one)
 
        Nz>Can't construct a join from %s to %s, they are the same entityru)r´rµZ_extra_criteriar) rÚ"_join_determine_implicit_left_sideÚ_join_place_explicit_left_siderrqÚ _join_check_and_adapt_right_sider{Ú_get_extra_criteriarTrrérêr) r~r¼rÂr½r¾r Z    outerjoinrµÚreplace_from_obj_indexÚuse_entity_indexÚr_infoZextra_criteriaZ left_clauserururvrºõs‚ ÿüý
ýÿÿÿ
 
 úÿÿ õÿÿ úÿz)ORMSelectCompileState._join_left_to_rightcCsXt|ƒ}d}}|jrrt |j|j|¡}t|ƒdkrH|d}|j|}n(t|ƒdkr`t d¡‚nt d|f¡‚nÜ|rDi}    t|ƒD]R\}
} | j    } | dkrœq„t| ƒ} | |kr®q„t
| t ƒrÈ|
| f|    | j<q„d| f|    | j<q„t |      ¡ƒ}t ||j|¡}t|ƒdkr|    ||d\}}n*t|ƒdkr2t d¡‚nt d|f¡‚n
t d¡‚|||fS)z­When join conditions don't express the left side explicitly,
        determine if an existing FROM or entity in this query
        can serve as the left hand side.
 
        NrraCan't determine which FROM clause to join from, there are multiple FROMS which can join to this entity. Please use the .select_from() method to establish an explicit left side, as well as providing an explicit ON clause if not present already to help resolve the ambiguity.zÇDon't know how to join to %r. Please use the .select_from() method to establish an explicit left side, as well as providing an explicit ON clause if not present already to help resolve the ambiguity.zgNo entities to join from; please use select_from() to establish the left entity/selectable of this join)r!rTrZfind_left_clause_to_join_fromrrärrqÚ    enumerateÚentity_zero_or_selectablerérêrrÚkeys)r~r¼rÂr½r¾rÉrÇrÈÚindexesZ    potentialZ entity_indexrìr(Zent_infoZ all_clausesrururvrÃXsjÿ   ÿ    üÿ
 ÿÿ    üÿÿz8ORMSelectCompileState._join_determine_implicit_left_sidec    Cs”d}}t|ƒ}|jrHt |j|j¡}t|ƒdkr<t d¡‚|rH|d}|dkrŒ|rŒt|dƒrŒt    |ƒD]$\}}t
|t ƒrf|  |¡rf|}qŒqf||fS)zøWhen join conditions express a left side explicitly, determine
        where in our existing list of FROM clauses we should join towards,
        or if we need to make a new join, and if so is it from one of our
        existing entities.
 
        NrzrCan't identify which entity in which to assign the left side of this join.   Please use a more specific ON clause.rrß) r!rTrZ#find_left_clause_that_matches_givenrrärrqr†rÊrérêÚcorresponds_to)    r~r¼rÂrÇrÈÚl_inforÍÚidxrìrururvrÄÂs0ÿ ÿ
ÿþýz4ORMSelectCompileState._join_place_explicit_left_sidec    Cs”t|ƒ}t|ƒ}d}t|ddƒ}|rp|js8t|jtjƒrp|jpD|jgD](}    t     
|j|    ¡rFt     
|    |j¡rFd}qpqF|r|j|jkrt   d|j¡‚t|ddƒ|jt|ddƒ}}
} |rØ|rØ|  |j¡sØt   d||f¡‚t|dƒrò|j|f7_d} |jrš|r
|j}|
jr0| ¡} | dk    rš| |dƒ}nj|rš|
 |j¡s\t   d|
j|jjf¡‚t|
tjƒr|t tj|
¡}
d} t||
ƒ}tjd    |d
d d |oª| oª|}| sÚ|rÚt|dd }d} tjd|dd | r|sêt‚t t!j"t|ƒ|j#d}| $||¡n4|jsB| sB|j%rB| $|t t!j&||j|j#d¡t|tj'ƒrh| ¡} | rh| |dƒ}|r†|j(|||j)ff7_(t|ƒ||fS)zútransform the "right" side of the join as well as the onclause
        according to polymorphic mapping translations, aliasing on the query
        or on the join, special cases where the right and left side have
        overlapping tables.
 
        FrßNTz*Can't join table/selectable '%s' to itselfrðzIJoin target %s does not correspond to the right side of join condition %sz(Selectable '%s' is not derived from '%s'zÕAn alias is being generated automatically against joined entity %s for raw clauseelement, which is deprecated and will be removed in a later release. Use the aliased() construct explicitly, see the linked example.z1.4Zxaj1)Úcode)Zflatz÷An alias is being generated automatically against joined entity %s due to overlapping tables.  This is a legacy pattern which may be deprecated in a later release.  Use the aliased(<entity>, flat=True) construct explicitly, see the linked example.Zxaj2r…)rrï)*r!rÓÚwith_polymorphicrérñr%ZJoinrTrrZselectables_overlaprrqÚ common_parentrßr†rbÚis_clause_elementZ _is_lateralr-Zis_derived_fromÚ descriptionrNr$r6r&ZFromClauseRolerr#Zwarn_deprecatedrårrrZ DEPRECATED_JOIN_ADAPT_RIGHT_SIDErôróZ#_has_aliased_polymorphic_fromclauseZ#WITH_POLYMORPHIC_ADAPTER_RIGHT_JOINZ ClauseElementr¹rÒ)r~rÂr½r¾r rÏrÉÚoverlapZ right_mapperrŠZright_selectableZright_is_aliasedZ need_adapterr+Zaliased_entityrúrururvrÅsê ÿ þÿÿþÿÿ
 
ý
ÿþ
ýÿÿ
 
 ÿþÿÿ
ÿ
ûø  ûù
 
ý
ÿþýüþ 
z6ORMSelectCompileState._join_check_and_adapt_right_sidec
Cs:|jj|jj|j|j|jj|jj|jp(d|jj|jj    dœ    S)N)    r¥r¦rmrlr©rªrjr§r¨)
rrŸr rmrlr£r¤rjr¡r¢r}rururvršÂsöz"ORMSelectCompileState._select_argscCsF|j}| d¡dk    pD| d¡dk    pD| dd¡pD| dd¡pD| dd¡S)Nr¥r¦rmFrlrurj)ršr‘)r~ÚkwargsrururvrsÒs ÿ
þ
ý
ûz-ORMSelectCompileState._should_nest_selectablecs<dˆjfˆjkr4t‡‡fdd„ˆjdˆjfDƒƒSdSdS)NÚadditional_entity_criteriac3s2|]*}|js|jˆkr| ˆ¡r| ˆ¡VqdSrz)Zinclude_aliasesr(Z_should_includeZ_resolve_where_criteria)r{Zae©rõr~rurvrâs
 
 
ûz<ORMSelectCompileState._get_extra_criteria.<locals>.<genexpr>ru)rßrŽrƒ)r~rõrurÙrvrÆÝsþýÿþ    z)ORMSelectCompileState._get_extra_criteriac    Cs
|jD]V}|j dd¡}|r|jjdk    s8d|jf|jkr||jkr||jrP|jndf|j|<qt    |j 
¡ƒ}|D]”\}}||j kr„qp|jj}|j j ršg}n
| |¡}|dk    r¶||f7}| ¡}|D]@}|rÔ| |¡}|ròt |ddi¡}||dƒ}|j|f7_qÂqpdS)aàApply extra criteria filtering.
 
        For all distinct single-table-inheritance mappers represented in
        the columns clause of this query, as well as the "select from entity",
        add criterion to the WHERE
        clause of the given QueryContext such that only the appropriate
        subtypes are selected from the total results.
 
        Additionally, add WHERE criteria originating from LoaderCriteriaOptions
        associated with the global context.
 
        r~NrØr®TF)rTr|r‘rßÚ_single_table_criterionrŽr"rðrˆrrrbrÂr¸rÆr-ZtraverserZ_deep_annotaterf)    r~Z
fromclauserõr«rúZ single_critrØr+r\rururvrpísB
ÿ
ýÿüù þ  
 
 
 
 
z0ORMSelectCompileState._adjust_for_extra_criteria)N)0rjrkrlr¹r€rPr&rþr/r0r1r2rnrorfrhr®rŸrYrUrýrzr}r€r‚rcr„rvrrŽrr‰rtrur—r¬r,r-rerºrÃrÄrÅrÿršrsrÆrprurururvr9•sj( 
 
 
 
 
 
    YJ1_cjB?
 
 
r9Fz#Union[Query, Select, FromStatement]zOptional[ORMSelectCompileState]rÄzList[ORMColumnDescription])Úquery_or_select_stmtrTrÑrˆcCs8|dkrtj||d}|}dd„dd„|jDƒDƒ}|S)N)rÑc
SsJg|]B\}}|j|jt|ddƒ|j|jdk    r>|js>t|ddƒnddœ‘qS)rðFNr()rÖÚtypeÚaliasedÚexprr()Ú _label_namerÜrÓrÞrŒrÔ)r{rìZinsp_entrururvrí2    s
ø
ÿÿùz(_column_descriptions.<locals>.<listcomp>cSsg|]}||jf‘qSru©rŒ)r{Z_entrururvrí<    s)r9rýrÀ)rÛrTrÑÚctxÚdrururvrØ(    sÿ
ÿörØzUnion[Query[Any], Select[Any]]z"Optional[_InternalEntityType[Any]])Úquery_or_augmented_selectrˆcCsJ|}|jr|j}|dk    r|S|jrBd|jdjkrB|jdjdSt|ƒS)Nr~r)rdÚ_last_joined_entityrSr|Ú_entity_from_pre_ent_zero)rãr~rärururvÚ_legacy_filter_by_entity_zeroC    sræcCsX|}|jsdS|jd}d|jkr,|jdSt|tƒr<|jSd|jkrP|jdS|SdS)Nrr~Úbundle)rr|rérr()rãr~rìrururvråR    s
 
 
 
 
 
råzTuple[_SetupJoinsElement, ...]z=Optional[Union[_InternalEntityType[Any], _JoinTargetElement]])ryrŒrˆcCs2|sdS|d\}}}}t|tjƒr*|jS|SdS)Néÿÿÿÿ)rérr¸r()ryrŒÚtargetr¾r¿rÀrururvrxe    sþrxc@s€eZdZUdZdZded<dZdZdZded<ded    <d
ed <d ed <dddœdd„Z    ddddœdd„Z
dd„Z e dd„ƒZ dS)rz:represent an entity column returned within a Query result.rurÄÚsupports_single_entityFz Optional[str]rßz!Union[Type[Any], TypeEngine[Any]]rÜz.Union[_InternalEntityType, ColumnElement[Any]]rÞzOptional[_InternalEntityType]rŒriÚNone)rTrˆcCs
tƒ‚dSrzr¤©r~rTrururvr#‡    sz _QueryEntity.setup_compile_stater©rTrúrˆcCs
tƒ‚dSrzr¤©r~rTrúrururvr.Š    sz._QueryEntity.setup_dml_returning_compile_statecCs
tƒ‚dSrzr¤)r~rçr«rururvÚ row_processor‘    sz_QueryEntity.row_processorcCsÜt|ƒD]Î\}}|jr8|jr2| ||j||¡qn|j}|jrÄ|jrtd|jkr^t||||ƒqÂt     
||j |||¡qÖ|j  dd¡r’t ||||ƒqÖ|jr®t     
||j |||¡qÖt     
||g|||¡q|jrt |||ƒq|S)Nr~rçF)rÊZ_is_lambda_elementZ _is_sequencerZ    _resolvedrÔr{r|rêÚ _ColumnEntityÚ _for_columnsZ_select_iterabler‘Ú _BundleEntityZ_is_clause_listZ    is_bundle)r¡rTr4r¼rrÐr(rururvr”    shü
üûüûûz_QueryEntity.to_compile_stateN)rjrkrlr rŠr‹Ú_non_hashable_valueÚ_null_column_typeÚuse_id_for_hashr#r.rïr®rrurururvrw    s
rc@s¤eZdZUdZdZded<ded<ded<ded    <d
ed <d ed <dd„ZdZdZdZ    e
dd„ƒZ e
dd„ƒZ dd„Z dd„Zdd„Zddddœdd „Zd!d"„Zd#S)$rêz mapper/class/AliasedClass entity)
rÞrßrŒrðÚpathÚ_extra_entitiesrßrørÚ_polymorphic_discriminatorr=rÞz Mapper[Any]rßrŒrÄrðrröÚstrrßcCsÀ| |¡|r*|jdkr||_d|_d|_|jd}|j|}|_|j}||_|j    |_    }|jf|_
|j rv|j |_ n
|jj|_ |j |_ |j|_|j|_|j|_|j|_|jr¼| ||j¡dS)NTr~)rÍrÃrþr/r|Ú _post_inspectrŒr(rÞrßr÷rðrÖrßÚclass_rjr½rörZwith_polymorphic_mappersrøZpolymorphic_onrøÚ _should_select_with_poly_adapterr÷)r~rTr(r¼rrõrßrururvr†î    s4
 
 
 
 
 
 
ÿz_MapperEntity.__init__TcCs|jjSrz)rßrûr}rururvrÜ
sz_MapperEntity.typecCs|jSrzràr}rururvrË
sz'_MapperEntity.entity_zero_or_selectablecCs t|j|ƒSrz)rrŒ©r~r(rururvrΠ
sz_MapperEntity.corresponds_tocCsRd}|js"|jr*|j |jd¡}n|jj}|rH|jrB| |j¡}qN|}n|j}|Srz)rðrÁr‘rßrŒrˆr&Úwrap)r~rTrúÚretrururvÚ_get_entity_clauses#
sÿz!_MapperEntity._get_entity_clausesc Cs„|j}| |¡}|jr(|r(| |j¡}n
|s2|j}|j|krL|jj}|j}nd}}tj    ||j
|||j ||||j d    }||j |jfS)N)Úonly_load_propsr_Úpolymorphic_discriminator)rTrr2rþrÃrÂr¶r_rZ_instance_processorrßrörørßr÷)r~rçr«rTrúrr_Z    _instancerururvrï9
s,
 
 
÷ z_MapperEntity.row_processorrirrëríc Cs.tj||j||j||j|j|jj|jd    dS)N©rÒrr)    rÚ_setup_entity_queryrßrörÇrørÂr¶rørîrururvr.V
s÷z/_MapperEntity.setup_dml_returning_compile_statec Cs†| |¡}|jj}|dk    s*d|jf|jkrJ|j}||jr>|jndf|j|<tj    ||j||j
||j |j |j j|jd    |j |j¡dS)NrØr)rrßrÚrŽrŒrðrˆr"rrrörÇrørÂr¶rør rÍr)r~rTrúÚsingle_table_critrõrururvr#g
s0
ÿÿþþ
÷ z!_MapperEntity.setup_compile_stateN)rjrkrlr rŠr‹r†rêrórõrÿrÜrËrÎrrïr.r#rurururvrê×    s*
 %
 
rêc@sŒeZdZUdZdZded<ded<ded<d    ed
<d ed <ded <ddd„Zedd„ƒZedd„ƒZ    dd„Z
edd„ƒZ dd„Z dd„Z dS)ròru)rçrÞrÜrßrÀrêr¿rÀrrçz    Type[Any]rÜrùrßrÄrêrÞTNc    Csâd|_|jd}|r"|j |¡n
| |¡t|tjtjfƒrH|     ¡}n|}||_
|_ t |ƒ|_ |j |_g|_|rÔ|jD]X}d|jkrœt|||||dqzt|tƒrºt|||||dqztj||g|d||dqz|j
j|_dS)NTrç©Ú parent_bundle)r/r|rÀrÍrérr¸rr¶rrçrÞrÜrÖrßÚexprsròrÚ_ORMColumnEntityrñZ single_entityrê)r~rTrÞr¼rZsetup_entitiesrrçrururvr†˜
sT    
 
 
ÿ
 
 
 
û
ûú    z_BundleEntity.__init__cCs|j}|dk    r|jSdSdSrz)rŒrß)r~rwrururvrßÓ
sz_BundleEntity.mappercCs&|jD]}|j}|dk    r|SqdSrz)rÀrŒ©r~rìrwrururvrŒÛ
s
 
 
z_BundleEntity.entity_zerocCsdSr^rurýrururvrÎä
sz_BundleEntity.corresponds_tocCs&|jD]}|j}|dk    r|SqdSrz)rÀrËr
rururvrËé
s
 
 
z'_BundleEntity.entity_zero_or_selectablecCs|jD]}| |¡qdSrz)rÀr#)r~rTrìrururvr#ò
s
z!_BundleEntity.setup_compile_statecs@t‡‡fdd„|jDƒŽ\}}}|j ˆj||¡}||j|jfS)Ncsg|]}| ˆˆ¡‘qSru)rïrë©rçr«rurvríø
sz/_BundleEntity.row_processor.<locals>.<listcomp>)r„rÀrçZcreate_row_processorrUrßr÷)r~rçr«ZprocsÚlabelsÚextraÚprocrur rvrïö
s
ÿ
z_BundleEntity.row_processor)TN)rjrkrlr÷rŠr‹r†rÿrßrŒrÎrËr#rïrurururvrò„
s(
    ù
;
 
 
ròc@sJeZdZdZed dd„ƒZedd„ƒZedd„ƒZed    d
„ƒZ    d d „Z
dS)rð)Ú _fetch_columnÚ_row_processorÚraw_column_indexÚtranslate_raw_columnNc
 
Cs„|D]z}|j}d|kr |d}    n t |d¡}    |    rjd|jkrRt||||    |||dq~t||||    |||dqt||||||dqdS)Nr~rdr)r|rZextract_first_column_annotationÚ_IdentityTokenEntityr    Ú_RawColumnEntity)
r¡rTrr¼rrrÚcolumnrÚ_entityrururvrñ sH
 
ÿ
ù
ù
úz_ColumnEntity._for_columnscCs|jjSrz)rrÜr}rururvrÜ: sz_ColumnEntity.typecCs |jjj Srz)rrÜZhashabler}rururvró> sz!_ColumnEntity._non_hashable_valuecCs
|jjjSrz)rrÜZ_isnullr}rururvrôB sz_ColumnEntity._null_column_typec    CsØ|j}|jdk    r@|j\}}}|jr6||jj|jf7}|||fS|jdk    rR|j}n&|j}|jrj|jj    |}|j
rx|  ¡}|j rŠ|j j    |}|  |¡}||j|jf}||_|jrÐ|j|jj|jf}||j|fS|SdSrz)rTrrrUrrrrr&rr|Ú _deannotater2Z_getterrßr÷)    r~rçr«rTÚgetterZ
label_nameZextra_entitiesrrÿrururvrïF s4
  ÿ
 
 
 ÿ z_ColumnEntity.row_processor)N) rjrkrlrŠr®rñrÿrÜrórôrïrurururvrð sù 1
 
 
rðc@s6eZdZdZdZdZdZd
dd„Zdd„Zdd    „Z    dS) rNF)rÞrrßrËr÷cCs¦||_||_|dk    |_|jr.|jddi7_|r8|jr@d|_n | |¡|_|r^|j     |¡n
|     |¡||_
|j
j r‚|j
j dnd|_ |j|j
f|_ d|_|_dS)NrºTr)rÞrrrºrÂZ_is_text_clauserßrÆrÀrÍrr=rËr÷rr)r~rTrr¼rrrrururvr†‡ s     
 
 
ÿz_RawColumnEntity.__init__cCsdSr^rurýrururvrΨ sz_RawColumnEntity.corresponds_tocCs\| ¡}|r&||jdƒ}|dkr,dSn|j}|jr:| ¡}|j |¡|j |¡||_dSr^)    r-rr|rrÉrÌrÇrÍr)r~rTr+rrururvr#« s   z$_RawColumnEntity.setup_compile_state)N)
rjrkrlrŒrßrêrŠr†rÎr#rurururvrz sù
!rc@sDeZdZdZdZdZddd„Zdd„Zd    d
d d œd d„Zdd„Z    dS)r    zColumn/expression based entity.F)rÞrßrrßrËrŒr÷NcCsê|j}|}    | dd¡}
| d|    ¡} |
r<t| j|
ƒ|_d|_n||_|dk    |_||_|rh|j||
d|_nd|_|    j    |    |_
|_ } |    j |_ } |r¢|j  |¡n
| |¡d|_||_d|_|_|j|jf|_| jræ| | | j¡dS)NÚ    proxy_keyÚ proxy_ownerF)rÕT)r|r‘rÓr(rÞrrrÆrßrúrŒrËrßrÀrÍr/rrrr÷rür÷r)r~rTrr¼r~rrrrrZorm_keyrrwrßrururvr†Í s>
 
ÿ
 
 ÿz_ORMColumnEntity.__init__cCs.t|ƒr||jkSt|jƒ o(| |j¡SdSrz)rrŒrÓrýrururvrÎ s
ÿ
þz_ORMColumnEntity.corresponds_torirrërícCs8|j|_||jdƒ}|dk    r4|j |¡|j |¡dSr^)rrrÉrÌrÇrÍ)r~rTrúrrururvr. s
  z2_ORMColumnEntity.setup_dml_returning_compile_statecCsØ| ¡}|r8||jdƒ}|dkr>|js*t‚|j|_dSn|j}|j}|jj}|dk    sdd|jf|jkr~||j    rr|j
ndf|j |<|j r’|j s’| ¡}t|jjƒ |jj¡r¶|j |j¡|j |¡|j |¡||_dS)NFrØ)r-rr­rrrŒrßrÚrŽrðrˆr"r|Z_expression_labelrrr=Ú intersectionrr rÍrÉrÌrÇ)r~rTr+rrwrrururvr#! s8 
ÿÿþþ
  ÿ  z$_ORMColumnEntity.setup_compile_state)N)
rjrkrlr rêrŠr†rÎr.r#rurururvr    ¾ sø
@     r    c@s eZdZdZdd„Zdd„ZdS)rFcCsdSrzrurìrururvr#Q sz(_IdentityTokenEntity.setup_compile_statecs‡fdd„}||j|jfS)NcsˆjjSrz)rWrq)Úrow©rçrurvrU sz2_IdentityTokenEntity.row_processor.<locals>.getter)rßr÷)r~rçr«rrurrvrïT s z"_IdentityTokenEntity.row_processorN)rjrkrlrr#rïrurururvrN sr)NF)N)|Ú
__future__rr?Útypingrrrrrrr    r
r r r rÚrrrÚbaserrrZ path_registryrr#rrrrrrrrrr r!r"r$r%r&rr'Z sql._typingr(r)r*r+Zsql.baser,r-r.r/r0r1Zsql.dmlr2Z sql.elementsr3r4Zsql.selectabler5r6r7r8r9r:r;Z sql.visitorsr<Ú_typingr=r>r?rßr@rUrArZrBrCZenginerDZengine.interfacesrErFZ sql.compilerrGrHrIrJrKrLrMrNZ sql.type_apirOrPÚrootr½rLr€rNrRrárŒrirZ
plugin_forrrr9rØrærårxrrêròrðrr    rrurururvÚ<module>    sø                                                                              gÿl+%sýþ`.|zD