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
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
U
¸ý°dÖÙã@sVdZddlmZddlmZddlZddlmZddlm    Z    ddlm
Z
ddlm Z ddlm Z dd    lm Z dd
lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl#m%Z%ddl#m&Z&ddl#m'Z'dd l#m(Z(dd!l#m)Z)dd"lm*Z*dd#lm+Z+dd$lm,Z,dd%lm-Z-dd&lm.Z.d'd(lm/Z0d'd)lm1Z1d'd*lm2Z2d'd+lm3Z3d'd,lm4Z4d'dlmZd'd-l5m6Z6d'd.l5m7Z7d'd/l8m9Z9d'd0l8m:Z:d'd1l4m;Z;d'd2l4m<Z<d'd3l4m=Z=d'd4l4m>Z>d'dl4mZ?d'd5l4m@Z@d'd6lAmBZBd'd7lAmCZCd'd8lDmEZEd'd9lFmGZGd'd:lFmHZHd'd;lFmIZId'd<lFmJZJd'd=lFmKZKd'd>lLmMZMd'd?lNmOZOd'd@lPmQZQd'dAlPmRZRd'dBlPmSZSd'dClPmTZTd'dDlPmUZUd'dElPmVZVd'dFlPmWZWd'dGlPmXZXd'dHlYmZZZd'dIlYm[Z[er²ddJlm\Z\ddKlm]Z]ddLlm^Z^ddMlm_Z_ddNl`maZaddOlbmcZcddPldmeZeddQldmfZfddRlgmhZhd'dSlimjZjd'dTlkmlZld'dUlkmmZmd'dVlkmnZnd'dWlkmoZod'dXlpmqZqd'dYlpmrZrd'dZlAmsZsd'd[lAmtZtd'd\lAmuZud'd]lAmvZvd'd^lAmwZwd'd_lAmxZxd'd`lAmyZyd'dalAmzZzd'dblAm{Z{d'dclAm|Z|d'ddlAm}Z}d'delAm~Z~d'dflAmZd'dglAm€Z€d'dhlAmZd'dilAm‚Z‚d'djlAmƒZƒd'dklAm„Z„d'dllAm…Z…d'dmlAm†Z‡d'dnlFmˆZˆd'dolFm‰Z‰d'dplLmŠZŠd'dqlLm‹Z‹d'drlPmŒZŒd'dslPmZd'dtlPmŽZŽd'dulPmZd'dvlPmZd'dwlPm‘Z‘d'dxlPm’Z’d'dylPm“Z“dzd{gZ”ed|ed}Z•e2j–e3j—Gd~dz„dzeReEeUeVeTe:e3j˜eKeJe e•ƒ ƒƒZ™Gdd€„d€ejšƒZ›Gdd‚„d‚ƒZœGdƒd„„d„eœƒZGd…d†„d†eœƒZžGd‡dˆ„dˆe™e7eCƒZŸdS)‰aThe Query class and support.
 
Defines the :class:`_query.Query` class, the central
construct used by the ORM to construct database queries.
 
The :class:`_query.Query` class should not be confused with the
:class:`_expression.Select` class, which defines database
SELECT operations at the SQL (non-ORM) level.  ``Query`` differs from
``Select`` in that it returns ORM-mapped objects and interacts with an
ORM session, whereas the ``Select`` construct interacts directly with the
database to return iterable result sets.
 
é)Ú annotationsN)ÚAny)ÚCallable)Úcast)ÚDict)ÚGeneric)ÚIterable)ÚIterator)ÚList)ÚMapping)ÚOptional)Úoverload)ÚSequence)ÚTuple)ÚType)Ú TYPE_CHECKING)ÚTypeVar)ÚUnioné)Ú
attributes)Ú
interfaces)Úloading)Úutil)Ú_O)Ú _assertions©Ú_column_descriptions)Ú_determine_last_joined_entity)Ú_legacy_filter_by_entity_zero)Ú FromStatement)ÚORMCompileState)Ú QueryContext)ÚORMColumnDescription)ÚORMColumnsClauseRole)Ú AliasedClass)Ú object_mapper)Ú with_parenté)Úexc)Úinspect)Ú
inspection)Úlog)Úsql)ÚResult)ÚRow)Ú
dispatcher)Ú EventTarget)Ú    coercions)Ú
expression)Úroles)ÚSelect)Úvisitors)Ú_FromClauseArgument)Ú_TP)ÚSupportsCloneAnnotations©Ú_entity_namespace_key)Ú _generative)Ú_NoArg)Ú
Executable)Ú
Generative)ÚBooleanClauseList)ÚExists)Ú_MemoizedSelectEntities)Ú_SelectFromElements)Ú ForUpdateArg)ÚHasHints)Ú HasPrefixes)Ú HasSuffixes)ÚLABEL_STYLE_TABLENAME_PLUS_COL)ÚSelectLabelStyle)ÚLiteral)ÚSelf)Ú _EntityType)Ú_ExternalEntityType)Ú_InternalEntityType)ÚSynchronizeSessionArgument)ÚMapper)Ú PathRegistry)Ú_PKIdentityArgument)ÚSession)Ú InstanceState)Ú CursorResult)Ú_ImmutableExecuteOptions)ÚCompiledCacheType)ÚIsolationLevel)ÚSchemaTranslateMapType)Ú FrozenResult)Ú ScalarResult)Ú_ColumnExpressionArgument)Ú#_ColumnExpressionOrStrLabelArgument)Ú_ColumnsClauseArgument)Ú_DMLColumnArgument)Ú_JoinTargetArgument)Ú_LimitOffsetType)Ú _MAYBE_ENTITY)Ú_no_kw)Ú _NOT_ENTITY)Ú_OnClauseArgument)Ú_PropagateAttrsType)Ú_T0)Ú_T1)Ú_T2)Ú_T3)Ú_T4)Ú_T5)Ú_T6)Ú_T7)Ú_TypedColumnClauseArgument)ÚCacheableOptions)ÚExecutableOption)Ú ColumnElement)ÚLabel)Ú_JoinTargetElement)Ú_SetupJoinsElement)ÚAlias)ÚCTE)ÚExecutableReturnsRows)Ú
FromClause)Ú ScalarSelect)ÚSubqueryÚQueryr!Ú_T)Úboundc@sFeZdZUdZdZded<dZded<dZded<dZded<dZ    d    ed
<dZ
d    ed <d Z d ed<dZ ded<dZ ded<dZded<dZd ed<dZded<dZded<ejZded<dZejZded<ded<ejddiZejZd ed!<dZdZ d"ed#<d$ed%<d&ed'<ej!d(d)œd*d+„ƒZ"dÜd,d-d.œd/d0„Z#d1d2d3œd4d5„Z$d6d7d8œd9d:„Z%d;d<d=œd>d?„Z&d@d)œdAdB„Z'dCdDdEœdFdG„Z(dHd d7dIœdJdK„Z)e*dLd2dMœdNdO„ƒZ+d7d)œdPdQ„Z,d7d)œdRdS„Z-dÝdCd d d7dTœdUdV„Z.dÞdCd d d7dTœdWdX„Z/dCd7dYœdZd[„Z0dCd7dYœd\d]„Z1dCd7dYœd^d_„Z2e3d d)œd`da„ƒZ4dßdbdbdcddded2dfœdgdh„Z5did2djœdkdl„Z6dmd)œdndo„Z7e3dpd)œdqdr„ƒZ8dàd dsdtœdudv„Z9dád d dpdwœdxdy„Z:dâdzd d d{d|œd}d~„Z;dãdzd d dd€œdd‚„Z<dzdƒd„œd…d†„Z=e>d‡dˆd=œd‰dŠ„ƒZ?e>d‹dŒd=œddŠ„ƒZ?e>dŽd)œddŠ„ƒZ?e @dd‘¡dŽd)œd’dŠ„ƒZ?e>d‡dŽd=œd“d”„ƒZAe>d‹dŒd=œd•d”„ƒZAe>dŽd)œd–d”„ƒZAdŽd)œd—d”„ZAe3dpd)œd˜d™„ƒZBdpd)œdšd›„ZCe>d;dœddžœdŸd „ƒZDe>d;d¡d;džœd¢d „ƒZDe*d d£d¤œd¥d „ƒZDe3d d)œd¦d§„ƒZEe*d d2d¤œd¨d©„ƒZFe*did2dªœd«d¬„ƒZGejHd­d®d¯d2d)œd°d±„ƒZIeIZJe3dd)œd²d³„ƒZKdd2d´œdµd¶„ZLe*d d2d¤œd·d¸„ƒZMe3d¹d)œdºd»„ƒZNe*d¼d2d½œd¾d¿„ƒZOe*dÀd2dÁœdÂdăZPejHdÄdÅd¯dÆdedǜdÈdɄƒZQdädÆdÊdeded˜dÌd̈́ZRe3ddd)œdÎdτƒZSe3d¼d)œdÐdфƒZTe*dÒd2dӜdÔdՄƒZUe*d d2d֜d×d؄ƒZVe*d2d)œdÙdڄƒZWe*d d2d¤œdÛd܄ƒZXejHdÝdÞd¯e Ydß¡dådàdádâd2dãœdäd儃ƒZZe*dædædçd£dèœdédꄃZ[e*d$d2dëœdìd턃Z\dîd2d8œdïdð„Z]e*d d2dñœdòdó„ƒZ^e*dçdôd d2dõœdöd÷„ƒZ_e @ddø¡dîdùdúœdûdü„ƒZ`e`Zadîdùdúœdýdþ„Zbe @ddÿ¡ddidœdd„ƒZce>dd;dœdd„ƒZde>dd    d
œd d„ƒZde>d d ddœdd„ƒZde>d d dddœdd„ƒZde>d d ddddœdd„ƒZde>d d dddddœdd„ƒZde>d d ddddddœd d„ƒZde>d d ddddd!d"d#œd$d„ƒZde>d d ddddd!d%d&d'œ    d(d„ƒZde>dîd£d8œd)d„ƒZde*dîdid£d*œd+d„ƒZde*dd£dœd,d-„ƒZee @dd.¡dd£dœd/d0„ƒZfe*d1d2d2œd3d4„ƒZgd5d£d6œd7d8„Zhd9d)œd:d;„Zie>d<d<d<d d d<d<d<d<d d d=œ d>dCd?d d dÀdÀdÀd@d d did2dAœ dBdC„ƒZje>did2dªœdDdC„ƒZje*did2dEœdFdC„ƒZje*d d dd d dGœd d dHd d d2dIœdJdK„ƒZke*dèdLdid2dMœdNdO„ƒZldPd2dQœdRdS„Zme*ene1e2ƒdPd2dQœdTdU„ƒƒZoej!dVd)œdWdX„ƒZpdid)œdYdZ„Zqdid2dEœd[d\„Zre*esjtfd]d^d2d_œd`da„ƒZue*esjtfd]d^d2d_œdbdc„ƒZve*ene1e2ƒdPd2ddœdedf„ƒƒZwdid£d2dgœdhdi„Zxd£d2djœdkdl„Zyd£d2djœdmdn„Zzd£d2djœdodp„Z{d£d2djœdqdr„Z|d£d2djœdsdt„Z}d£d2djœdudv„Z~e*ene1e2ƒdéd d dwœdxdyd d d2dzœd{d|„ƒƒZdêd d}œdxdyd d2d~œdd€„Z€e*ene1ƒd2d)œdd‚„ƒƒZe*ene0ƒdƒd2d„œd…d†„ƒƒZ‚didid‡œdˆd‰„Zƒe*ene1ƒdÀdÀd2dŠœd‹dŒ„ƒƒZ„e*ene1ƒdd2dŽœdd„ƒƒZ…e*ene1ƒdd2d‘œd’d“„ƒƒZ†e*ene1ƒdd2d”œd•d–„ƒƒZ‡d—d)œd˜d™„Zˆe*ene0ƒdšd2d›œdœd„ƒƒZ‰džd)œdŸd „ZАdžd)œd¡d¢„Z‹d£d)œd¤d¥„ZŒdid)œd¦d§„Zd¨d)œd©dª„Zސd«d)œd¬d­„ZdCd)œd®d¯„Zdidididid°œd±d²„Z‘e3d³d)œd´dµ„ƒZ’e @d¶d·¡dëd¸d¹didºœd»d¼„ƒZ“ejHd½d¾d d¿dìdÀd dÁdœdÐdĄƒZ”dÅd)œdƐdDŽZ•dÀd)œdȐdɄZ–dídËdÀd̜d͐d΄Z—dîdϐdːdÐdÀdќdҐdӄZ˜dïd didԐd՜d֐dׄZ™dðd dؐdٜdڐdۄZšdS(ñr{aOORM-level SQL construction object.
 
    .. legacy:: The ORM :class:`.Query` object is a legacy construct
       as of SQLAlchemy 2.0.   See the notes at the top of
       :ref:`query_api_toplevel` for an overview, including links to migration
       documentation.
 
    :class:`_query.Query` objects are normally initially generated using the
    :meth:`~.Session.query` method of :class:`.Session`, and in
    less common cases by instantiating the :class:`_query.Query` directly and
    associating with a :class:`.Session` using the
    :meth:`_query.Query.with_session`
    method.
 
    ©zTuple[ColumnElement[Any], ...]Ú_where_criteriaÚ_having_criteriaÚ_order_by_clausesÚ_group_by_clausesNzOptional[ColumnElement[Any]]Ú _limit_clauseÚ_offset_clauseFÚboolÚ    _distinctÚ _distinct_onzOptional[ForUpdateArg]Ú_for_update_argzTuple[FromClause, ...]Ú
_correlateTÚ_auto_correlateÚ    _from_objzTuple[_SetupJoinsElement, ...]Ú _setup_joinsrHÚ _label_stylez/Union[Type[CacheableOptions], CacheableOptions]Ú_compile_optionszTuple[ExecutableOption, ...]Ú _with_optionsZ_legacy_uniquingzutil.immutabledict[str, Any]Ú_paramszOptional[ExecutableReturnsRows]Ú
_statementrRÚsessionzdispatcher[Query[_T]]Údispatchre©ÚreturncCstjS©N)rÚ
EMPTY_DICT©Úselfr~r~úKd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/orm/query.pyÚ_propagate_attrsçszQuery._propagate_attrsz%Sequence[_ColumnsClauseArgument[Any]]zOptional[Session])Úentitiesr’cCs||_| |¡dS)a·Construct a :class:`_query.Query` directly.
 
        E.g.::
 
            q = Query([User, Address], session=some_session)
 
        The above is equivalent to::
 
            q = some_session.query(User, Address)
 
        :param entities: a sequence of entities and/or SQL expressions.
 
        :param session: a :class:`.Session` with which the
         :class:`_query.Query`
         will be associated.   Optional; a :class:`_query.Query`
         can be associated
         with a :class:`.Session` generatively via the
         :meth:`_query.Query.with_session` method as well.
 
        .. seealso::
 
            :meth:`.Session.query`
 
            :meth:`_query.Query.with_session`
 
        N)r’Ú _set_entities)r™rœr’r~r~ršÚ__init__ës%zQuery.__init__zMapping[str, Any]rJ)Úvaluesr•cCst |¡|_|Sr–)rZ immutabledictr›)r™rŸr~r~ršÚ_set_propagate_attrss zQuery._set_propagate_attrsz%Iterable[_ColumnsClauseArgument[Any]]ÚNone)rœr•cs‡fdd„t |¡Dƒˆ_dS)Ncs g|]}tjtj|ˆdd‘qS)T©Úapply_propagate_attrsZ post_inspect©r1Úexpectr3ÚColumnsClauseRole)Ú.0Úentr˜r~ršÚ
<listcomp>súüz'Query._set_entities.<locals>.<listcomp>)rZto_listÚ _raw_columns©r™rœr~r˜ršrs
ùzQuery._set_entitiesz    Query[_O]zQuery[Tuple[_O]])r™r•cCs
| d¡S)a¢return a tuple-typed form of this :class:`.Query`.
 
        This method invokes the :meth:`.Query.only_return_tuples`
        method with a value of ``True``, which by itself ensures that this
        :class:`.Query` will always return :class:`.Row` objects, even
        if the query is made against a single entity.  It then also
        at the typing level will return a "typed" query, if possible,
        that will type result rows as ``Tuple`` objects with typed
        elements.
 
        This method can be compared to the :meth:`.Result.tuples` method,
        which returns "self", but from a typing perspective returns an object
        that will yield typed ``Tuple`` objects for results.   Typing
        takes effect only if this :class:`.Query` object is a typed
        query object already.
 
        .. versionadded:: 2.0
 
        .. seealso::
 
            :meth:`.Result.tuples` - v2 equivalent method.
 
        T)Úonly_return_tuplesr˜r~r~ršÚtuples$sz Query.tuplesz"Optional[_InternalEntityType[Any]]cCsl|js
dS|jd}d|jkr(|jdSd|jkr<|jdSt |¡D]}d|jkrF|jdSqFdSdS)NrÚ parententityZbundle)rªÚ _annotationsr5Ziterate)r™r¨Úelementr~r~ršÚ_entity_from_pre_ent_zero>s
 
 
 
 
 
zQuery._entity_from_pre_ent_zeroÚstrz Mapper[Any])Úmethnamer•cCsHt|jƒdks*d|jdjks*|jdjs8t d|¡‚|jdjdS)Nrr®rz4%s() can only be used against a single mapped class.)Úlenrªr¯Z is_selectableÚsa_excÚInvalidRequestError)r™r³r~r~ršÚ_only_full_mapper_zeroPs ÿþ
ýÿÿzQuery._only_full_mapper_zerozIterable[_FromClauseArgument])ÚobjÚset_base_aliasr•cs2‡fdd„|Dƒ}ˆjd|i7_t|ƒˆ_dS)Ncs g|]}tjtj|dˆd‘qS)T)Z allow_selectr£)r1r¥r3ZStrictFromClauseRole)r§Úelemr˜r~ršr©`súüz*Query._set_select_from.<locals>.<listcomp>Ú_set_base_alias)rŽÚtupler‹)r™r¸r¹Úfar~r˜ršÚ_set_select_from]s
 
ù
zQuery._set_select_fromzInstanceState[Any])Ústater•cCs|jd|i7_|S)NÚ_lazy_loaded_from©Ú load_options)r™r¿r~r~ršÚ_set_lazyload_frommszQuery._set_lazyload_fromcCs|jdddddS)zused by legacy BakedQueryÚgetF©Úorder_byÚdistinctN)Ú_no_criterion_conditionr˜r~r~ršÚ_get_conditionrszQuery._get_conditioncCs|jdddddS)NrÄFrÅ)Ú_no_criterion_assertionr˜r~r~ršÚ_get_existing_conditionvszQuery._get_existing_condition)ÚmethrÆrÇr•cCsf|js
dS|jsT|jdk    sT|jsT|jsT|jdk    sT|jdk    sT|jsT|rJ|jsT|rb|j    rbt
  d|¡‚dS©Nz<Query.%s() being called on a Query with existing criterion. ) Ú_enable_assertionsrr‘r‹rŒrƒr„r‚rr†rµr¶©r™rÌrÆrÇr~r~ršrÊys:ÿþýüûúùøø    ÷    ÷ ÿÿzQuery._no_criterion_assertioncCsR| |||¡d|_|_|jdk    r6|jddi7_d|_d|_d|_|_dS)Nr~r‘F)    rÊr‹rŒr‘rŽrr†rr‚rÏr~r~ršrȎs 
zQuery._no_criterion_condition)rÌr•cCs,|js
dS|jrt d|¡‚| |¡dSrÍ)rÎrrµr¶rÈ©r™rÌr~r~ršÚ_no_clauseelement_condition›sÿÿz!Query._no_clauseelement_conditioncCs&|js
dS|jdk    r"t d|¡‚dS)Nz[Query.%s() being called on a Query with an existing full statement - can't apply criterion.)rÎr‘rµr¶rÐr~r~ršÚ_no_statement_condition¥s
üÿzQuery._no_statement_conditioncCs4|js
dS|jdk    s|jdk    r0t d||f¡‚dS)Nz€Query.%s() being called on a Query which already has LIMIT or OFFSET applied.  Call %s() before limit() or offset() are applied.)rÎrƒr„rµr¶rÐr~r~ršÚ_no_limit_offset±sþÿzQuery._no_limit_offsetcCs|jdk    p|jdk    Sr–)rƒr„r˜r~r~ršÚ_has_row_limiting_clause»sÿzQuery._has_row_limiting_clausezOptional[bool]zOptional[Sequence[str]]zOptional[InstanceState[Any]]z Optional[Any])Úpopulate_existingÚ version_checkÚonly_load_propsÚ refresh_stateÚidentity_tokenr•cCsxi}i}|r||d<|r ||d<|r4||d<d|d<|rDt|ƒ|d<|rP||d<|rb|j|7_|rt|j|7_|S)NZ_version_checkÚ_populate_existingZ_refresh_stateTZ_for_refresh_stateZ_only_load_propsZ_identity_token)Ú    frozensetrÂrŽ)r™rÕrÖr×rØrÙrÂÚcompile_optionsr~r~ršÚ _get_optionsÁs$ zQuery._get_optionsr)Úkwr•cKs| ¡Sr–)Ú    _generate)r™rÞr~r~ršÚ_cloneßsz Query._cloneú
Select[_T]cCs |jdk    rt d¡‚td|jƒS)Nz<Can't call this method on a Query that uses from_statement()rá)r‘rµr¶rÚ    statementr˜r~r~ršÚ_get_select_statement_onlyâs
 
ÿz Query._get_select_statement_onlyz$Union[Select[_T], FromStatement[_T]]cCs:|jjs|jdd}n|jddj}|jr6| |j¡}|S)z×The full SELECT statement represented by this Query.
 
        The statement by default will not have disambiguating labels
        applied to the construct unless with_labels(True) is called
        first.
 
        T©Ú for_statement)rŽr»Ú _statement_20Ú_compile_staterârÚparams)r™Ústmtr~r~ršrâés  zQuery.statementz Select[Any])Úlegacy_query_styler•cCs| ¡}|j|djS)a8Return the 'final' SELECT statement for this :class:`.Query`.
 
        This is used by the testing suite only and is fairly inefficient.
 
        This is the Core-only select() that will be rendered by a complete
        compilation of this query, and is what .statement used to return
        in 1.3.
 
 
        )Úuse_legacy_query_style)ràrçrâ)r™rêÚqr~r~ršÚ_final_statements ÿzQuery._final_statement)rårër•cCsê|jjrJ|jjD]8}||ƒ}|dk    r||k    r|}|js|jddi7_q|j}|||dœ7}|jdk    r–t|j|jƒ}|jj|j    |j
||j |j dn2t jf|jŽ}|jj|j||j d|j dd¡d|j kræ|j  ddd    œ¡|_ |S)
NÚ_bake_okF)Ú_for_statementZ_use_legacy_query_style)rÚ_with_context_optionsrŽÚ_execution_optionsr›)rrŽr›r’Úcompile_state_pluginÚorm)ròZplugin_subject)r“Zbefore_compilerîrŽr‘rrªÚ__dict__Úupdaterrðrñr›r4Z_create_raw_selectrÚpopÚunion)r™rårëÚfnÚ    new_queryrÜrér~r~ršræ$sB þ
û    ý
ÿzQuery._statement_20z Optional[str]rz)ÚnameÚ with_labelsÚreduce_columnsr•cCsJ| d¡}|r| t¡}| ¡}tr2t|tƒs2t‚|r>| ¡}|j    |dS)aîReturn the full SELECT statement represented by
        this :class:`_query.Query`, embedded within an
        :class:`_expression.Alias`.
 
        Eager JOIN generation within the query is disabled.
 
        .. seealso::
 
            :meth:`_sql.Select.subquery` - v2 comparable method.
 
        :param name: string name to be assigned as the alias;
            this is passed through to :meth:`_expression.FromClause.alias`.
            If ``None``, a name will be deterministically generated
            at compile time.
 
        :param with_labels: if True, :meth:`.with_labels` will be called
         on the :class:`_query.Query` first to apply table-qualified labels
         to all columns.
 
        :param reduce_columns: if True,
         :meth:`_expression.Select.reduce_columns` will
         be called on the resulting :func:`_expression.select` construct,
         to remove same-named columns where one also refers to the other
         via foreign key or WHERE clause equivalence.
 
        F)rú)
Úenable_eagerloadsÚset_label_stylerGrãrÚ
isinstancer4ÚAssertionErrorrüÚsubquery)r™rúrûrürìrér~r~ršrXs 
 
zQuery.subqueryrv)rúÚ    recursiveÚnestingr•cCs| d¡ ¡j|||dS)a\Return the full SELECT statement represented by this
        :class:`_query.Query` represented as a common table expression (CTE).
 
        Parameters and usage are the same as those of the
        :meth:`_expression.SelectBase.cte` method; see that method for
        further details.
 
        Here is the `PostgreSQL WITH
        RECURSIVE example
        <https://www.postgresql.org/docs/current/static/queries-with.html>`_.
        Note that, in this example, the ``included_parts`` cte and the
        ``incl_alias`` alias of it are Core selectables, which
        means the columns are accessed via the ``.c.`` attribute.  The
        ``parts_alias`` object is an :func:`_orm.aliased` instance of the
        ``Part`` entity, so column-mapped attributes are available
        directly::
 
            from sqlalchemy.orm import aliased
 
            class Part(Base):
                __tablename__ = 'part'
                part = Column(String, primary_key=True)
                sub_part = Column(String, primary_key=True)
                quantity = Column(Integer)
 
            included_parts = session.query(
                            Part.sub_part,
                            Part.part,
                            Part.quantity).\
                                filter(Part.part=="our part").\
                                cte(name="included_parts", recursive=True)
 
            incl_alias = aliased(included_parts, name="pr")
            parts_alias = aliased(Part, name="p")
            included_parts = included_parts.union_all(
                session.query(
                    parts_alias.sub_part,
                    parts_alias.part,
                    parts_alias.quantity).\
                        filter(parts_alias.part==incl_alias.c.sub_part)
                )
 
            q = session.query(
                    included_parts.c.sub_part,
                    func.sum(included_parts.c.quantity).
                        label('total_quantity')
                ).\
                group_by(included_parts.c.sub_part)
 
        .. seealso::
 
            :meth:`_sql.Select.cte` - v2 equivalent method.
 
        F)rúrr)rýrãÚcte)r™rúrrr~r~ršr…s =þÿz    Query.ctez
Label[Any])rúr•cCs| d¡ ¡ |¡S)zùReturn the full SELECT statement represented by this
        :class:`_query.Query`, converted
        to a scalar subquery with a label of the given name.
 
        .. seealso::
 
            :meth:`_sql.Select.label` - v2 comparable method.
 
        F)rýrãÚlabel)r™rúr~r~ršrÇs þÿz Query.labelzQuery[Tuple[_MAYBE_ENTITY]]zScalarSelect[_MAYBE_ENTITY]cCsdSr–r~r˜r~r~ršÚ    as_scalarØszQuery.as_scalarzQuery[Tuple[_NOT_ENTITY]]zScalarSelect[_NOT_ENTITY]cCsdSr–r~r˜r~r~ršrÞszScalarSelect[Any]cCsdSr–r~r˜r~r~ršräsú1.4z—The :meth:`_query.Query.as_scalar` method is deprecated and will be removed in a future release.  Please refer to :meth:`_query.Query.scalar_subquery`.cCs| ¡S)z}Return the full SELECT statement represented by this
        :class:`_query.Query`, converted to a scalar subquery.
 
        )Úscalar_subqueryr˜r~r~ršrès cCsdSr–r~r˜r~r~ršrõszQuery.scalar_subquerycCsdSr–r~r˜r~r~ršrûscCsdSr–r~r˜r~r~ršrscCs| d¡ ¡ ¡S)aÈReturn the full SELECT statement represented by this
        :class:`_query.Query`, converted to a scalar subquery.
 
        Analogous to
        :meth:`sqlalchemy.sql.expression.SelectBase.scalar_subquery`.
 
        .. versionchanged:: 1.4 The :meth:`_query.Query.scalar_subquery`
           method replaces the :meth:`_query.Query.as_scalar` method.
 
        .. seealso::
 
            :meth:`_sql.Select.scalar_subquery` - v2 comparable method.
 
        F)rýrãrr˜r~r~ršrsÿcCs| ¡S)z÷Return the :class:`_expression.Select` object emitted by this
        :class:`_query.Query`.
 
        Used for :func:`_sa.inspect` compatibility, this is equivalent to::
 
            query.enable_eagerloads(False).with_labels().statement
 
        )Ú__clause_element__r˜r~r~ršÚ
selectables
zQuery.selectablecCs|jddd t¡jS)NFT)Ú_enable_eagerloadsZ_render_for_subquery)Ú_with_compile_optionsrþrGrâr˜r~r~ršr    'sÿýÿzQuery.__clause_element__z Literal[True]zRowReturningQuery[Tuple[_O]])r™Úvaluer•cCsdSr–r~©r™r r~r~ršr¬0szQuery.only_return_tupleszLiteral[False]cCsdSr–r~rr~r~ršr¬6sú
Query[Any])r r•cCs|jt|d7_|S)aðWhen set to True, the query results will always be a
        :class:`.Row` object.
 
        This can change a query that normally returns a single entity
        as a scalar to return a :class:`.Row` result in all cases.
 
        .. seealso::
 
            :meth:`.Query.tuples` - returns tuples, but also at the typing
            level will type results as ``Tuple``.
 
            :meth:`_query.Query.is_single_entity`
 
            :meth:`_engine.Result.tuples` - v2 comparable method.
 
        )Ú_only_return_tuples)rÂÚdictrr~r~ršr¬<scCs>|jj o<t|jƒdko<d|jdjko<t|jdjdtƒS)a€Indicates if this :class:`_query.Query`
        returns tuples or single entities.
 
        Returns True if this query returns a single entity for each instance
        in its result list, and False if this query returns a tuple of entities
        for each result.
 
        .. versionadded:: 1.3.11
 
        .. seealso::
 
            :meth:`_query.Query.only_return_tuples`
 
        rr®r)rÂrr´rªr¯rÿr#r˜r~r~ršÚis_single_entityQs
 ÿþþüzQuery.is_single_entitycCs|jd|i7_|S)aControl whether or not eager joins and subqueries are
        rendered.
 
        When set to False, the returned Query will not render
        eager joins regardless of :func:`~sqlalchemy.orm.joinedload`,
        :func:`~sqlalchemy.orm.subqueryload` options
        or mapper-level ``lazy='joined'``/``lazy='subquery'``
        configurations.
 
        This is used primarily when nesting the Query's
        statement into a subquery or other
        selectable, or when using :meth:`_query.Query.yield_per`.
 
        r ©rŽrr~r~ršrýkszQuery.enable_eagerloads)Úoptr•cKs|j|7_|Sr–r©r™rr~r~ršr ~szQuery._with_compile_optionszB:meth:`_orm.Query.with_labels` and :meth:`_orm.Query.apply_labels`z<Use set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL) instead.)Ú alternativecCs | tj¡Sr–)rþrHrGr˜r~r~ršrûƒsÿzQuery.with_labelscCs|jS)z²
        Retrieve the current label style.
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :meth:`_sql.Select.get_label_style` - v2 equivalent method.
 
        )rr˜r~r~ršÚget_label_styles zQuery.get_label_style)Ústyler•cCs|j|k    r| ¡}||_|S)aðApply column labels to the return value of Query.statement.
 
        Indicates that this Query's `statement` accessor should return
        a SELECT statement that applies labels to all columns in the
        form <tablename>_<columnname>; this is commonly used to
        disambiguate columns from multiple tables which have the same
        name.
 
        When the `Query` actually issues SQL to load rows, it always
        uses column labeling.
 
        .. note:: The :meth:`_query.Query.set_label_style` method *only* applies
           the output of :attr:`_query.Query.statement`, and *not* to any of
           the result-row invoking systems of :class:`_query.Query` itself,
           e.g.
           :meth:`_query.Query.first`, :meth:`_query.Query.all`, etc.
           To execute
           a query using :meth:`_query.Query.set_label_style`, invoke the
           :attr:`_query.Query.statement` using :meth:`.Session.execute`::
 
                result = session.execute(
                    query
                    .set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
                    .statement
                )
 
        .. versionadded:: 1.4
 
 
        .. seealso::
 
            :meth:`_sql.Select.set_label_style` - v2 equivalent method.
 
        )rrß)r™rr~r~ršrþs#
zQuery.set_label_stylecCs
||_|S)aControl whether assertions are generated.
 
        When set to False, the returned Query will
        not assert its state before certain operations,
        including that LIMIT/OFFSET has not been applied
        when filter() is called, no criterion exists
        when get() is called, and no "from_statement()"
        exists when filter()/order_by()/group_by() etc.
        is called.  This more permissive mode is used by
        custom Query subclasses to specify criterion or
        other modifiers outside of the usual usage patterns.
 
        Care should be taken to ensure that the usage
        pattern is even possible.  A statement applied
        by from_statement() will override any criterion
        set by filter() or order_by(), for example.
 
        )rÎrr~r~ršÚenable_assertionsÅszQuery.enable_assertionszOptional[ColumnElement[bool]]cCs t |j¡S)a3A readonly attribute which returns the current WHERE criterion for
        this Query.
 
        This returned value is a SQL expression construct, or ``None`` if no
        criterion has been established.
 
        .. seealso::
 
            :attr:`_sql.Select.whereclause` - v2 equivalent property.
 
        )r?Z_construct_for_whereclauserr˜r~r~ršÚ whereclauseÜs ÿzQuery.whereclauserP)Úpathr•cCs|jd|i7_|S)aindicate that this query applies to objects loaded
        within a certain path.
 
        Used by deferred loaders (see strategies.py) which transfer
        query options from an originating query to a newly generated
        query intended for the deferred load.
 
        Ú _current_pathr)r™rr~r~ršÚ_with_current_pathís
zQuery._with_current_pathÚint)Úcountr•cCs|jd|i7_|S)a¡Yield only ``count`` rows at a time.
 
        The purpose of this method is when fetching very large result sets
        (> 10K rows), to batch results in sub-collections and yield them
        out partially, so that the Python interpreter doesn't need to declare
        very large areas of memory which is both time consuming and leads
        to excessive memory use.   The performance from fetching hundreds of
        thousands of rows can often double when a suitable yield-per setting
        (e.g. approximately 1000) is used, even with DBAPIs that buffer
        rows (which are most).
 
        As of SQLAlchemy 1.4, the :meth:`_orm.Query.yield_per` method is
        equivalent to using the ``yield_per`` execution option at the ORM
        level. See the section :ref:`orm_queryguide_yield_per` for further
        background on this option.
 
        .. seealso::
 
            :ref:`orm_queryguide_yield_per`
 
        Ú
_yield_perrÁ)r™rr~r~ršÚ    yield_perúszQuery.yield_perz:meth:`_orm.Query.get`z7The method is now available as :meth:`_orm.Session.get`rQ)Úidentr•cCs|jdddd| |tj¡S)a® Return an instance based on the given primary key identifier,
        or ``None`` if not found.
 
        E.g.::
 
            my_user = session.query(User).get(5)
 
            some_object = session.query(VersionedFoo).get((5, 10))
 
            some_object = session.query(VersionedFoo).get(
                {"id": 5, "version_id": 10})
 
        :meth:`_query.Query.get` is special in that it provides direct
        access to the identity map of the owning :class:`.Session`.
        If the given primary key identifier is present
        in the local identity map, the object is returned
        directly from this collection and no SQL is emitted,
        unless the object has been marked fully expired.
        If not present,
        a SELECT is performed in order to locate the object.
 
        :meth:`_query.Query.get` also will perform a check if
        the object is present in the identity map and
        marked as expired - a SELECT
        is emitted to refresh the object as well as to
        ensure that the row is still present.
        If not, :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised.
 
        :meth:`_query.Query.get` is only used to return a single
        mapped instance, not multiple instances or
        individual column constructs, and strictly
        on a single primary key value.  The originating
        :class:`_query.Query` must be constructed in this way,
        i.e. against a single mapped entity,
        with no additional filtering criterion.  Loading
        options via :meth:`_query.Query.options` may be applied
        however, and will be used if the object is not
        yet locally present.
 
        :param ident: A scalar, tuple, or dictionary representing the
         primary key.  For a composite (e.g. multiple column) primary key,
         a tuple or dictionary should be passed.
 
         For a single-column primary key, the scalar calling form is typically
         the most expedient.  If the primary key of a row is the value "5",
         the call looks like::
 
            my_object = query.get(5)
 
         The tuple form contains primary key values typically in
         the order in which they correspond to the mapped
         :class:`_schema.Table`
         object's primary key columns, or if the
         :paramref:`_orm.Mapper.primary_key` configuration parameter were
         used, in
         the order used for that parameter. For example, if the primary key
         of a row is represented by the integer
         digits "5, 10" the call would look like::
 
             my_object = query.get((5, 10))
 
         The dictionary form should include as keys the mapped attribute names
         corresponding to each element of the primary key.  If the mapped class
         has the attributes ``id``, ``version_id`` as the attributes which
         store the object's primary key value, the call would look like::
 
            my_object = query.get({"id": 5, "version_id": 10})
 
         .. versionadded:: 1.3 the :meth:`_query.Query.get`
            method now optionally
            accepts a dictionary of attribute names to values in order to
            indicate a primary key identifier.
 
 
        :return: The object instance, or ``None``.
 
        rÄFrÅ)rÊÚ    _get_implrZload_on_pk_identity)r™r"r~r~ršrÄsRz    Query.getzCallable[..., Any])Úprimary_key_identityÚ
db_load_fnrÙr•c
Cs0| d¡}|jj||||jj|j|j||jdS)NrÄ)rÕÚwith_for_updateÚoptionsrÙÚexecution_options)r·r’r#rÂrÚrˆrrñ)r™r$r%rÙÚmapperr~r~ršr#ls
øzQuery._get_implcCs|jjS)a An :class:`.InstanceState` that is using this :class:`_query.Query`
        for a lazy load operation.
 
        .. deprecated:: 1.4  This attribute should be viewed via the
           :attr:`.ORMExecuteState.lazy_loaded_from` attribute, within
           the context of the :meth:`.SessionEvents.do_orm_execute`
           event.
 
        .. seealso::
 
            :attr:`.ORMExecuteState.lazy_loaded_from`
 
        )rÂrÀr˜r~r~ršÚlazy_loaded_from~szQuery.lazy_loaded_fromcCs|jjSr–)rŽrr˜r~r~ršrszQuery._current_pathz2Union[Literal[(None, False)], _FromClauseArgument])Ú fromclausesr•cGs<d|_|r|ddkrd|_n|jtdd„|Dƒƒ|_|S)ažReturn a :class:`.Query` construct which will correlate the given
        FROM clauses to that of an enclosing :class:`.Query` or
        :func:`~.expression.select`.
 
        The method here accepts mapped classes, :func:`.aliased` constructs,
        and :class:`_orm.Mapper` constructs as arguments, which are resolved
        into expression constructs, in addition to appropriate expression
        constructs.
 
        The correlation arguments are ultimately passed to
        :meth:`_expression.Select.correlate`
        after coercion to expression constructs.
 
        The correlation arguments take effect in such cases
        as when :meth:`_query.Query.from_self` is used, or when
        a subquery as returned by :meth:`_query.Query.subquery` is
        embedded in another :func:`_expression.select` construct.
 
        .. seealso::
 
            :meth:`_sql.Select.correlate` - v2 equivalent method.
 
        Fr>NFr~css|]}t tj|¡VqdSr–)r1r¥r3ZFromClauseRole)r§Úfr~r~ršÚ    <genexpr>´sz"Query.correlate.<locals>.<genexpr>)rŠr‰r¼)r™r+r~r~ršÚ    correlate“s ÿ zQuery.correlate)Úsettingr•cCs|jd|i7_|S)a?Return a Query with a specific 'autoflush' setting.
 
        As of SQLAlchemy 1.4, the :meth:`_orm.Query.autoflush` method
        is equivalent to using the ``autoflush`` execution option at the
        ORM level. See the section :ref:`orm_queryguide_autoflush` for
        further background on this option.
 
        Z
_autoflushrÁ)r™r/r~r~ršÚ    autoflush¹s
zQuery.autoflushcCs|jddi7_|S)a¿Return a :class:`_query.Query`
        that will expire and refresh all instances
        as they are loaded, or reused from the current :class:`.Session`.
 
        As of SQLAlchemy 1.4, the :meth:`_orm.Query.populate_existing` method
        is equivalent to using the ``populate_existing`` execution option at
        the ORM level. See the section :ref:`orm_queryguide_populate_existing`
        for further background on this option.
 
        rÚTrÁr˜r~r~ršrÕÆs zQuery.populate_existingcCs|jd|i7_|S)zêSet the 'invoke all eagers' flag which causes joined- and
        subquery loaders to traverse into already-loaded related objects
        and collections.
 
        Default is that of :attr:`_query.Query._invoke_all_eagers`.
 
        Z_invoke_all_eagersrÁrr~r~ršÚ_with_invoke_all_eagersÕs    zQuery._with_invoke_all_eagersz:meth:`_orm.Query.with_parent`z6Use the :func:`_orm.with_parent` standalone construct.zsqlalchemy.orm.relationshipsÚobjectz,Optional[attributes.QueryableAttribute[Any]]z"Optional[_ExternalEntityType[Any]])ÚinstanceÚpropertyÚ from_entityr•cCsŠtjj}|rt|ƒ}nt|ƒ}|dkrvt|ƒ}|jD]$}t||jƒr4|j    |j    kr4|}qvq4t
  d|j    j j |jj f¡‚| t|||jƒ¡S)aAdd filtering criterion that relates the given instance
        to a child object or collection, using its attribute state
        as well as an established :func:`_orm.relationship()`
        configuration.
 
        The method uses the :func:`.with_parent` function to generate
        the clause, the result of which is passed to
        :meth:`_query.Query.filter`.
 
        Parameters are the same as :func:`.with_parent`, with the exception
        that the given property can be None, in which case a search is
        performed against this :class:`_query.Query` object's target mapper.
 
        :param instance:
          An instance which has some :func:`_orm.relationship`.
 
        :param property:
          Class bound attribute which indicates
          what relationship from the instance should be used to reconcile the
          parent/child relationship.
 
        :param from_entity:
          Entity in which to consider as the left side.  This defaults to the
          "zero" entity of the :class:`_query.Query` itself.
 
        Nz\Could not locate a property which relates instances of class '%s' to instances of class '%s')rZ    preloadedZorm_relationshipsr)rr%Ziterate_propertiesrÿZRelationshipPropertyr)rµr¶Úclass_Ú__name__Ú    __class__Úfilterr&Úentity)r™r3r4r5Z relationshipsZ entity_zeror)Úpropr~r~ršr&ás6'
 
 
ÿ
þþþÿ    ýÿzQuery.with_parentz_EntityType[Any]z Optional[Union[Alias, Subquery]])r:Úaliasr•cCs<|dk    rt||ƒ}t|jƒ|_|j tjtj||d¡|S)z­add a mapped entity to the list of result columns
        to be returned.
 
        .. seealso::
 
            :meth:`_sql.Select.add_columns` - v2 comparable method.
        N©r£)r$ÚlistrªÚappendr1r¥r3r¦)r™r:r<r~r~ršÚ
add_entity+s
 ÿÿzQuery.add_entity)r’r•cCs
||_|S)aReturn a :class:`_query.Query` that will use the given
        :class:`.Session`.
 
        While the :class:`_query.Query`
        object is normally instantiated using the
        :meth:`.Session.query` method, it is legal to build the
        :class:`_query.Query`
        directly without necessarily using a :class:`.Session`.  Such a
        :class:`_query.Query` object, or any :class:`_query.Query`
        already associated
        with a different :class:`.Session`, can produce a new
        :class:`_query.Query`
        object associated with a target session using this method::
 
            from sqlalchemy.orm import Query
 
            query = Query([MyClass]).filter(MyClass.id == 5)
 
            result = query.with_session(my_session).one()
 
        )r’)r™r’r~r~ršÚ with_sessionFszQuery.with_sessionz_ColumnsClauseArgument[Any]cGs4| t¡ d¡ ¡ ¡}| |¡}|r0| |¡|Sr–)rþrGr.rZ_anonymous_fromclauseÚ_from_selectabler)r™rœÚ
fromclauserìr~r~ršÚ_legacy_from_selfas
ÿ
ÿ
 
zQuery._legacy_from_self)Úvalr•cCs|jd|i7_|S)NÚ_enable_single_critr)r™rEr~r~ršÚ_set_enable_single_crittszQuery._set_enable_single_critrx)rCÚset_entity_fromr•cCs<dD]}|j |d¡q| |g|¡|jddi7_|S)N) rrr‚rƒr„Ú_last_joined_entityrŒÚ_memoized_select_entitiesr†r‡r€Ú    _prefixesZ    _suffixesrFF)rôrör¾rŽ)r™rCrHÚattrr~r~ršrBysÿzQuery._from_selectablez:meth:`_query.Query.values` is deprecated and will be removed in a future release.  Please use :meth:`_query.Query.with_entities`z Iterable[Any])Úcolumnsr•cGs
|j|ŽS)zfReturn an iterator yielding result tuples corresponding
        to the given list of columns
 
        )Ú_values_no_warn)r™rMr~r~ršrŸ”s z Query.valuescGsF|s tdƒS| ¡ d¡}| |¡|jjs>|jddi7_t|ƒS)Nr~Fr é
)ÚiterràrýrrÂr )r™rMrìr~r~ršrN£s
zQuery._values_no_warnz°:meth:`_query.Query.value` is deprecated and will be removed in a future release.  Please use :meth:`_query.Query.with_entities` in combination with :meth:`_query.Query.scalar`z_ColumnExpressionArgument[Any])Úcolumnr•cCs0zt| |¡ƒdWStk
r*YdSXdS)zVReturn a scalar result corresponding to the given
        column expression.
 
        rN)ÚnextrNÚ StopIteration©r™rQr~r~ršr ®s z Query.valuez_EntityType[_O])Ú_entityr•cCsdSr–r~)r™rUr~r~ršÚ with_entities¿szQuery.with_entitiesz roles.TypedColumnsClauseRole[_T]zRowReturningQuery[Tuple[_T]])Ú_colexprr•cCsdSr–r~)r™rWr~r~ršrVÃsz
_TCCA[_T0]z
_TCCA[_T1]z"RowReturningQuery[Tuple[_T0, _T1]])Ú _Query__ent0Ú _Query__ent1r•cCsdSr–r~)r™rXrYr~r~ršrVÏsz
_TCCA[_T2]z'RowReturningQuery[Tuple[_T0, _T1, _T2]])rXrYÚ _Query__ent2r•cCsdSr–r~)r™rXrYrZr~r~ršrVÕsz
_TCCA[_T3]z,RowReturningQuery[Tuple[_T0, _T1, _T2, _T3]])rXrYrZÚ _Query__ent3r•cCsdSr–r~)r™rXrYrZr[r~r~ršrVÛsz
_TCCA[_T4]z1RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4]])rXrYrZr[Ú _Query__ent4r•cCsdSr–r~)r™rXrYrZr[r\r~r~ršrVås    z
_TCCA[_T5]z6RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4, _T5]])rXrYrZr[r\Ú _Query__ent5r•cCsdSr–r~)r™rXrYrZr[r\r]r~r~ršrVðs
z
_TCCA[_T6]z;RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6]])rXrYrZr[r\r]Ú _Query__ent6r•cCsdSr–r~)r™rXrYrZr[r\r]r^r~r~ršrVüs z
_TCCA[_T7]z@RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7]])    rXrYrZr[r\r]r^Ú _Query__ent7r•c        CsdSr–r~)    r™rXrYrZr[r\r]r^r_r~r~ršrV    s cGsdSr–r~r«r~r~ršrVs)rœÚ
_Query__kwr•cOs"|r
tƒ‚t |¡| |¡|S)a—Return a new :class:`_query.Query`
        replacing the SELECT list with the
        given entities.
 
        e.g.::
 
            # Users, filtered on some arbitrary criterion
            # and then ordered by related email address
            q = session.query(User).\
                        join(User.address).\
                        filter(User.name.like('%ed%')).\
                        order_by(Address.email)
 
            # given *only* User.id==5, Address.email, and 'q', what
            # would the *next* User in the result be ?
            subq = q.with_entities(Address.email).\
                        order_by(None).\
                        filter(User.id==5).\
                        subquery()
            q = q.join((subq, subq.c.email < Address.email)).\
                        limit(1)
 
        .. seealso::
 
            :meth:`_sql.Select.with_only_columns` - v2 comparable method.
        )rbrAZ_generate_for_statementr)r™rœr`r~r~ršrVs
 
 
cs*tˆjƒˆ_ˆj ‡fdd„|Dƒ¡ˆS)z¼Add one or more column expressions to the list
        of result columns to be returned.
 
        .. seealso::
 
            :meth:`_sql.Select.add_columns` - v2 comparable method.
        c3s"|]}tjtj|ˆddVqdS)Tr¢Nr¤)r§Úcr˜r~ršr-Usúüz$Query.add_columns.<locals>.<genexpr>)r>rªÚextendrTr~r˜ršÚ add_columnsGs
ù    zQuery.add_columnszƒ:meth:`_query.Query.add_column` is deprecated and will be removed in a future release.  Please use :meth:`_query.Query.add_columns`cCs
| |¡S)zWAdd a column expression to the list of result columns to be
        returned.
 
        )rcrTr~r~ršÚ
add_column`s zQuery.add_columnrp)Úargsr•cGsjtt |¡ƒ}|jjr8|D]}|js|jr| |¡qn |D]}|js<|jr<| |¡q<|j    |7_    |S)aKReturn a new :class:`_query.Query` object,
        applying the given list of
        mapper options.
 
        Most supplied options regard changing how column- and
        relationship-mapped attributes are loaded.
 
        .. seealso::
 
            :ref:`loading_columns`
 
            :ref:`relationship_loader_options`
 
        )
r¼rZflatten_iteratorrŽrZ_is_coreZ_is_legacy_optionZprocess_query_conditionallyZ process_queryr)r™reÚoptsrr~r~ršr'ms   z Query.optionsz"Callable[[Query[Any]], Query[Any]])rør•cCs||ƒS)aªReturn a new :class:`_query.Query` object transformed by
        the given function.
 
        E.g.::
 
            def filter_something(criterion):
                def transform(q):
                    return q.filter(criterion)
                return transform
 
            q = q.with_transformation(filter_something(x==5))
 
        This allows ad-hoc recipes to be created for :class:`_query.Query`
        objects.
 
        r~)r™rør~r~ršÚwith_transformationŒszQuery.with_transformationrUcCs|jS)aGet the non-SQL options which will take effect during execution.
 
        .. versionadded:: 1.3
 
        .. seealso::
 
            :meth:`_query.Query.execution_options`
 
            :meth:`_sql.Select.get_execution_options` - v2 comparable method.
 
        )rñr˜r~r~ršÚget_execution_options¡s zQuery.get_execution_options.) Úcompiled_cacheÚ logging_tokenÚisolation_levelÚ no_parametersÚstream_resultsÚmax_row_bufferr!Úinsertmanyvalues_page_sizeÚschema_translate_maprÕr0zOptional[CompiledCacheType]rWz Optional[SchemaTranslateMapType]) rirjrkrlrmrnr!rorprÕr0rr•c KsdSr–r~) r™rirjrkrlrmrnr!rorprÕr0rr~r~ršr(¯szQuery.execution_optionscKsdSr–r~rr~r~ršr(Âs)Úkwargsr•cKs|j |¡|_|S)a‰Set non-SQL options which take effect during execution.
 
        Options allowed here include all of those accepted by
        :meth:`_engine.Connection.execution_options`, as well as a series
        of ORM specific options:
 
        ``populate_existing=True`` - equivalent to using
        :meth:`_orm.Query.populate_existing`
 
        ``autoflush=True|False`` - equivalent to using
        :meth:`_orm.Query.autoflush`
 
        ``yield_per=<value>`` - equivalent to using
        :meth:`_orm.Query.yield_per`
 
        Note that the ``stream_results`` execution option is enabled
        automatically if the :meth:`~sqlalchemy.orm.query.Query.yield_per()`
        method or execution option is used.
 
        .. versionadded:: 1.4 - added ORM options to
           :meth:`_orm.Query.execution_options`
 
        The execution options may also be specified on a per execution basis
        when using :term:`2.0 style` queries via the
        :paramref:`_orm.Session.execution_options` parameter.
 
        .. warning:: The
           :paramref:`_engine.Connection.execution_options.stream_results`
           parameter should not be used at the level of individual ORM
           statement executions, as the :class:`_orm.Session` will not track
           objects from different schema translate maps within a single
           session.  For multiple schema translate maps within the scope of a
           single :class:`_orm.Session`, see :ref:`examples_sharding`.
 
 
        .. seealso::
 
            :ref:`engine_stream_results`
 
            :meth:`_query.Query.get_execution_options`
 
            :meth:`_sql.Select.execution_options` - v2 equivalent method.
 
        )rñr÷)r™rqr~r~ršr(Æs.)ÚnowaitÚreadÚofÚ skip_lockedÚ    key_sharezYOptional[Union[_ColumnExpressionArgument[Any], Sequence[_ColumnExpressionArgument[Any]]]])rrrsrtrurvr•cCst|||||d|_|S)aÎreturn a new :class:`_query.Query`
        with the specified options for the
        ``FOR UPDATE`` clause.
 
        The behavior of this method is identical to that of
        :meth:`_expression.GenerativeSelect.with_for_update`.
        When called with no arguments,
        the resulting ``SELECT`` statement will have a ``FOR UPDATE`` clause
        appended.  When additional arguments are specified, backend-specific
        options such as ``FOR UPDATE NOWAIT`` or ``LOCK IN SHARE MODE``
        can take effect.
 
        E.g.::
 
            q = sess.query(User).populate_existing().with_for_update(nowait=True, of=User)
 
        The above query on a PostgreSQL backend will render like::
 
            SELECT users.id AS users_id FROM users FOR UPDATE OF users NOWAIT
 
        .. warning::
 
            Using ``with_for_update`` in the context of eager loading
            relationships is not officially supported or recommended by
            SQLAlchemy and may not work with certain queries on various
            database backends.  When ``with_for_update`` is successfully used
            with a query that involves :func:`_orm.joinedload`, SQLAlchemy will
            attempt to emit SQL that locks all involved tables.
 
        .. note::  It is generally a good idea to combine the use of the
           :meth:`_orm.Query.populate_existing` method when using the
           :meth:`_orm.Query.with_for_update` method.   The purpose of
           :meth:`_orm.Query.populate_existing` is to force all the data read
           from the SELECT to be populated into the ORM objects returned,
           even if these objects are already in the :term:`identity map`.
 
        .. seealso::
 
            :meth:`_expression.GenerativeSelect.with_for_update`
            - Core level method with
            full argument and behavioral description.
 
            :meth:`_orm.Query.populate_existing` - overwrites attributes of
            objects already loaded in the identity map.
 
        )rsrrrtrurv)rCrˆ)r™rrrsrtrurvr~r~ršr&÷s>ûzQuery.with_for_updatezOptional[Dict[str, Any]])Ú_Query__paramsrÞr•cKs |r| |¡|j |¡|_|S)aƒAdd values for bind parameters which may have been
        specified in filter().
 
        Parameters may be specified using \**kwargs, or optionally a single
        dictionary as the first positional argument. The reason for both is
        that \**kwargs is convenient, however some parameter dictionaries
        contain unicode keys in which case \**kwargs cannot be used.
 
        )rõrr÷)r™rwrÞr~r~ršrè>s 
z Query.paramsz_ColumnExpressionArgument[bool])Ú    criterionr•cGs
|j|ŽS)z¢A synonym for :meth:`.Query.filter`.
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :meth:`_sql.Select.where` - v2 equivalent method.
 
        )r9)r™rxr~r~ršÚwherePs
z Query.wherecGs4t|ƒD]&}tjtj||d}|j|f7_q|S)a`Apply the given filtering criterion to a copy
        of this :class:`_query.Query`, using SQL expressions.
 
        e.g.::
 
            session.query(MyClass).filter(MyClass.name == 'some name')
 
        Multiple criteria may be specified as comma separated; the effect
        is that they will be joined together using the :func:`.and_`
        function::
 
            session.query(MyClass).\
                filter(MyClass.name == 'some name', MyClass.id > 5)
 
        The criterion is any SQL expression object applicable to the
        WHERE clause of a select.   String expressions are coerced
        into SQL expression constructs via the :func:`_expression.text`
        construct.
 
        .. seealso::
 
            :meth:`_query.Query.filter_by` - filter on keyword expressions.
 
            :meth:`_sql.Select.where` - v2 equivalent method.
 
        r=)r>r1r¥r3ÚWhereHavingRoler)r™rxÚcritr~r~ršr9\s ÿz Query.filterz=Optional[Union[_InternalEntityType[Any], _JoinTargetElement]]cCs|jrt|jƒSdSdSr–)rŒrr˜r~r~ršrIs
ÿzQuery._last_joined_entitycCs:|jr|j}|dk    r|S|jr0|jjs0|jdS|jdS)z“for the filter_by() method, return the target entity for which
        we will attempt to derive an expression from based on string name.
 
        Nr)rŒrIr‹rŽr»rª)r™rIr~r~ršÚ_filter_by_zeroŒs
zQuery._filter_by_zeroc s(| ¡‰‡fdd„| ¡Dƒ}|j|ŽS)aApply the given filtering criterion to a copy
        of this :class:`_query.Query`, using keyword expressions.
 
        e.g.::
 
            session.query(MyClass).filter_by(name = 'some name')
 
        Multiple criteria may be specified as comma separated; the effect
        is that they will be joined together using the :func:`.and_`
        function::
 
            session.query(MyClass).\
                filter_by(name = 'some name', id = 5)
 
        The keyword expressions are extracted from the primary
        entity of the query, or the last entity that was the
        target of a call to :meth:`_query.Query.join`.
 
        .. seealso::
 
            :meth:`_query.Query.filter` - filter on SQL expressions.
 
            :meth:`_sql.Select.filter_by` - v2 comparable method.
 
        csg|]\}}tˆ|ƒ|k‘qSr~r9)r§Úkeyr ©r5r~ršr©Òsÿz#Query.filter_by.<locals>.<listcomp>)r|Úitemsr9)r™rqÚclausesr~r~ršÚ    filter_by¶s
 
þzQuery.filter_byzTUnion[Literal[None, False, _NoArg.NO_ARG], _ColumnExpressionOrStrLabelArgument[Any]]z(_ColumnExpressionOrStrLabelArgument[Any])Ú _Query__firstr€r•cGsj|j|jfD] }|dƒq |s6|dks.|dkr6d|_n0|tjk    rftdd„|f|Dƒƒ}|j|7_|S)aôApply one or more ORDER BY criteria to the query and return
        the newly resulting :class:`_query.Query`.
 
        e.g.::
 
            q = session.query(Entity).order_by(Entity.id, Entity.name)
 
        Calling this method multiple times is equivalent to calling it once
        with all the clauses concatenated. All existing ORDER BY criteria may
        be cancelled by passing ``None`` by itself.  New ORDER BY criteria may
        then be added by invoking :meth:`_orm.Query.order_by` again, e.g.::
 
            # will erase all ORDER BY and ORDER BY new_col alone
            q = q.order_by(None).order_by(new_col)
 
        .. seealso::
 
            These sections describe ORDER BY in terms of :term:`2.0 style`
            invocation but apply to :class:`_orm.Query` as well:
 
            :ref:`tutorial_order_by` - in the :ref:`unified_tutorial`
 
            :ref:`tutorial_order_by_label` - in the :ref:`unified_tutorial`
 
            :meth:`_sql.Select.order_by` - v2 equivalent method.
 
        rÆNFr~css|]}t tj|¡VqdSr–)r1r¥r3Z OrderByRole©r§Úclauser~r~ršr-sÿz!Query.order_by.<locals>.<genexpr>)rÒrÓrr<ÚNO_ARGr¼©r™r‚r€Z    assertionrxr~r~ršrÆØs%
 
þzQuery.order_bycGsj|j|jfD] }|dƒq |s6|dks.|dkr6d|_n0|tjk    rftdd„|f|Dƒƒ}|j|7_|S)aªApply one or more GROUP BY criterion to the query and return
        the newly resulting :class:`_query.Query`.
 
        All existing GROUP BY settings can be suppressed by
        passing ``None`` - this will suppress any GROUP BY configured
        on mappers as well.
 
        .. seealso::
 
            These sections describe GROUP BY in terms of :term:`2.0 style`
            invocation but apply to :class:`_orm.Query` as well:
 
            :ref:`tutorial_group_by_w_aggregates` - in the
            :ref:`unified_tutorial`
 
            :ref:`tutorial_order_by_label` - in the :ref:`unified_tutorial`
 
            :meth:`_sql.Select.group_by` - v2 equivalent method.
 
        Úgroup_byNFr~css|]}t tj|¡VqdSr–)r1r¥r3Z GroupByRolerƒr~r~ršr-/sÿz!Query.group_by.<locals>.<genexpr>)rÒrÓr‚r<r…r¼r†r~r~ršr‡ s
 
þzQuery.group_by)Úhavingr•cGs,|D]"}t tj|¡}|j|f7_q|S)aoApply a HAVING criterion to the query and return the
        newly resulting :class:`_query.Query`.
 
        :meth:`_query.Query.having` is used in conjunction with
        :meth:`_query.Query.group_by`.
 
        HAVING criterion makes it possible to use filters on aggregate
        functions like COUNT, SUM, AVG, MAX, and MIN, eg.::
 
            q = session.query(User.id).\
                        join(User.addresses).\
                        group_by(User.id).\
                        having(func.count(Address.id) > 2)
 
        .. seealso::
 
            :meth:`_sql.Select.having` - v2 equivalent method.
 
        )r1r¥r3rzr€)r™rˆrxZhaving_criteriar~r~ršrˆ6sÿz Query.having)Úexpr_fnrìr•cGs|f|}| ||Ž ¡¡Sr–)rBr)r™r‰rìZlist_of_queriesr~r~ršÚ_set_opTs
z Query._set_op)rìr•cGs|jtjf|žŽS)aéProduce a UNION of this Query against one or more queries.
 
        e.g.::
 
            q1 = sess.query(SomeClass).filter(SomeClass.foo=='bar')
            q2 = sess.query(SomeClass).filter(SomeClass.bar=='foo')
 
            q3 = q1.union(q2)
 
        The method accepts multiple Query objects so as to control
        the level of nesting.  A series of ``union()`` calls such as::
 
            x.union(y).union(z).all()
 
        will nest on each ``union()``, and produces::
 
            SELECT * FROM (SELECT * FROM (SELECT * FROM X UNION
                            SELECT * FROM y) UNION SELECT * FROM Z)
 
        Whereas::
 
            x.union(y, z).all()
 
        produces::
 
            SELECT * FROM (SELECT * FROM X UNION SELECT * FROM y UNION
                            SELECT * FROM Z)
 
        Note that many database backends do not allow ORDER BY to
        be rendered on a query called within UNION, EXCEPT, etc.
        To disable all ORDER BY clauses including those configured
        on mappers, issue ``query.order_by(None)`` - the resulting
        :class:`_query.Query` object will not render ORDER BY within
        its SELECT statement.
 
        .. seealso::
 
            :meth:`_sql.Select.union` - v2 equivalent method.
 
        )rŠr2r÷©r™rìr~r~ršr÷Xs)z Query.unioncGs|jtjf|žŽS)aProduce a UNION ALL of this Query against one or more queries.
 
        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.
 
        .. seealso::
 
            :meth:`_sql.Select.union_all` - v2 equivalent method.
 
        )rŠr2Ú    union_allr‹r~r~ršrŒƒs zQuery.union_allcGs|jtjf|žŽS)aProduce an INTERSECT of this Query against one or more queries.
 
        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.
 
        .. seealso::
 
            :meth:`_sql.Select.intersect` - v2 equivalent method.
 
        )rŠr2Ú    intersectr‹r~r~ršrs zQuery.intersectcGs|jtjf|žŽS)a Produce an INTERSECT ALL of this Query against one or more queries.
 
        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.
 
        .. seealso::
 
            :meth:`_sql.Select.intersect_all` - v2 equivalent method.
 
        )rŠr2Ú intersect_allr‹r~r~ršrŽs zQuery.intersect_allcGs|jtjf|žŽS)aProduce an EXCEPT of this Query against one or more queries.
 
        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.
 
        .. seealso::
 
            :meth:`_sql.Select.except_` - v2 equivalent method.
 
        )rŠr2Úexcept_r‹r~r~ršrªs z Query.except_cGs|jtjf|žŽS)aProduce an EXCEPT ALL of this Query against one or more queries.
 
        Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See
        that method for usage examples.
 
        .. seealso::
 
            :meth:`_sql.Select.except_all` - v2 equivalent method.
 
        )rŠr2Ú
except_allr‹r~r~ršr·s zQuery.except_all©ÚisouterÚfullr_zOptional[_OnClauseArgument])ÚtargetÚonclauser’r“r•cCsdtjtj||dd}|dk    r0tjtj|dd}nd}|j||d||dœff7_|j dd¡|S)a‘Create a SQL JOIN against this :class:`_query.Query`
        object's criterion
        and apply generatively, returning the newly resulting
        :class:`_query.Query`.
 
        **Simple Relationship Joins**
 
        Consider a mapping between two classes ``User`` and ``Address``,
        with a relationship ``User.addresses`` representing a collection
        of ``Address`` objects associated with each ``User``.   The most
        common usage of :meth:`_query.Query.join`
        is to create a JOIN along this
        relationship, using the ``User.addresses`` attribute as an indicator
        for how this should occur::
 
            q = session.query(User).join(User.addresses)
 
        Where above, the call to :meth:`_query.Query.join` along
        ``User.addresses`` will result in SQL approximately equivalent to::
 
            SELECT user.id, user.name
            FROM user JOIN address ON user.id = address.user_id
 
        In the above example we refer to ``User.addresses`` as passed to
        :meth:`_query.Query.join` as the "on clause", that is, it indicates
        how the "ON" portion of the JOIN should be constructed.
 
        To construct a chain of joins, multiple :meth:`_query.Query.join`
        calls may be used.  The relationship-bound attribute implies both
        the left and right side of the join at once::
 
            q = session.query(User).\
                    join(User.orders).\
                    join(Order.items).\
                    join(Item.keywords)
 
        .. note:: as seen in the above example, **the order in which each
           call to the join() method occurs is important**.    Query would not,
           for example, know how to join correctly if we were to specify
           ``User``, then ``Item``, then ``Order``, in our chain of joins; in
           such a case, depending on the arguments passed, it may raise an
           error that it doesn't know how to join, or it may produce invalid
           SQL in which case the database will raise an error. In correct
           practice, the
           :meth:`_query.Query.join` method is invoked in such a way that lines
           up with how we would want the JOIN clauses in SQL to be
           rendered, and each call should represent a clear link from what
           precedes it.
 
        **Joins to a Target Entity or Selectable**
 
        A second form of :meth:`_query.Query.join` allows any mapped entity or
        core selectable construct as a target.   In this usage,
        :meth:`_query.Query.join` will attempt to create a JOIN along the
        natural foreign key relationship between two entities::
 
            q = session.query(User).join(Address)
 
        In the above calling form, :meth:`_query.Query.join` is called upon to
        create the "on clause" automatically for us.  This calling form will
        ultimately raise an error if either there are no foreign keys between
        the two entities, or if there are multiple foreign key linkages between
        the target entity and the entity or entities already present on the
        left side such that creating a join requires more information.  Note
        that when indicating a join to a target without any ON clause, ORM
        configured relationships are not taken into account.
 
        **Joins to a Target with an ON Clause**
 
        The third calling form allows both the target entity as well
        as the ON clause to be passed explicitly.    A example that includes
        a SQL expression as the ON clause is as follows::
 
            q = session.query(User).join(Address, User.id==Address.user_id)
 
        The above form may also use a relationship-bound attribute as the
        ON clause as well::
 
            q = session.query(User).join(Address, User.addresses)
 
        The above syntax can be useful for the case where we wish
        to join to an alias of a particular target entity.  If we wanted
        to join to ``Address`` twice, it could be achieved using two
        aliases set up using the :func:`~sqlalchemy.orm.aliased` function::
 
            a1 = aliased(Address)
            a2 = aliased(Address)
 
            q = session.query(User).\
                    join(a1, User.addresses).\
                    join(a2, User.addresses).\
                    filter(a1.email_address=='ed@foo.com').\
                    filter(a2.email_address=='ed@bar.com')
 
        The relationship-bound calling form can also specify a target entity
        using the :meth:`_orm.PropComparator.of_type` method; a query
        equivalent to the one above would be::
 
            a1 = aliased(Address)
            a2 = aliased(Address)
 
            q = session.query(User).\
                    join(User.addresses.of_type(a1)).\
                    join(User.addresses.of_type(a2)).\
                    filter(a1.email_address == 'ed@foo.com').\
                    filter(a2.email_address == 'ed@bar.com')
 
        **Augmenting Built-in ON Clauses**
 
        As a substitute for providing a full custom ON condition for an
        existing relationship, the :meth:`_orm.PropComparator.and_` function
        may be applied to a relationship attribute to augment additional
        criteria into the ON clause; the additional criteria will be combined
        with the default criteria using AND::
 
            q = session.query(User).join(
                User.addresses.and_(Address.email_address != 'foo@bar.com')
            )
 
        .. versionadded:: 1.4
 
        **Joining to Tables and Subqueries**
 
 
        The target of a join may also be any table or SELECT statement,
        which may be related to a target entity or not.   Use the
        appropriate ``.subquery()`` method in order to make a subquery
        out of a query::
 
            subq = session.query(Address).\
                filter(Address.email_address == 'ed@foo.com').\
                subquery()
 
 
            q = session.query(User).join(
                subq, User.id == subq.c.user_id
            )
 
        Joining to a subquery in terms of a specific relationship and/or
        target entity may be achieved by linking the subquery to the
        entity using :func:`_orm.aliased`::
 
            subq = session.query(Address).\
                filter(Address.email_address == 'ed@foo.com').\
                subquery()
 
            address_subq = aliased(Address, subq)
 
            q = session.query(User).join(
                User.addresses.of_type(address_subq)
            )
 
 
        **Controlling what to Join From**
 
        In cases where the left side of the current state of
        :class:`_query.Query` is not in line with what we want to join from,
        the :meth:`_query.Query.select_from` method may be used::
 
            q = session.query(Address).select_from(User).\
                            join(User.addresses).\
                            filter(User.name == 'ed')
 
        Which will produce SQL similar to::
 
            SELECT address.* FROM user
                JOIN address ON user.id=address.user_id
                WHERE user.name = :name_1
 
        .. seealso::
 
            :meth:`_sql.Select.join` - v2 equivalent method.
 
        :param \*props: Incoming arguments for :meth:`_query.Query.join`,
         the props collection in modern use should be considered to be a  one
         or two argument form, either as a single "target" entity or ORM
         attribute-bound relationship, or as a target entity plus an "on
         clause" which  may be a SQL expression or ORM attribute-bound
         relationship.
 
        :param isouter=False: If True, the join used will be a left outer join,
         just as if the :meth:`_query.Query.outerjoin` method were called.
 
        :param full=False: render FULL OUTER JOIN; implies ``isouter``.
 
        T)r£ÚlegacyN©r–r‘rI)r1r¥r3ZJoinTargetRoleZ OnClauseRolerŒrôrö)r™r”r•r’r“Z join_targetZonclause_elementr~r~ršÚjoinÄs2Füÿþüÿ z
Query.join)r“)r”r•r“r•cCs|j||d|dS)a#Create a left outer join against this ``Query`` object's criterion
        and apply generatively, returning the newly resulting ``Query``.
 
        Usage is the same as the ``join()`` method.
 
        .. seealso::
 
            :meth:`_sql.Select.outerjoin` - v2 equivalent method.
 
        T)r•r’r“)r˜)r™r”r•r“r~r~ršÚ    outerjoin¥    szQuery.outerjoincCs
d|_|S)aSReturn a new :class:`.Query`, where the "join point" has
        been reset back to the base FROM entities of the query.
 
        This method is usually used in conjunction with the
        ``aliased=True`` feature of the :meth:`~.Query.join`
        method.  See the example in :meth:`~.Query.join` for how
        this is used.
 
        N)rIr˜r~r~ršÚreset_joinpoint¸    s zQuery.reset_joinpointr6)Úfrom_objr•cGs| |d¡|S)aRSet the FROM clause of this :class:`.Query` explicitly.
 
        :meth:`.Query.select_from` is often used in conjunction with
        :meth:`.Query.join` in order to control which entity is selected
        from on the "left" side of the join.
 
        The entity or selectable object here effectively replaces the
        "left edge" of any calls to :meth:`~.Query.join`, when no
        joinpoint is otherwise established - usually, the default "join
        point" is the leftmost entity in the :class:`~.Query` object's
        list of entities to be selected.
 
        A typical example::
 
            q = session.query(Address).select_from(User).\
                join(User.addresses).\
                filter(User.name == 'ed')
 
        Which produces SQL equivalent to::
 
            SELECT address.* FROM user
            JOIN address ON user.id=address.user_id
            WHERE user.name = :name_1
 
        :param \*from_obj: collection of one or more entities to apply
         to the FROM clause.  Entities can be mapped classes,
         :class:`.AliasedClass` objects, :class:`.Mapper` objects
         as well as core :class:`.FromClause` elements like subqueries.
 
        .. seealso::
 
            :meth:`~.Query.join`
 
            :meth:`.Query.select_entity_from`
 
            :meth:`_sql.Select.select_from` - v2 equivalent method.
 
        F)r¾)r™r›r~r~ršÚ select_fromÈ    s* zQuery.select_from)Úitemr•cCs t ||¡Sr–)Úorm_utilZ_getitem)r™rr~r~ršÚ __getitem__õ    sþzQuery.__getitem__)ÚstartÚstopr•cCs t |j|j||¡\|_|_|S)aLComputes the "slice" of the :class:`_query.Query` represented by
        the given indices and returns the resulting :class:`_query.Query`.
 
        The start and stop indices behave like the argument to Python's
        built-in :func:`range` function. This method provides an
        alternative to using ``LIMIT``/``OFFSET`` to get a slice of the
        query.
 
        For example, ::
 
            session.query(User).order_by(User.id).slice(1, 3)
 
        renders as
 
        .. sourcecode:: sql
 
           SELECT users.id AS users_id,
                  users.name AS users_name
           FROM users ORDER BY users.id
           LIMIT ? OFFSET ?
           (2, 1)
 
        .. seealso::
 
           :meth:`_query.Query.limit`
 
           :meth:`_query.Query.offset`
 
           :meth:`_sql.Select.slice` - v2 equivalent method.
 
        )Úsql_utilZ _make_slicerƒr„)r™r r¡r~r~ršÚsliceû    s'ÿ z Query.slicer`)Úlimitr•cCst |¡|_|S)z¯Apply a ``LIMIT`` to the query and return the newly resulting
        ``Query``.
 
        .. seealso::
 
            :meth:`_sql.Select.limit` - v2 equivalent method.
 
        )r¢Ú_offset_or_limit_clauserƒ)r™r¤r~r~ršr¤'
s z Query.limit)Úoffsetr•cCst |¡|_|S)z±Apply an ``OFFSET`` to the query and return the newly resulting
        ``Query``.
 
        .. seealso::
 
            :meth:`_sql.Select.offset` - v2 equivalent method.
        )r¢r¥r„)r™r¦r~r~ršr¦5
s
z Query.offset)Úexprr•cGs0|r&d|_|jtdd„|Dƒƒ|_nd|_|S)aUApply a ``DISTINCT`` to the query and return the newly resulting
        ``Query``.
 
 
        .. note::
 
            The ORM-level :meth:`.distinct` call includes logic that will
            automatically add columns from the ORDER BY of the query to the
            columns clause of the SELECT statement, to satisfy the common need
            of the database backend that ORDER BY columns be part of the SELECT
            list when DISTINCT is used.   These columns *are not* added to the
            list of columns actually fetched by the :class:`_query.Query`,
            however,
            so would not affect results. The columns are passed through when
            using the :attr:`_query.Query.statement` accessor, however.
 
            .. deprecated:: 2.0  This logic is deprecated and will be removed
               in SQLAlchemy 2.0.     See :ref:`migration_20_query_distinct`
               for a description of this use case in 2.0.
 
        .. seealso::
 
            :meth:`_sql.Select.distinct` - v2 equivalent method.
 
        :param \*expr: optional column expressions.  When present,
         the PostgreSQL dialect will render a ``DISTINCT ON (<expressions>)``
         construct.
 
         .. deprecated:: 1.4 Using \*expr in other dialects is deprecated
            and will raise :class:`_exc.CompileError` in a future version.
 
        Tcss|]}t tj|¡VqdSr–)r1r¥r3ZByOfRole)r§Úer~r~ršr-g
sz!Query.distinct.<locals>.<genexpr>)r†r‡r¼)r™r§r~r~ršrÇB
s# ÿzQuery.distinctzList[_T]cCs | ¡ ¡S)a˜Return the results represented by this :class:`_query.Query`
        as a list.
 
        This results in an execution of the underlying SQL statement.
 
        .. warning::  The :class:`_query.Query` object,
           when asked to return either
           a sequence or iterator that consists of full ORM-mapped entities,
           will **deduplicate entries based on primary key**.  See the FAQ for
           more details.
 
            .. seealso::
 
                :ref:`faq_query_deduplicating`
 
        .. seealso::
 
            :meth:`_engine.Result.all` - v2 comparable method.
 
            :meth:`_engine.Result.scalars` - v2 comparable method.
        )Ú_iterÚallr˜r~r~ršrªn
sz    Query.allrw)râr•cCstjtj||d}||_|S)aExecute the given SELECT statement and return results.
 
        This method bypasses all internal statement compilation, and the
        statement is executed without modification.
 
        The statement is typically either a :func:`_expression.text`
        or :func:`_expression.select` construct, and should return the set
        of columns
        appropriate to the entity class represented by this
        :class:`_query.Query`.
 
        .. seealso::
 
            :meth:`_sql.Select.from_statement` - v2 comparable method.
 
        r=)r1r¥r3ZSelectStatementRoler‘)r™râr~r~ršÚfrom_statement†
sÿzQuery.from_statementz Optional[_T]cCs,|jdk    r| ¡ ¡S| d¡ ¡ ¡SdS)a½Return the first result of this ``Query`` or
        None if the result doesn't contain any row.
 
        first() applies a limit of one within the generated SQL, so that
        only one primary entity row is generated on the server side
        (note this may consist of multiple result rows if join-loaded
        collections are present).
 
        Calling :meth:`_query.Query.first`
        results in an execution of the underlying
        query.
 
        .. seealso::
 
            :meth:`_query.Query.one`
 
            :meth:`_query.Query.one_or_none`
 
            :meth:`_engine.Result.first` - v2 comparable method.
 
            :meth:`_engine.Result.scalars` - v2 comparable method.
 
        Nr)r‘r©Úfirstr¤r˜r~r~ršr¬Ÿ
s
 z Query.firstcCs | ¡ ¡S)aÚReturn at most one result or raise an exception.
 
        Returns ``None`` if the query selects
        no rows.  Raises ``sqlalchemy.orm.exc.MultipleResultsFound``
        if multiple object identities are returned, or if multiple
        rows are returned for a query that returns only scalar values
        as opposed to full identity-mapped entities.
 
        Calling :meth:`_query.Query.one_or_none`
        results in an execution of the
        underlying query.
 
        .. seealso::
 
            :meth:`_query.Query.first`
 
            :meth:`_query.Query.one`
 
            :meth:`_engine.Result.one_or_none` - v2 comparable method.
 
            :meth:`_engine.Result.scalar_one_or_none` - v2 comparable method.
 
        )r©Ú one_or_noner˜r~r~ršr­½
szQuery.one_or_noner|cCs | ¡ ¡S)aÉReturn exactly one result or raise an exception.
 
        Raises ``sqlalchemy.orm.exc.NoResultFound`` if the query selects
        no rows.  Raises ``sqlalchemy.orm.exc.MultipleResultsFound``
        if multiple object identities are returned, or if multiple
        rows are returned for a query that returns only scalar values
        as opposed to full identity-mapped entities.
 
        Calling :meth:`.one` results in an execution of the underlying query.
 
        .. seealso::
 
            :meth:`_query.Query.first`
 
            :meth:`_query.Query.one_or_none`
 
            :meth:`_engine.Result.one` - v2 comparable method.
 
            :meth:`_engine.Result.scalar_one` - v2 comparable method.
 
        )r©Úoner˜r~r~ršr®×
sz    Query.onecCsBz$| ¡}t|tjƒs|WS|dWStjk
r<YdSXdS)aReturn the first element of the first result or None
        if no rows present.  If multiple rows are returned,
        raises MultipleResultsFound.
 
          >>> session.query(Item).scalar()
          <Item>
          >>> session.query(Item.id).scalar()
          1
          >>> session.query(Item.id).filter(Item.id < 0).scalar()
          None
          >>> session.query(Item.id, Item.name).scalar()
          1
          >>> session.query(func.count(Parent.id)).scalar()
          20
 
        This results in an execution of the underlying query.
 
        .. seealso::
 
            :meth:`_engine.Result.scalar` - v2 comparable method.
 
        rN)r®rÿÚcollections_abcrrµZ NoResultFound)r™Úretr~r~ršÚscalarï
s 
z Query.scalarz Iterator[_T]ccs:| ¡}z|EdHWntk
r4| ¡‚YnXdSr–)r©Ú GeneratorExitZ _soft_close)r™Úresultr~r~ršÚ__iter__ s zQuery.__iter__z#Union[ScalarResult[_T], Result[_T]]cCsd|j}| ¡}|jj||d|jid}|j dd¡rBtd|ƒ ¡}|j dd¡r`|jj    s`| 
¡}|S)NZ_sa_orm_load_options©r(rFz
Result[_T]Úfiltered) rrær’ÚexecuterÂÚ _attributesrÄrÚscalarsr Úunique)r™rèrâr³r~r~ršr© sý ÿþz Query._itercCsP| ¡}z|jr | ||jj¡nd}Wntjk
r@d}YnXt| |¡ƒSr–)rær’Ú_get_bind_argsZget_bindrµZUnboundExecutionErrorr²Úcompile)r™râÚbindr~r~ršÚ__str__0 sÿý
z Query.__str__)rârørÞr•cKs|fd|i|—ŽS)Nr„r~)r™rârørÞr~r~ršr»> szQuery._get_bind_argszList[ORMColumnDescription]cCs t|ddS)aàReturn metadata about the columns which would be
        returned by this :class:`_query.Query`.
 
        Format is a list of dictionaries::
 
            user_alias = aliased(User, name='user2')
            q = sess.query(User, User.id, user_alias)
 
            # this expression:
            q.column_descriptions
 
            # would return:
            [
                {
                    'name':'User',
                    'type':User,
                    'aliased':False,
                    'expr':User,
                    'entity': User
                },
                {
                    'name':'id',
                    'type':Integer(),
                    'aliased':False,
                    'expr':User.id,
                    'entity': User
                },
                {
                    'name':'user2',
                    'type':User,
                    'aliased':True,
                    'expr':user_alias,
                    'entity': user_alias
                }
            ]
 
        .. seealso::
 
            This API is available using :term:`2.0 style` queries as well,
            documented at:
 
            * :ref:`queryguide_inspection`
 
            * :attr:`.Select.column_descriptions`
 
        Tr—rr˜r~r~ršÚcolumn_descriptionsA s1zQuery.column_descriptionsz2.0zËThe :meth:`_orm.Query.instances` method is deprecated and will be removed in a future release. Use the Select.from_statement() method or aliased() construct in conjunction with Session.execute() instead.úCursorResult[Any]zOptional[QueryContext])Ú result_proxyÚcontextr•cCsv|dkr:tjddd|jdd}t||j|j|j|jƒ}t     ||¡}|j
  dd¡r\|  ¡}|j
  dd¡rr|  ¡}|S)    zhReturn an ORM result given a :class:`_engine.CursorResult` and
        :class:`.QueryContext`.
 
        NzÞUsing the Query.instances() method without a context is deprecated and will be disallowed in a future release.  Please make use of :meth:`_query.Query.from_statement` for linking ORM results to arbitrary select constructs.r)ÚversionFrärr¶)rZwarn_deprecatedrçr!rârr’rÂrÚ    instancesr¸rÄr¹rº)r™rÁrÂÚ compile_stater³r~r~ršrÄt s&û û zQuery.instancesz:meth:`_orm.Query.merge_result`zJThe method is superseded by the :func:`_orm.merge_frozen_result` function.)rZenable_warningszCUnion[FrozenResult[Any], Iterable[Sequence[Any]], Iterable[object]]z'Union[FrozenResult[Any], Iterable[Any]])ÚiteratorÚloadr•cCst |||¡S)akMerge a result into this :class:`_query.Query` object's Session.
 
        Given an iterator returned by a :class:`_query.Query`
        of the same structure
        as this one, return an identical iterator of results, with all mapped
        instances merged into the session using :meth:`.Session.merge`. This
        is an optimized method which will merge all mapped instances,
        preserving the structure of the result rows and unmapped columns with
        less method overhead than that of calling :meth:`.Session.merge`
        explicitly for each value.
 
        The structure of the results is determined based on the column list of
        this :class:`_query.Query` - if these do not correspond,
        unchecked errors
        will occur.
 
        The 'load' argument is the same as that of :meth:`.Session.merge`.
 
        For an example of how :meth:`_query.Query.merge_result` is used, see
        the source code for the example :ref:`examples_caching`, where
        :meth:`_query.Query.merge_result` is used to efficiently restore state
        from a cache back into a target :class:`.Session`.
 
        )rÚ merge_result)r™rÆrÇr~r~ršrÈ¢ s&zQuery.merge_resultr@cCsJ| d¡ t d¡¡ t¡ ¡ d¡}| ¡}|dk    r@|     |¡}t 
|¡S)aØA convenience method that turns a query into an EXISTS subquery
        of the form EXISTS (SELECT 1 FROM ... WHERE ...).
 
        e.g.::
 
            q = session.query(User).filter(User.name == 'fred')
            session.query(q.exists())
 
        Producing SQL similar to::
 
            SELECT EXISTS (
                SELECT 1 FROM users WHERE users.name = :name_1
            ) AS anon_1
 
        The EXISTS construct is usually used in the WHERE clause::
 
            session.query(User.id).filter(q.exists()).scalar()
 
        Note that some databases such as SQL Server don't allow an
        EXISTS expression to be present in the columns clause of a
        SELECT.    To select a simple boolean value based on the exists
        as a WHERE, use :func:`.literal`::
 
            from sqlalchemy import literal
 
            session.query(literal(True)).filter(q.exists()).scalar()
 
        .. seealso::
 
            :meth:`_sql.Select.exists` - v2 comparable method.
 
        FÚ1rN) rýrcr,Úliteral_columnrþrGrãZwith_only_columnsr±rœÚexists)r™ÚinnerZezeror~r~ršrËÊ s)
ÿþüÿ
z Query.existscCs&tj t d¡¡}| |¡ d¡ ¡S)añReturn a count of rows this the SQL formed by this :class:`Query`
        would return.
 
        This generates the SQL for this Query as follows::
 
            SELECT count(1) AS count_1 FROM (
                SELECT <rest of query follows...>
            ) AS anon_1
 
        The above SQL returns a single row, which is the aggregate value
        of the count function; the :meth:`_query.Query.count`
        method then returns
        that single integer value.
 
        .. warning::
 
            It is important to note that the value returned by
            count() is **not the same as the number of ORM objects that this
            Query would return from a method such as the .all() method**.
            The :class:`_query.Query` object,
            when asked to return full entities,
            will **deduplicate entries based on primary key**, meaning if the
            same primary key value would appear in the results more than once,
            only one object of that primary key would be present.  This does
            not apply to a query that is against individual columns.
 
            .. seealso::
 
                :ref:`faq_query_deduplicating`
 
        For fine grained control over specific columns to count, to skip the
        usage of a subquery or otherwise control of the FROM clause, or to use
        other aggregate functions, use :attr:`~sqlalchemy.sql.expression.func`
        expressions in conjunction with :meth:`~.Session.query`, i.e.::
 
            from sqlalchemy import func
 
            # count User records, without
            # using a subquery.
            session.query(func.count(User.id))
 
            # return count of user "id" grouped
            # by "name"
            session.query(func.count(User.id)).\
                    group_by(User.name)
 
            from sqlalchemy import distinct
 
            # count distinct "name" values
            session.query(func.count(distinct(User.name)))
 
        .. seealso::
 
            :ref:`migration_20_query_usage`
 
        Ú*F)r,ÚfuncrrÊrDrýr±)r™Úcolr~r~ršr s9ÿz Query.countÚautorN)Úsynchronize_sessionr•c    Csšt|ƒ}|jjr>|jjD]$}||j|ƒ}|dk    r6||_|j}qtj|jŽ}|j|_td|j    j
||j |j   d|i¡dƒ}||_|j    j |¡| ¡|jS)aèPerform a DELETE with an arbitrary WHERE clause.
 
        Deletes rows matched by this query from the database.
 
        E.g.::
 
            sess.query(User).filter(User.age == 25).\
                delete(synchronize_session=False)
 
            sess.query(User).filter(User.age == 25).\
                delete(synchronize_session='evaluate')
 
        .. warning::
 
            See the section :ref:`orm_expression_update_delete` for important
            caveats and warnings, including limitations when using bulk UPDATE
            and DELETE with mapper inheritance configurations.
 
        :param synchronize_session: chooses the strategy to update the
         attributes on objects in the session.   See the section
         :ref:`orm_expression_update_delete` for a discussion of these
         strategies.
 
        :return: the count of rows matched as returned by the database's
          "row count" feature.
 
        .. seealso::
 
            :ref:`orm_expression_update_delete`
 
        NrÀrÑrµ)Ú
BulkDeleter“Zbefore_compile_deleteÚqueryr,Údeleterªrrr’r·rrñr÷r³Zafter_bulk_deleteÚcloseÚrowcount)r™rÑZbulk_delrørùZdelete_r³r~r~ršrÔ> s.#   ÿýþ
z Query.deleteúDict[_DMLColumnArgument, Any]úOptional[Dict[Any, Any]])rŸrÑÚ update_argsr•c
    CsÜ|pi}t|||ƒ}|jjrJ|jjD]}||j|ƒ}|dk    r$||_q$|j}tj|jŽ}| dd¡}|rr|j|Ž}n
|     |¡}|rŒ|j
f|Ž}|j |_ t d|j j||j|j d|i¡dƒ}    |    |_|j j |¡|     ¡|    jS)aÉPerform an UPDATE with an arbitrary WHERE clause.
 
        Updates rows matched by this query in the database.
 
        E.g.::
 
            sess.query(User).filter(User.age == 25).\
                update({User.age: User.age - 10}, synchronize_session=False)
 
            sess.query(User).filter(User.age == 25).\
                update({"age": User.age - 10}, synchronize_session='evaluate')
 
        .. warning::
 
            See the section :ref:`orm_expression_update_delete` for important
            caveats and warnings, including limitations when using arbitrary
            UPDATE and DELETE with mapper inheritance configurations.
 
        :param values: a dictionary with attributes names, or alternatively
         mapped attributes or SQL expressions, as keys, and literal
         values or sql expressions as values.   If :ref:`parameter-ordered
         mode <tutorial_parameter_ordered_updates>` is desired, the values can
         be passed as a list of 2-tuples; this requires that the
         :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order`
         flag is passed to the :paramref:`.Query.update.update_args` dictionary
         as well.
 
        :param synchronize_session: chooses the strategy to update the
         attributes on objects in the session.   See the section
         :ref:`orm_expression_update_delete` for a discussion of these
         strategies.
 
        :param update_args: Optional dictionary, if present will be passed
         to the underlying :func:`_expression.update`
         construct as the ``**kw`` for
         the object.  May be used to pass dialect-specific arguments such
         as ``mysql_limit``, as well as other special arguments such as
         :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order`.
 
        :return: the count of rows matched as returned by the database's
         "row count" feature.
 
 
        .. seealso::
 
            :ref:`orm_expression_update_delete`
 
        NZpreserve_parameter_orderFrÀrÑrµ)Ú
BulkUpdater“Zbefore_compile_updaterÓr,rõrªröZordered_valuesrŸZwith_dialect_optionsrrr’r·rrñr÷r³Zafter_bulk_updaterÕrÖ)
r™rŸrÑrÙZbulk_udrørùZupdZppor³r~r~ršrõ| s<7      
 ÿýþ
z Query.updater )rårÞr•cKsB|jfd|i|—Ž}||jjks$t‚ttt |d¡ƒ}| |d¡S)aÂCreate an out-of-compiler ORMCompileState object.
 
        The ORMCompileState object is normally created directly as a result
        of the SQLCompiler.process() method being handed a Select()
        or FromStatement() object that uses the "orm" plugin.   This method
        provides a means of creating this ORMCompileState object directly
        without using the compiler.
 
        This method is used only for deprecated cases, which include
        the .from_self() method for a Query that has multiple levels
        of .from_self() in use, as well as the instances() method.  It is
        also used within the test suite to generate ORMCompileState objects
        for test purposes.
 
        råróN)rærŽrïrrr Z_get_plugin_class_for_pluginZcreate_for_statement)r™rårÞréZcompile_state_clsr~r~ršrçØ s
þzQuery._compile_stater!)rår•cCs(|j|d}t||j|j|j|jƒ}|S)Nrä)rçr!rârr’rÂ)r™rårÅrÂr~r~ršÚ_compile_contextù s ûzQuery._compile_context)N)TT)TT)NNNNN)T)FT)NFF)NFF)N)NN)N)T)N)N)N)N)T)rÐ)rÐN)F)F)›r7Ú
__module__Ú __qualname__Ú__doc__rÚ__annotations__r€rr‚rƒr„r†r‡rˆr‰rŠr‹rŒrHZLABEL_STYLE_LEGACY_ORMrrJr Zdefault_compile_optionsrŽr!Zdefault_load_optionsrÂrr—rrÎr‘Zmemoized_propertyr›ržr rr­r±r·r¾r;rÃrÉrËrÊrÈrÑrÒrÓr4rÔrÝràrãrârírærrrr rÚ
deprecatedrr
r    r¬rrýr Zbecame_legacy_20rûZ apply_labelsrrþrrrr!rÄr#r*rr.r0rÕr1Zpreload_moduler&r@rArDrGrBrŸZ_valuesrNr rVrcrdr'rgrhr(r&rèryrr9rIr|rr<r…rÆr‡rˆrŠr÷rŒrrŽrrr˜r™ršrœrŸr£r¤r¦rÇrªr«r¬r­r®r±r´r©r¾r»r¿rÄrÈrËrrÔrõrçrÛr~r~r~ršr{šs
             þ
ÿ ý(  ÿÿ 
 
ú(ÿ6ü/üBþ     þ ( þXü%  þúEýÿþ þ
  $(    ,
0 4 8'þó:0ô(Fÿ #
*"û 2û *+     ýú*cýû$+*  * 
2þ
ý 'ü û "6?ÿAü"]ÿ!c@s:eZdZdZe dd¡ddœdd„ƒZdd    d
œd d „Zd S)Ú AliasOptionFrz¦The :class:`.AliasOption` object is not necessary for entities to be matched up to a query that is established via :meth:`.Query.from_statement` and now does nothing.zUnion[Alias, Subquery])r<cCsdS)zReturn a :class:`.MapperOption` that will indicate to the
        :class:`_query.Query`
        that the main table has been aliased.
 
        Nr~)r™r<r~r~ršrž     szAliasOption.__init__r r¡)rÅr•cCsdSr–r~)r™rÅr~r~ršÚprocess_compile_state sz!AliasOption.process_compile_stateN)r7rÜrÝZ inherit_cacherràržrâr~r~r~ršrá sþrác@s>eZdZdZddœdd„Zddœdd    „Zed
dœd d „ƒZd S)ÚBulkUDzrState used for the orm.Query version of update() / delete().
 
    This object is now specific to Query only.
 
    r)rÓcCs$| d¡|_| ¡|j ¡|_dS)NF)rýrÓÚ_validate_query_stater±r))r™rÓr~r~ršrž! s zBulkUD.__init__r¡r”c
CsŒdddtjfdddtjfdddtjfdd    dtjfd
d d tjfd ddtjfdddtjffD].\}}}}|t|j|ƒ|ƒsXt d|f¡‚qXdS)Nrƒzlimit()r„zoffset()rz
order_by()r~r‚z
group_by()r†z
distinct()Fr‹z2join(), outerjoin(), select_from(), or from_self()rŒzCCan't call Query.update() or Query.delete() when %s has been called)ÚoperatorÚis_ÚeqÚgetattrrÓrµr¶)r™rLr³ZnotsetÚopr~r~ršrä& s,     üüôÿÿzBulkUD._validate_query_staterRcCs|jjSr–)rÓr’r˜r~r~ršr’@ szBulkUD.sessionN)r7rÜrÝrÞržrär4r’r~r~r~ršrã s
rãcs*eZdZdZddddœ‡fdd„ Z‡ZS)rÚzBulkUD which handles UPDATEs.rr×rØ)rÓrŸÚ update_kwargscstƒ |¡||_||_dSr–)ÚsuperržrŸrê)r™rÓrŸrê©r8r~ršržH s zBulkUpdate.__init__)r7rÜrÝrÞržÚ __classcell__r~r~rìršrÚE srÚc@seZdZdZdS)rÒzBulkUD which handles DELETEs.N)r7rÜrÝrÞr~r~r~ršrÒS srÒc@seZdZerddœdd„ZdS)ÚRowReturningQueryz
Query[_TP]r”cCsdSr–r~r˜r~r~ršr­Z szRowReturningQuery.tuplesN)r7rÜrÝrr­r~r~r~ršrîW srî) rÞÚ
__future__rÚcollections.abcÚabcr¯råÚtypingrrrrrrr    r
r r r rrrrrrÚrrrrržÚ_typingrÚbaserrÂrrrrr r!r"r#r$r%r&r(rµr)r*r+r,Zenginer-r.Úeventr/r0r1r2r3r4r¢r5Z sql._typingr6r7Zsql.annotationr8Zsql.baser:r;r<r=r>Z sql.elementsr?Zsql.expressionr@Zsql.selectablerArBrCrDrErFrGrHZ util.typingrIrJrKrLrMrNr)rOZ path_registryrPr’rQrRr¿rSZ engine.cursorrTZengine.interfacesrUrVrWrXZ engine.resultrYrZr[r\r]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrnZ_TCCArorprqrrrsrtrurvrwrxryrzÚ__all__r|Z_self_inspectsZ class_loggerZ
Identifiedr{Z LoaderOptionrárãrÚrÒrîr~r~r~ršÚ<module>sP                                                                                                                         
ö+