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
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
U
¸ý°dcìã@sUdZddlmZddlZddlmZddlZddlZddlZddlm    Z    ddlm
Z
ddlm Z ddlm Z dd    lm Z dd
lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$dd lm%Z&dd!l'm(Z(dd"l'm)Z)dd#l'm*Z*dd$l'm+Z+dd%l'm,Z,dd&l-m.Z.dd'l-m/Z/dd(l-m0Z0dd)l-m1Z1dd*l-m2Z2dd+l-m3Z3dd,l-m4Z4dd-l-m5Z5dd.l-m6Z6dd/lm7Z7dd0lm8Z8dd1l"m9Z9dd2l$m:Z:dd3l%m;Z;dd4l<m=Z=dd5l<m>Z>dd6l<m?Z?dd7l@mAZAd8d9lmBZBd8dlm!ZCd8d:lmDZDd8d;lmEZEd8d<lBmFZFd8d=lBmGZGd8d>lHmIZId8d?lJmKZKd8d@lJmLZLd8dAlMmNZNd8dBlMmOZOd8dClDmPZPd8dDlDmQZQd8dElDmRZRd8dFlDmSZSd8dGlDmTZTd8dHlDmUZUd8dIlVmWZWd8dJlXmYZYd8dKlZm[Z[d8dLlZm\Z\d8dMlEm]Z]d8dNl^m_Z_d8dOl^m`Z`ejrvddPl'maZaddQl'mbZbddRl'mcZcddSl'mdZdddTlemfZfddUlemgZgddVlhmiZiddWljmkZkddXl$mlZld8dYlBmmZmd8dZlBmnZnd8d[lBmoZod8d\lpmqZqd8d]lpmrZrd8d^lsmtZtd8d_lsmuZud8d`lsmvZvd8dalwmxZxd8dblJmyZyd8dclzm{Z{d8ddlzm|Z|d8delzm}Z}d8dflzm~Z~d8dglzmZd8dhlzm€Z€d8dilzmZd8djlzm‚Z‚d8dklzmƒZƒd8dllzm„Z„d8dmlzm…Z†d8dnlVm‡Z‡d8dolVmˆZˆd8dpl‰mŠZŠd8dql‹mŒZŒd8drlZmZd8dslZmŽZŽedte    duZdvdwdxdydzd{d|d}gZe ‘¡Z’d~e“d<e’e&_’ee    ee    d€ffZ”e e•e    fZ–eee(dfZ—eee    d‚dƒe•fZ˜ed„Z™e_d…ZšGd†d‡„d‡e`ƒZ›dˆd‰dŠœd‹dŒ„ZœGddŽ„dŽƒZGdd„de>ƒZžeŸežƒ\Z Z¡Z¢Z£Z¤Gd‘dy„dyeEj¥ƒZ¦Gd’d“„d“eƒZ§Gd”dw„dwe=eIƒZ¨Gd•dv„dveeLƒZ©ed–dvduZªGd—dx„dxee eªƒZ«d˜d™œdšdz„Z¬d›d˜dœœdd{„Z­d›d˜dœœdžd|„Z®d›d‰dœœdŸd}„Z¯eE °¡Z±dS) z1Provides the Session class and related utilities.é)Ú annotationsN)ÚEnum)ÚAny)ÚCallable)Úcast)ÚDict)ÚGeneric)ÚIterable)ÚIterator)ÚList)ÚNoReturn)ÚOptional)Úoverload)ÚSequence)ÚSet)ÚTuple)ÚType)Ú TYPE_CHECKING)ÚTypeVar)ÚUnioné)Ú
attributes)Úbulk_persistence)Úcontext)Údescriptor_props)Úexc)Úidentity)Úloading)Úquery©Ústate)Ú_O)Úinsp_is_mapper)Úis_composite_class)Ú is_orm_option©Úis_user_defined_option)Ú_class_to_mapper)Ú    _none_set)Ú _state_mapper)Ú instance_str)ÚLoaderCallableStatus)Ú object_mapper)Ú object_state)Ú PassiveFlag)Ú    state_str)Ú FromStatement)ÚORMCompileState)Ú IdentityMap)ÚQuery)Ú InstanceState)Ú _StateChange)Ú_StateChangeState)Ú_StateChangeStates)ÚUOWTransactioné)Úengine)Úsql)Úutil)Ú
Connection)ÚEngine)ÚTransactionalContext)Ú
dispatcher)Ú EventTarget)Úinspect)Ú Inspectable)Ú    coercions)Údml)Úroles)ÚSelect)Ú TableClause)Úvisitors)Ú CompileState)ÚTable)Ú ForUpdateArg)ÚLABEL_STYLE_TABLENAME_PLUS_COL)Ú IdentitySet)ÚLiteral)ÚProtocol)Ú _EntityType)Ú_IdentityKeyType)Ú _InstanceDict)ÚOrmExecuteOptionsParameter)Ú    ORMOption)ÚUserDefinedOption)ÚMapper)Ú PathRegistry)ÚRowReturningQuery)ÚResult)ÚRow)Ú
RowMapping)Ú Transaction)ÚTwoPhaseTransaction)Ú_CoreAnyExecuteParams)Ú_CoreSingleExecuteParams)Ú_ExecuteOptions)Ú ScalarResult)Ú_InstanceLevelDispatch)Ú_ColumnsClauseArgument)Ú    _InfoType)Ú_T0)Ú_T1)Ú_T2)Ú_T3)Ú_T4)Ú_T5)Ú_T6)Ú_T7)Ú_TypedColumnClauseArgument)Ú
Executable)ÚExecutableOption)Ú ClauseElement)ÚTypedColumnsClauseRole)ÚForUpdateParameter)ÚTypedReturnsRowsÚ_T)ÚboundÚSessionÚSessionTransactionÚ sessionmakerÚORMExecuteStateÚclose_all_sessionsÚmake_transientÚmake_transient_to_detachedÚobject_sessionz)weakref.WeakValueDictionary[int, Session]Ú    _sessions.ú
Mapper[_O]ú Mapper[Any]rH)r>r=)Úconditional_savepointÚ rollback_onlyÚ control_fullyÚcreate_savepointc@s&eZdZdZd
dddddœdd    „ZdS) Ú_ConnectionCallableProtoa×a callable that returns a :class:`.Connection` given an instance.
 
    This callable, when present on a :class:`.Session`, is called only from the
    ORM's persistence mechanism (i.e. the unit of work flush process) to allow
    for connection-per-instance schemes (i.e. horizontal sharding) to be used
    as persistence time.
 
    This callable is not present on a plain :class:`.Session`, however
    is established when using the horizontal sharding extension.
 
    NúOptional[Mapper[Any]]zOptional[object]rr=)ÚmapperÚinstanceÚkwÚreturncKsdS©N©)Úselfrˆr‰rŠrrúMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/orm/session.pyÚ__call__¶sz!_ConnectionCallableProto.__call__)NN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrrrr†©sýr†úInstanceState[Any]úOptional[Session]©r r‹cCs|jS)z[Given an :class:`.InstanceState`, return the :class:`.Session`
    associated, if any.
    ©ÚsessionrrrrÚ_state_session¿sršc @steZdZdZee dd¡ddœdd„ƒƒZee d¡dd    d    d    d
œd d d dd ddœdd„ƒƒZ    edddœdd„ƒZ
d    S)Ú_SessionClassMethodszBClass-level methods for :class:`.Session`, :class:`.sessionmaker`.z1.3z’The :meth:`.Session.close_all` method is deprecated and will be removed in a future release.  Please refer to :func:`.session.close_all_sessions`.ÚNone©r‹cCs
tƒdS)zClose *all* sessions in memory.N)r{)ÚclsrrrÚ    close_allÉs
z_SessionClassMethods.close_allzsqlalchemy.orm.utilN©r‰ÚrowÚidentity_tokenzOptional[Type[Any]]úUnion[Any, Tuple[Any, ...]]ú Optional[Any]z%Optional[Union[Row[Any], RowMapping]]z_IdentityKeyType[Any])Úclass_Úidentr‰r¡r¢r‹cCstjjj|||||dS)zZReturn an identity key.
 
        This is an alias of :func:`.util.identity_key`.
 
        r )r<Z    preloadedZorm_utilÚ identity_key)ržr¥r¦r‰r¡r¢rrrr§Õsûz!_SessionClassMethods.identity_keyÚobjectr–©r‰r‹cCst|ƒS)zxReturn the :class:`.Session` to which an object belongs.
 
        This is an alias of :func:`.object_session`.
 
        )r~)ržr‰rrrr~ísz#_SessionClassMethods.object_session)NN) r‘r’r“r”Ú classmethodr<Ú
deprecatedrŸZpreload_moduler§r~rrrrr›Æs$þýù r›c@s eZdZdZdZdZdZdZdS)ÚSessionTransactionStaterr9éééN)r‘r’r“ÚACTIVEÚPREPAREDÚ    COMMITTEDÚDEACTIVEÚCLOSEDrrrrr¬øs
r¬c@söeZdZUdZdZded<ded<ded<d    ed
<d    ed <d ed <ded<ded<ded<ded<dddd    d dddœdd„Zddœdd„ZdXdddd d!d"œd#d$„Ze    d%dœd&d'„ƒZ
e    d(dœd)d*„ƒZ e    d+dœd,d-„ƒZ e    d+dœd.d/„ƒZ e    d+dœd0d1„ƒZe    d+dœd2d3„ƒZe    d+dœd4d5„ƒZe    d+dœd6d7„ƒZe    d+dœd8d9„ƒZd:d;d<œd=d>„Zd?dœd@dA„Ze    dBdœdCdD„ƒZe    dEdœdFdG„ƒZe    d+dœdHdI„ƒZe    d+dœdJdK„ƒZe    dLdœdMdN„ƒZe    dOdœdPdQ„ƒZe    dRdœdSdT„ƒZe    dUdœdVdW„ƒZdS)Yrza8Represents a call to the :meth:`_orm.Session.execute` method, as passed
    to the :meth:`.SessionEvents.do_orm_execute` event hook.
 
    .. versionadded:: 1.4
 
    .. seealso::
 
        :ref:`session_execute_events` - top level documentation on how
        to use :meth:`_orm.SessionEvents.do_orm_execute`
 
    ) r™Ú    statementÚ
parametersÚexecution_optionsÚlocal_execution_optionsÚbind_argumentsr¢Ú_compile_state_clsÚ_starting_event_idxÚ _events_todoÚ_update_execution_optionsrwr™rorµúOptional[_CoreAnyExecuteParams]r¶rar·r¸Ú_BindArgumentsr¹zOptional[Type[ORMCompileState]]rºÚintr»z    List[Any]r¼úOptional[_ExecuteOptions]r½z%List[_InstanceLevelDispatch[Session]])r™rµr¶r·r¹Úcompile_state_clsÚ events_todocCs@||_||_||_||_|j |¡|_||_||_t    |ƒ|_
dS)zhConstruct a new :class:`_orm.ORMExecuteState`.
 
        this object is constructed internally.
 
        N) r™rµr¶r¸Ú_execution_optionsÚunionr·r¹rºÚlistr¼)rŽr™rµr¶r·r¹rÂrÃrrrÚ__init__ZsÿzORMExecuteState.__init__rcCs|j|jdd…S)Nr)r¼r»©rŽrrrÚ_remaining_eventstsz!ORMExecuteState._remaining_eventsNzOptional[Executable]z$Optional[OrmExecuteOptionsParameter]úOptional[_BindArguments]ú Result[Any])rµÚparamsr·r¹r‹c Cs|dkr|j}t|jƒ}|r&| |¡d|d<|rÔ|jr²g}td|jƒ}t |td|ƒ¡D]T\}}    |dksr|    dkr’t     
dt |ƒ›dt |ƒ›d¡‚t|ƒ}| |    ¡|  |¡qZqÚttd|jƒƒ}| td|ƒ¡n|j}|j }
|rî|
 |¡}
|jj|||
||d    S)
a¸Execute the statement represented by this
        :class:`.ORMExecuteState`, without re-invoking events that have
        already proceeded.
 
        This method essentially performs a re-entrant execution of the current
        statement for which the :meth:`.SessionEvents.do_orm_execute` event is
        being currently invoked.    The use case for this is for event handlers
        that want to override how the ultimate
        :class:`_engine.Result` object is returned, such as for schemes that
        retrieve results from an offline cache or which concatenate results
        from multiple executions.
 
        When the :class:`_engine.Result` object is returned by the actual
        handler function within :meth:`_orm.SessionEvents.do_orm_execute` and
        is propagated to the calling
        :meth:`_orm.Session.execute` method, the remainder of the
        :meth:`_orm.Session.execute` method is preempted and the
        :class:`_engine.Result` object is returned to the caller of
        :meth:`_orm.Session.execute` immediately.
 
        :param statement: optional statement to be invoked, in place of the
         statement currently represented by :attr:`.ORMExecuteState.statement`.
 
        :param params: optional dictionary of parameters or list of parameters
         which will be merged into the existing
         :attr:`.ORMExecuteState.parameters` of this :class:`.ORMExecuteState`.
 
         .. versionchanged:: 2.0 a list of parameter dictionaries is accepted
            for executemany executions.
 
        :param execution_options: optional dictionary of execution options
         will be merged into the existing
         :attr:`.ORMExecuteState.execution_options` of this
         :class:`.ORMExecuteState`.
 
        :param bind_arguments: optional dictionary of bind_arguments
         which will be merged amongst the current
         :attr:`.ORMExecuteState.bind_arguments`
         of this :class:`.ORMExecuteState`.
 
        :return: a :class:`_engine.Result` object with ORM-level results.
 
        .. seealso::
 
            :ref:`do_orm_execute_re_executing` - background and examples on the
            appropriate usage of :meth:`_orm.ORMExecuteState.invoke_statement`.
 
 
        NTÚ_sa_skip_eventszList[Dict[str, Any]]zgCan't apply executemany parameters to statement; number of parameter sets passed to Session.execute() (zW) does not match number of parameter sets given to ORMExecuteState.invoke_statement() (ú)zDict[str, Any])r·r¹Ú_parent_execute_state)rµÚdictr¹ÚupdateÚis_executemanyrr¶Ú    itertoolsÚ zip_longestÚsa_excÚInvalidRequestErrorÚlenÚappendr¸rÅr™Ú_execute_internal) rŽrµrÌr·r¹Z_bind_argumentsÚ_paramsZexec_many_parametersZ_existing_paramsZ _new_paramsrÄrrrÚinvoke_statementwsJ9
 
ÿþ ÿ
 
ûz ORMExecuteState.invoke_statementr‡cCs|j dd¡S)aÓReturn the :class:`_orm.Mapper` that is the primary "bind" mapper.
 
        For an :class:`_orm.ORMExecuteState` object invoking an ORM
        statement, that is, the :attr:`_orm.ORMExecuteState.is_orm_statement`
        attribute is ``True``, this attribute will return the
        :class:`_orm.Mapper` that is considered to be the "primary" mapper
        of the statement.   The term "bind mapper" refers to the fact that
        a :class:`_orm.Session` object may be "bound" to multiple
        :class:`_engine.Engine` objects keyed to mapped classes, and the
        "bind mapper" determines which of those :class:`_engine.Engine` objects
        would be selected.
 
        For a statement that is invoked against a single mapped class,
        :attr:`_orm.ORMExecuteState.bind_mapper` is intended to be a reliable
        way of getting this mapper.
 
        .. versionadded:: 1.4.0b2
 
        .. seealso::
 
            :attr:`_orm.ORMExecuteState.all_mappers`
 
 
        rˆN)r¹ÚgetrÈrrrÚ bind_mapperászORMExecuteState.bind_mapperzSequence[Mapper[Any]]cCs˜|js
gSt|jttfƒrzg}tƒ}|jjD]H}|d}|r,t|dd}|r,|jr,|j|kr,|     |j¡| 
|j¡q,|S|jj r|j r|j gSgSdS)aReturn a sequence of all :class:`_orm.Mapper` objects that are
        involved at the top level of this statement.
 
        By "top level" we mean those :class:`_orm.Mapper` objects that would
        be represented in the result set rows for a :func:`_sql.select`
        query, or for a :func:`_dml.update` or :func:`_dml.delete` query,
        the mapper that is the main subject of the UPDATE or DELETE.
 
        .. versionadded:: 1.4.0b2
 
        .. seealso::
 
            :attr:`_orm.ORMExecuteState.bind_mapper`
 
 
 
        ÚentityF)ZraiseerrN) Úis_orm_statementÚ
isinstancerµrGr0ÚsetZcolumn_descriptionsrBrˆÚaddrØÚis_dmlrÝ)rŽÚresultÚseenÚdÚentÚinsprrrÚ all_mappersýs    zORMExecuteState.all_mappersÚboolcCs
|jdk    S)areturn True if the operation is an ORM statement.
 
        This indicates that the select(), insert(), update(), or delete()
        being invoked contains ORM entities as subjects.   For a statement
        that does not have ORM entities and instead refers only to
        :class:`.Table` metadata, it is invoked as a Core SQL statement
        and no ORM-level automation takes place.
 
        N)rºrÈrrrrß"s z ORMExecuteState.is_orm_statementcCs t|jtƒS)z–return True if the parameters are a multi-element list of
        dictionaries with more than one dictionary.
 
        .. versionadded:: 2.0
 
        )ràr¶rÆrÈrrrrÒ/szORMExecuteState.is_executemanycCs|jjS)z*return True if this is a SELECT operation.)rµÚ    is_selectrÈrrrrë9szORMExecuteState.is_selectcCs|jjo|jjS)z+return True if this is an INSERT operation.)rµrãÚ    is_insertrÈrrrrì>szORMExecuteState.is_insertcCs|jjo|jjS)z+return True if this is an UPDATE operation.)rµrãÚ    is_updaterÈrrrríCszORMExecuteState.is_updatecCs|jjo|jjS)z*return True if this is a DELETE operation.)rµrãÚ    is_deleterÈrrrrîHszORMExecuteState.is_deletecCst|jtjtjfƒSrŒ)ràrµrEZUpdateZDeleterÈrrrÚ_is_crudMszORMExecuteState._is_crudrrœ)Úoptsr‹cKs|j |¡|_dS)z3Update the local execution options with new values.N)r¸rÅ©rŽrðrrrÚupdate_execution_optionsQsz(ORMExecuteState.update_execution_optionszwOptional[Union[context.ORMCompileState.default_compile_options, Type[context.ORMCompileState.default_compile_options]]]cCsP|js
dSz |jj}Wntk
r,YdSX|dk    rH| tjj¡rH|SdSdSrŒ)rërµZ_compile_optionsÚAttributeErrorràrr1Zdefault_compile_optionsrñrrrÚ_orm_compile_optionsUs  ÿz$ORMExecuteState._orm_compile_optionsúOptional[InstanceState[Any]]cCs|jjS)aÿAn :class:`.InstanceState` that is using this statement execution
        for a lazy load operation.
 
        The primary rationale for this attribute is to support the horizontal
        sharding extension, where it is available within specific query
        execution time hooks created by this extension.   To that end, the
        attribute is only intended to be meaningful at **query execution
        time**, and importantly not any time prior to that, including query
        compilation time.
 
        )Ú load_optionsZ_lazy_loaded_fromrÈrrrÚlazy_loaded_fromks z ORMExecuteState.lazy_loaded_fromzOptional[PathRegistry]cCs| ¡}|dk    r|jSdSdS)zÐReturn the :class:`.PathRegistry` for the current load path.
 
        This object represents the "path" in a query along relationships
        when a particular object or collection is being loaded.
 
        N)rôZ _current_pathrñrrrÚloader_strategy_pathzsz$ORMExecuteState.loader_strategy_pathcCs| ¡}|dk    o|jS)aqReturn True if the operation is refreshing column-oriented
        attributes on an existing ORM object.
 
        This occurs during operations such as :meth:`_orm.Session.refresh`,
        as well as when an attribute deferred by :func:`_orm.defer` is
        being loaded, or an attribute that was expired either directly
        by :meth:`_orm.Session.expire` or via a commit operation is being
        loaded.
 
        Handlers will very likely not want to add any options to queries
        when such an operation is occurring as the query should be a straight
        primary key fetch which should not have any additional WHERE criteria,
        and loader options travelling with the instance
        will have already been added to the query.
 
        .. versionadded:: 1.4.0b2
 
        .. seealso::
 
            :attr:`_orm.ORMExecuteState.is_relationship_load`
 
        N)rôZ_for_refresh_staterñrrrÚis_column_loadˆszORMExecuteState.is_column_loadcCs*| ¡}|dkrdS|j}|dk    o(|j S)azReturn True if this load is loading objects on behalf of a
        relationship.
 
        This means, the loader in effect is either a LazyLoader,
        SelectInLoader, SubqueryLoader, or similar, and the entire
        SELECT statement being emitted is on behalf of a relationship
        load.
 
        Handlers will very likely not want to add any options to queries
        when such an operation is occurring, as loader options are already
        capable of being propagated to relationship loaders and should
        be already present.
 
        .. seealso::
 
            :attr:`_orm.ORMExecuteState.is_column_load`
 
        NF)rôrøZis_root)rŽrðÚpathrrrÚis_relationship_load£s
z$ORMExecuteState.is_relationship_loadzaUnion[context.QueryContext.default_load_options, Type[context.QueryContext.default_load_options]]cCs"|jst d¡‚|j dtjj¡S)z=Return the load_options that will be used for this execution.zRThis ORM execution is not against a SELECT statement so there are no load options.Z_sa_orm_load_options)rërÕrÖr·rÜrÚ QueryContextÚdefault_load_optionsrÈrrrrö½s    ÿÿzORMExecuteState.load_optionszƒUnion[bulk_persistence.BulkUDCompileState.default_update_options, Type[bulk_persistence.BulkUDCompileState.default_update_options]]cCs"|jst d¡‚|j dtjj¡S)zNReturn the update_delete_options that will be used for this
        execution.z_This ORM execution is not against an UPDATE or DELETE statement so there are no update options.Z_sa_orm_update_options)rïrÕrÖr·rÜrZBulkUDCompileStateZdefault_update_optionsrÈrrrÚupdate_delete_optionsÏs
ÿþz%ORMExecuteState.update_delete_optionszSequence[ORMOption]cCsdd„|jjDƒS)NcSsg|]}t|ƒr|js|‘qSr)r$Z_is_compile_state©Ú.0ÚoptrrrÚ
<listcomp>åsþz<ORMExecuteState._non_compile_orm_options.<locals>.<listcomp>©rµZ _with_optionsrÈrrrÚ_non_compile_orm_optionsãsþz(ORMExecuteState._non_compile_orm_optionszSequence[UserDefinedOption]cCsdd„|jjDƒS)zzThe sequence of :class:`.UserDefinedOptions` that have been
        associated with the statement being invoked.
 
        cSsg|]}t|ƒr|‘qSrr%rÿrrrrñsþz8ORMExecuteState.user_defined_options.<locals>.<listcomp>rrÈrrrÚuser_defined_optionsësþz$ORMExecuteState.user_defined_options)NNNN)r‘r’r“r”Ú    __slots__Ú__annotations__rÇrÉrÛÚpropertyrÝrérßrÒrërìrírîrïròrôr÷rørùrûrörþrrrrrrrzsn
 
ûj$      c@s eZdZdZdZdZdZdZdS)ÚSessionTransactionOriginzáindicates the origin of a :class:`.SessionTransaction`.
 
    This enumeration is present on the
    :attr:`.SessionTransaction.origin` attribute of any
    :class:`.SessionTransaction` object.
 
    .. versionadded:: 2.0
 
    rrr9r­N)r‘r’r“r”Ú    AUTOBEGINÚBEGINÚ BEGIN_NESTEDÚSUBTRANSACTIONrrrrr    øs 
r    c@s\eZdZUdZdZded<ded<ded<d    ed
<d ed <d ed<d ed<d ed<ded<ded<dZded<dWddd    dœdd„Zddddœdd „Ze    d    d!œd"d#„ƒZ
e    dd!œd$d%„ƒZ e    dd!œd&d'„ƒZ e  ejfej¡dXd(d)d*d+d,œd-d.„ƒZe  ejfej¡dYddd/œd0d1„ƒZdZd    d2d3œd4d5„Zd6d!œd7d8„Zd[dd6d9œd:d;„Zd6d!œd<d=„Ze  ejfej¡d>d)d+d?œd@dA„ƒZd6d!œdBdC„Ze  ejfej¡d6d!œdDdE„ƒZe  ejejfej¡d\dd6dFœdGdH„ƒZe  ejejejfej¡d]ddd6dIœdJdK„ƒZ e  ej!ej¡d^dd6dLœdMdN„ƒZ"dd!œdOdP„Z#dd!œdQdR„Z$dd!œdSdT„Z%dd!œdUdV„Z&dS)_rxa¬A :class:`.Session`-level transaction.
 
    :class:`.SessionTransaction` is produced from the
    :meth:`_orm.Session.begin`
    and :meth:`_orm.Session.begin_nested` methods.   It's largely an internal
    object that in modern use provides a context manager for session
    transactions.
 
    Documentation on interacting with :class:`_orm.SessionTransaction` is
    at: :ref:`unitofwork_transaction`.
 
 
    .. versionchanged:: 1.4  The scoping and API methods to work with the
       :class:`_orm.SessionTransaction` object directly have been simplified.
 
    .. seealso::
 
        :ref:`unitofwork_transaction`
 
        :meth:`.Session.begin`
 
        :meth:`.Session.begin_nested`
 
        :meth:`.Session.rollback`
 
        :meth:`.Session.commit`
 
        :meth:`.Session.in_transaction`
 
        :meth:`.Session.in_nested_transaction`
 
        :meth:`.Session.get_transaction`
 
        :meth:`.Session.get_nested_transaction`
 
 
    NzOptional[BaseException]Ú_rollback_exceptionzKDict[Union[Engine, Connection], Tuple[Connection, Transaction, bool, bool]]Ú _connectionsrwr™úOptional[SessionTransaction]Ú_parentr¬Ú_statez5weakref.WeakKeyDictionary[InstanceState[Any], object]Ú_newÚ_deletedÚ_dirtyz>weakref.WeakKeyDictionary[InstanceState[Any], Tuple[Any, Any]]Ú _key_switchesr    ÚoriginFrêÚnested)r™rÚparentcCs t |¡||_i|_||_|tjk|_}||_|rN|sDt     
d¡‚|j |_ n$|tj krf|dk    srt‚n |dksrt‚tj|_| ¡||j_|jj |j|¡dS)NzOCan't start a SAVEPOINT transaction when no existing transaction is in progress)r?Ú_trans_ctx_checkr™rrr    r rrrÕrÖÚ_nested_transactionÚ_previous_nested_transactionr ÚAssertionErrorr¬r°rÚ_take_snapshotÚ _transactionÚdispatchZafter_transaction_create)rŽr™rrrrrrrÇ`s&
ÿ
 
 zSessionTransaction.__init__Ústrr6r )Úoperation_namer r‹cCsf|tjkr4|jr(tjd|j›dd‚qbt d¡‚n.|tjkrJt d¡‚nt d|j     ¡›d¡‚dS)NzÀThis Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: Z7s2a)Úcodez‰This session is in 'inactive' state, due to the SQL transaction being rolled back; no further SQL can be emitted within this transaction.zThis transaction is closedzThis session is in 'z?' state; no further SQL can be emitted within this transaction.)
r¬r³rrÕZPendingRollbackErrorrÖr´ZResourceClosedErrorÚnameÚlower)rŽr"r rrrÚ_raise_for_prerequisite_state…s
 
ú    ÿ
 ÿz0SessionTransaction._raise_for_prerequisite_statercCs|jS)aaThe parent :class:`.SessionTransaction` of this
        :class:`.SessionTransaction`.
 
        If this attribute is ``None``, indicates this
        :class:`.SessionTransaction` is at the top of the stack, and
        corresponds to a real "COMMIT"/"ROLLBACK"
        block.  If non-``None``, then this is either a "subtransaction"
        (an internal marker object used by the flush process) or a
        "nested" / SAVEPOINT transaction.  If the
        :attr:`.SessionTransaction.nested` attribute is ``True``, then
        this is a SAVEPOINT, and if ``False``, indicates this a subtransaction.
 
        )rrÈrrrr szSessionTransaction.parentcCs|jdk    o|jtjkSrŒ)r™rr¬r°rÈrrrÚ    is_active±s
 
þzSessionTransaction.is_activecCs|jp |j SrŒ)rrrÈrrrÚ_is_transaction_boundary¸sz+SessionTransaction._is_transaction_boundaryr‡rÁrr=)Úbindkeyr·Úkwargsr‹cKs|jj|f|Ž}| ||¡SrŒ)r™Úget_bindÚ_connection_for_bind)rŽr)r·r*ÚbindrrrÚ
connection¼s    zSessionTransaction.connection©rr‹cCst|j|rtjntj|ƒSrŒ)rxr™r    r r )rŽrrrrÚ_beginÈsÿûzSessionTransaction._beginzIterable[SessionTransaction])Úuptor‹cCsJ|}d}|rF||f7}|j|kr$qFq|jdkr>t d|¡‚q|j}q|S)Nrz4Transaction %s is not on the active transaction list)rrÕrÖ)rŽr1ÚcurrenträrrrÚ_iterate_self_and_parentsÔs
 
 
ÿÿz,SessionTransaction._iterate_self_and_parentsrœcCs|js<|j}|dk    st‚|j|_|j|_|j|_|j|_dS|jtj    tj
fk}|sd|j j sd|j   ¡t ¡|_t ¡|_t ¡|_t ¡|_dSrŒ)r(rrrrrrrr    r r
r™Ú    _flushingÚflushÚweakrefÚWeakKeyDictionary)rŽrZis_beginrrrrès$ þ 
 
 
 
z!SessionTransaction._take_snapshot)Ú
dirty_onlyr‹cCsä|js
t‚t|jƒ |jj¡}|jj|dd|j ¡D]6\}\}}|jj     
|¡||_ ||kr8|jj      |¡q8t|j ƒ |jj ¡D]}|jj|ddq„|jj r¦t‚|jj     ¡D],}|rÊ|jsÊ||jkr²| |j|jj    j¡q²dS)zmRestore the restoration state taken before a transaction began.
 
        Corresponds to a rollback.
 
        T©Ú to_transient)Úrevert_deletionN)r(rrárrÅr™Ú_expunge_statesrÚitemsÚ identity_mapÚ safe_discardÚkeyÚreplacerÚ _update_implÚ
all_statesÚmodifiedrÚ_expirerÐÚ    _modified)rŽr8Z
to_expungeÚsZoldkeyZnewkeyrrrÚ_restore_snapshotþs
 z$SessionTransaction._restore_snapshotcCs´|js
t‚|js`|jjr`|jj ¡D]}| |j|jjj    ¡q$t
j   t |jƒ|j¡|j ¡nP|jr°|j}|dk    sxt‚|j |j¡|j |j¡|j |j¡|j |j¡dS)zjRemove the restoration state taken before a transaction began.
 
        Corresponds to a commit.
 
        N)r(rrr™Úexpire_on_commitr>rCrErÐrFÚstatelibr4Ú_detach_statesrÆrÚclearrrrÑrr)rŽrGrrrrÚ_remove_snapshots 
ÿ  z#SessionTransaction._remove_snapshotÚ _SessionBind)r-r·r‹c    Cs¶||jkr&|rt d¡|j|dSd}d}|jrN|j ||¡}|js‚|Sn4t|tjƒrv|}|j|jkr‚t     
d¡‚n |  ¡}d}zÎ|r”|j f|Ž}|j jr°|jdkr°| ¡}nž|jrÀ| ¡}nŽ| ¡rF|j j}|dkrì| ¡rèd}nd}|d    kr"| ¡r
| ¡}n| ¡}|dkrDd}n"|dkr6| ¡}ndsNt|ƒ‚n| ¡}Wn|rf| ¡‚YnFXt|tjƒ}|||| f|j|<|j|j<|j j |j ||¡|SdS)
NzOConnection is already established for the given bind; execution_options ignoredrFTzMSession already has a Connection associated for the given Connection's Enginer‚r…rƒ)r„rƒ)rr<Úwarnrr,rràr:r=rÕrÖÚconnectr·r™ÚtwophaseZbegin_twophaseÚ begin_nestedÚin_transactionÚjoin_transaction_modeÚin_nested_transactionZ _get_required_nested_transactionZ_get_required_transactionrÚbeginÚcloser Z after_begin)    rŽr-r·Z local_connectÚ should_commitÚconnÚ transactionrTZbind_is_connectionrrrr,6sn    
ÿ  ÿ 
 
 
 
 
 
 
 
 
  üz'SessionTransaction._connection_for_bindcCs(|jdk    s|jjst d¡‚| ¡dS)NzD'twophase' mode not enabled, or not root transaction; can't prepare.)rr™rQrÕrÖÚ _prepare_implrÈrrrÚprepare’s
ÿzSessionTransaction.preparec Cs|jdks|jr |jj |j¡|jj}|dk    s4t‚||k    rV|j|dD] }| ¡qH|jj    sŽt
dƒD]}|j  ¡rxqŽ|j  ¡qft  d¡‚|jdkrô|jjrôz*t|j ¡ƒD]}td|dƒ ¡q°Wn(t ¡| ¡W5QRXYnXtj|_dS)N©r1édzrOver 100 subsequent flushes have occurred within session.commit() - is an after_flush() hook creating new objects?r^r)rrr™r Z before_commitrrr3Úcommitr4ÚrangeÚ    _is_cleanr5rÚ
FlushErrorrQrárÚvaluesrr\r<Ú safe_reraiseÚrollbackr¬r±r)rŽÚstxÚsubtransactionZ _flush_guardÚtrrrr[šs. 
 
 ÿ
z SessionTransaction._prepare_impl)Ú_to_rootr‹c    CsÀ|jtjk    r,| tj¡| ¡W5QRX|jdks<|jr„t|j     ¡ƒD]\}}}}|rJ| 
¡qJtj |_|j j  |j ¡| ¡| tj¡| ¡W5QRX|r¼|jr¼|jj
dddS)NT©ri)rr¬r±Ú _expect_stater[rrrárrcr_r²r™r Z after_commitrMr´rW)rŽrirYÚtransrXÚ    autocloserrrr_¾s  ÿ
 
zSessionTransaction.commit)Ú_capture_exceptionrir‹c
 
Cs¬|jj}|dk    st‚||k    r6|j|dD] }| ¡q(|}d}|jtjtjfkrð| ¡D]–}|j    dksl|j
ræzVz<t |j ¡ƒD]}|d ¡q~tj |_|jj |j¡Wnt ¡}YnXW5tj |_|j |j
dX|}qðqXtj |_qX|j}    |s|     ¡st d¡|j |j
d| tj¡| ¡W5QRX|j    r\|r\t ¡d|j    _|r~|dr~|d |d¡‚|    j |    |¡|r¨|j    r¨|j    jdddS)Nr])r8rz\Session's state has been changed on a non-active transaction - this state will be discarded.r9Trj)r™rrr3rWrr¬r°r±rrr³rHrárrcrer Zafter_rollbackÚsysÚexc_inforar<rOrkr´rÚwith_tracebackZafter_soft_rollback)
rŽrnrirfrgÚboundaryZ rollback_errrZrhÚsessrrrreÙsT  
þ ÿ
ÿzSessionTransaction.rollback©Ú
invalidater‹cCs”|jr|j|j_|j|j_t|j ¡ƒD]J\}}}}|rJ|jdkrJ|     ¡|r\|j
r\|  ¡|r(|jdkr(|  ¡q(t j |_|j}|j ||¡dSrŒ)rrr™rrrrárrcrur'rWr¬r´rr Zafter_transaction_end)rŽrur.rZrXrmrsrrrrW s ÿ
ÿ
 
 
zSessionTransaction.closecCs|jSrŒr˜rÈrrrÚ _get_subjectCszSessionTransaction._get_subjectcCs |jtjkSrŒ)rr¬r°rÈrrrÚ_transaction_is_activeFsz)SessionTransaction._transaction_is_activecCs |jtjkSrŒ)rr¬r´rÈrrrÚ_transaction_is_closedIsz)SessionTransaction._transaction_is_closedcCs|jttfkSrŒ)rr²r´rÈrrrÚ_rollback_can_be_calledLsz*SessionTransaction._rollback_can_be_called)N)N)F)N)F)F)FF)F)'r‘r’r“r”rrrrÇr&rrr'r(r5Zdeclare_statesr¬r°r7Ú    NO_CHANGEr.r0r3rrHrMr,r\r±r[r´r_r³reÚANYrWrvrwrxryrrrrrxs
&  ü%ÿý    ÿ
ÿ ÿYÿ!
þýú    ÿ?ÿ c@s
eZdZUdZdZded<ded<ded<ded    <d
ed <d ed <ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<dcddddddddddd d!œ d"dd#dddd$dd%d&d'dd(œ d)d*„ZdZd+ed,<dZd-ed.<d/d/d0œd1d2„Z    d3d3d3d4d5œd6d7„Z
e j d/d8d0œd9d:„ƒZ dd;œd<d=„Zdd;œd>d?„Zdd;œd@dA„Zdd;œdBdC„ZejdDd;œdEdF„ƒZddddGdHœdIdJ„ZdeddGdKœdLdM„ZdGd;œdNdO„Zd4d;œdPdQ„Zd4d;œdRdS„Zd4d;œdTdU„ZdfdVdWdXdYœdZd[„Zdgd\dWd3dXd]œd^d_„Zedhejdddd`daœdbdcdddVdeded#d3dfœdgdh„ƒZediejdddd`daœdbdidddVdededdjdfœdkdh„ƒZdjejdddddaœdbdidddVdededd3dfœdldh„ZedkejddddmœdndidddVdededodpœdqdr„ƒZ edlejddddmœdbdidddVdededjdpœdsdr„ƒZ dmejddddmœdbdidddVdededjdpœdtdr„Z ednejdduœdvdcdddVd3dwdxœdydz„ƒZ!edoejdduœdbdcdddVd3d3dxœd{dz„ƒZ!dpejdduœdbdcdddVd3d3dxœd|dz„Z!edqejdduœdvdidddVd3d}dxœd~d„ƒZ"edrejdduœdbdidddVd3d€dxœdd„ƒZ"dsejdduœdbdidddVd3d€dxœd‚d„Z"d4d;œdƒd„„Z#d4d;œd…d†„Z$dd4d‡œdˆd‰„Z%d4d;œdŠd‹„Z&dŒd\d4dœdŽd„Z'dd\d4d‘œd’d“„Z(d”d\d4d•œd–d—„Z)dtddddd˜œd™dšd"d›dd3dœdœdždŸ„Z*ed d¡d¢œd£d¤„ƒZ+ed¥d¦d§œd¨d¤„ƒZ+ed©dªd«d¬œd­d¤„ƒZ+ed©dªd®d¯d°œd±d¤„ƒZ+ed©dªd®d²d³d´œdµd¤„ƒZ+ed©dªd®d²d¶d·d¸œd¹d¤„ƒZ+ed©dªd®d²d¶dºd»d¼œd½d¤„ƒZ+ed©dªd®d²d¶dºd¾d¿dÀœdÁd¤„ƒZ+ed©dªd®d²d¶dºd¾dÂdÃdĜ    dÅd¤„ƒZ+edÆd3dÇdȜdÉd¤„ƒZ+dÆd3dÇdȜdÊd¤„Z+de,j-dejdfdËdÌd3dÍdÎdddVdÏdМdÑd҄Z.ej/e j dÓd;œdÔdՄƒƒZ0ej1 2dÖe3j4¡d4d;œd×d؄ƒZ5dudÙdÚdÛd4dܜdÝdބZ6d4d;œdßdà„Z7dvdÙdÚd4dáœdâdã„Z8dädÚd4dåœdædç„Z9dwdäd›d4dèœdédê„Z:dÙd4dëœdìdí„Z;dxdîdd4dïœdðdñ„Z<dòd4dóœdôdõ„Z=dîd4dóœdöd÷„Z>dîd4dóœdødù„Z?dydÙdd4dúœdûdü„Z@dýd4dþœdÿd„ZAdäd4dœdd„ZBdÙd4d뜐dd„ZCdädÙdd4dœdd„ZDddddejdd    œdd
d ddÛdedddVd d œ    dd„ZEddddejdd    œdd
ddddÛdedddVd dœ
dd„ZFdddœddd ddœdd„ZGddœddd dddddœd d!„ZHdäd4dœd"d#„ZIdäd4dœd$d%„ZJdzdädd4d&œd'd(„ZKdäd4dœd)d*„ZLdÙd4d+œd,d-„ZMdädÙdd.œd/d0„ZNdädÙd4d.œd1d2„ZOdÙdd뜐d3d4„ZPd5d;œd6d7„ZQdäddœd8d9„ZRd{d:d4d;œd<d=„ZSd3d4d>œd?d@„ZTdd;œdAdB„ZUd|dCd4d;œdDdE„ZVd}dýdddd4dFœdGdH„ZWd~dIdJddd4dKœdLdM„ZXdIdJd4dNœdOdP„ZYdːdQdddddd4dRœdSdT„ZZddÙdddUœdVdW„Z[e\dd;œdXdY„ƒZ]e\dîd;œdZd[„ƒZ^e\d\d;œd]d^„ƒZ_e\d\d;œd_d`„ƒZ`e\d\d;œdadb„ƒZadS(€rwz„Manages persistence operations for ORM-mapped objects.
 
    The Session's usage paradigm is described at :doc:`/orm/session`.
 
 
    Fzdispatcher[Session]r r2r>zDict[InstanceState[Any], Any]rrz#Optional[Union[Engine, Connection]]r-z#Dict[_SessionBindKey, _SessionBind]Ú_Session__bindsrêr4Ú_warn_on_eventsrrrrÀÚhash_keyÚ    autoflushrIÚenable_baked_queriesrQÚJoinTransactionModerTzType[Query[Any]]Ú
_query_clsNTr‚) rÚfuturerIÚ    autobeginrQÚbindsr€ÚinfoÚ    query_clsÚ
autocommitrTúOptional[_SessionBind]z Literal[True]z-Optional[Dict[_SessionBindKey, _SessionBind]]úOptional[_InfoType]zOptional[Type[Query[Any]]]zLiteral[False]) r-rrƒrIr„rQr…r€r†r‡rˆrTc Csö| rt d¡‚t ¡|_|s&t d¡‚i|_i|_||_i|_d|_    d|_
d|_ d|_ t ƒ|_||_||_||_||_| r–| tjkr–t d| ›d¡‚| |_||_|
rª|
ntj|_|    rÂ|j |    ¡|dk    rè| ¡D]\} }| | |¡qÒ|t|j<dS)aÂ(Construct a new Session.
 
        See also the :class:`.sessionmaker` function which is used to
        generate a :class:`.Session`-producing callable with a given
        set of arguments.
 
        :param autoflush: When ``True``, all query operations will issue a
           :meth:`~.Session.flush` call to this ``Session`` before proceeding.
           This is a convenience feature so that :meth:`~.Session.flush` need
           not be called repeatedly in order for database queries to retrieve
           results.
 
           .. seealso::
 
               :ref:`session_flushing` - additional background on autoflush
 
        :param autobegin: Automatically start transactions (i.e. equivalent to
           invoking :meth:`_orm.Session.begin`) when database access is
           requested by an operation.   Defaults to ``True``.    Set to
           ``False`` to prevent a :class:`_orm.Session` from implicitly
           beginning transactions after construction, as well as after any of
           the :meth:`_orm.Session.rollback`, :meth:`_orm.Session.commit`,
           or :meth:`_orm.Session.close` methods are called.
 
           .. versionadded:: 2.0
 
           .. seealso::
 
                :ref:`session_autobegin_disable`
 
        :param bind: An optional :class:`_engine.Engine` or
           :class:`_engine.Connection` to
           which this ``Session`` should be bound. When specified, all SQL
           operations performed by this session will execute via this
           connectable.
 
        :param binds: A dictionary which may specify any number of
           :class:`_engine.Engine` or :class:`_engine.Connection`
           objects as the source of
           connectivity for SQL operations on a per-entity basis.   The keys
           of the dictionary consist of any series of mapped classes,
           arbitrary Python classes that are bases for mapped classes,
           :class:`_schema.Table` objects and :class:`_orm.Mapper` objects.
           The
           values of the dictionary are then instances of
           :class:`_engine.Engine`
           or less commonly :class:`_engine.Connection` objects.
           Operations which
           proceed relative to a particular mapped class will consult this
           dictionary for the closest matching entity in order to determine
           which :class:`_engine.Engine` should be used for a particular SQL
           operation.    The complete heuristics for resolution are
           described at :meth:`.Session.get_bind`.  Usage looks like::
 
            Session = sessionmaker(binds={
                SomeMappedClass: create_engine('postgresql+psycopg2://engine1'),
                SomeDeclarativeBase: create_engine('postgresql+psycopg2://engine2'),
                some_mapper: create_engine('postgresql+psycopg2://engine3'),
                some_table: create_engine('postgresql+psycopg2://engine4'),
                })
 
           .. seealso::
 
                :ref:`session_partitioning`
 
                :meth:`.Session.bind_mapper`
 
                :meth:`.Session.bind_table`
 
                :meth:`.Session.get_bind`
 
 
        :param \class_: Specify an alternate class other than
           ``sqlalchemy.orm.session.Session`` which should be used by the
           returned class. This is the only argument that is local to the
           :class:`.sessionmaker` function, and is not sent directly to the
           constructor for ``Session``.
 
        :param enable_baked_queries: legacy; defaults to ``True``.
           A parameter consumed
           by the :mod:`sqlalchemy.ext.baked` extension to determine if
           "baked queries" should be cached, as is the normal operation
           of this extension.  When set to ``False``, caching as used by
           this particular extension is disabled.
 
           .. versionchanged:: 1.4 The ``sqlalchemy.ext.baked`` extension is
              legacy and is not used by any of SQLAlchemy's internals. This
              flag therefore only affects applications that are making explicit
              use of this extension within their own code.
 
        :param expire_on_commit:  Defaults to ``True``. When ``True``, all
           instances will be fully expired after each :meth:`~.commit`,
           so that all attribute/object access subsequent to a completed
           transaction will load from the most recent database state.
 
            .. seealso::
 
                :ref:`session_committing`
 
        :param future: Deprecated; this flag is always True.
 
          .. seealso::
 
            :ref:`migration_20_toplevel`
 
        :param info: optional dictionary of arbitrary data to be associated
           with this :class:`.Session`.  Is available via the
           :attr:`.Session.info` attribute.  Note the dictionary is copied at
           construction time so that modifications to the per-
           :class:`.Session` dictionary will be local to that
           :class:`.Session`.
 
        :param query_cls:  Class which should be used to create new Query
          objects, as returned by the :meth:`~.Session.query` method.
          Defaults to :class:`_query.Query`.
 
        :param twophase:  When ``True``, all transactions will be started as
            a "two phase" transaction, i.e. using the "two phase" semantics
            of the database in use along with an XID.  During a
            :meth:`~.commit`, after :meth:`~.flush` has been issued for all
            attached databases, the :meth:`~.TwoPhaseTransaction.prepare`
            method on each database's :class:`.TwoPhaseTransaction` will be
            called. This allows each database to roll back the entire
            transaction, before each transaction is committed.
 
        :param autocommit: the "autocommit" keyword is present for backwards
            compatibility but must remain at its default value of ``False``.
 
        :param join_transaction_mode: Describes the transactional behavior to
          take when a given bind is a :class:`_engine.Connection` that
          has already begun a transaction outside the scope of this
          :class:`_orm.Session`; in other words the
          :meth:`_engine.Connection.in_transaction()` method returns True.
 
          The following behaviors only take effect when the :class:`_orm.Session`
          **actually makes use of the connection given**; that is, a method
          such as :meth:`_orm.Session.execute`, :meth:`_orm.Session.connection`,
          etc. are actually invoked:
 
          * ``"conditional_savepoint"`` - this is the default.  if the given
            :class:`_engine.Connection` is begun within a transaction but
            does not have a SAVEPOINT, then ``"rollback_only"`` is used.
            If the :class:`_engine.Connection` is additionally within
            a SAVEPOINT, in other words
            :meth:`_engine.Connection.in_nested_transaction()` method returns
            True, then ``"create_savepoint"`` is used.
 
            ``"conditional_savepoint"`` behavior attempts to make use of
            savepoints in order to keep the state of the existing transaction
            unchanged, but only if there is already a savepoint in progress;
            otherwise, it is not assumed that the backend in use has adequate
            support for SAVEPOINT, as availability of this feature varies.
            ``"conditional_savepoint"`` also seeks to establish approximate
            backwards compatibility with previous :class:`_orm.Session`
            behavior, for applications that are not setting a specific mode. It
            is recommended that one of the explicit settings be used.
 
          * ``"create_savepoint"`` - the :class:`_orm.Session` will use
            :meth:`_engine.Connection.begin_nested()` in all cases to create
            its own transaction.  This transaction by its nature rides
            "on top" of any existing transaction that's opened on the given
            :class:`_engine.Connection`; if the underlying database and
            the driver in use has full, non-broken support for SAVEPOINT, the
            external transaction will remain unaffected throughout the
            lifespan of the :class:`_orm.Session`.
 
            The ``"create_savepoint"`` mode is the most useful for integrating
            a :class:`_orm.Session` into a test suite where an externally
            initiated transaction should remain unaffected; however, it relies
            on proper SAVEPOINT support from the underlying driver and
            database.
 
            .. tip:: When using SQLite, the SQLite driver included through
               Python 3.11 does not handle SAVEPOINTs correctly in all cases
               without workarounds. See the section
               :ref:`pysqlite_serializable` for details on current workarounds.
 
          * ``"control_fully"`` - the :class:`_orm.Session` will take
            control of the given transaction as its own;
            :meth:`_orm.Session.commit` will call ``.commit()`` on the
            transaction, :meth:`_orm.Session.rollback` will call
            ``.rollback()`` on the transaction, :meth:`_orm.Session.close` will
            call ``.rollback`` on the transaction.
 
            .. tip:: This mode of use is equivalent to how SQLAlchemy 1.4 would
               handle a :class:`_engine.Connection` given with an existing
               SAVEPOINT (i.e. :meth:`_engine.Connection.begin_nested`); the
               :class:`_orm.Session` would take full control of the existing
               SAVEPOINT.
 
          * ``"rollback_only"`` - the :class:`_orm.Session` will take control
            of the given transaction for ``.rollback()`` calls only;
            ``.commit()`` calls will not be propagated to the given
            transaction.  ``.close()`` calls will have no effect on the
            given transaction.
 
            .. tip:: This mode of use is equivalent to how SQLAlchemy 1.4 would
               handle a :class:`_engine.Connection` given with an existing
               regular database transaction (i.e.
               :meth:`_engine.Connection.begin`); the :class:`_orm.Session`
               would propagate :meth:`_orm.Session.rollback` calls to the
               underlying transaction, but not :meth:`_orm.Session.commit` or
               :meth:`_orm.Session.close` calls.
 
          .. versionadded:: 2.0.0rc1
 
 
        z&autocommit=True is no longer supportedzCThe 'future' parameter passed to Session() may only be set to True.FNz.invalid selection for join_transaction_mode: "ú")rÕÚ ArgumentErrorrÚWeakInstanceDictr>rrr-r|r4r}rrÚ_new_sessionidr~r„rrIr€rÚ__args__rTrQrr3r‚r†rÑr=Ú    _add_bindr)rŽr-rrƒrIr„rQr…r€r†r‡rˆrTr@rrrrÇzsRfÿ
ÿÿÿþ
ÿ zSession.__init__zOptional[TransactionalContext]Ú_trans_context_managerz"Optional[_ConnectionCallableProto]Úconnection_callableÚ_S)rŽr‹cCs|SrŒrrÈrrrÚ    __enter__“szSession.__enter__rrœ)Útype_ÚvalueÚ    tracebackr‹cCs | ¡dSrŒ)rW)rŽr•r–r—rrrÚ__exit__–szSession.__exit__z Iterator[_S]c
cs.| | ¡ |VW5QRXW5QRXdSrŒ©rVrÈrrrÚ_maker_context_manager™s
zSession._maker_context_managerrcCs
|jdk    S)z®Return True if this :class:`_orm.Session` has begun a transaction.
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :attr:`_orm.Session.is_active`
 
 
        N)rrÈrrrrSŸs zSession.in_transactioncCs
|jdk    S)zŠReturn True if this :class:`_orm.Session` has begun a nested
        transaction, e.g. SAVEPOINT.
 
        .. versionadded:: 1.4
 
        N©rrÈrrrrU¬szSession.in_nested_transactioncCs$|j}|dk    r |jdk    r |j}q|S)zaReturn the current root transaction in progress, if any.
 
        .. versionadded:: 1.4
 
        N)rr©rŽrlrrrÚget_transactionµszSession.get_transactioncCs|jS)zcReturn the current nested transaction in progress, if any.
 
        .. versionadded:: 1.4
 
        r›rÈrrrÚget_nested_transactionÀszSession.get_nested_transactionrecCsiS)aŠA user-modifiable dictionary.
 
        The initial value of this dictionary can be populated using the
        ``info`` argument to the :class:`.Session` constructor or
        :class:`.sessionmaker` constructor or factory methods.  The dictionary
        here is always local to this :class:`.Session` and can be modified
        independently of all other :class:`.Session` objects.
 
        rrÈrrrr†És z Session.inforx)rVr‹cCsL|jdkrF|s|jst d¡‚t||r,tjntjƒ}|j|ksBt‚|S|jS)Nz]Autobegin is disabled on this Session; please call session.begin() to start a new transaction)    rr„rÕrÖrxr    r r
r)rŽrVrlrrrÚ _autobegin_tÖs
 
ÿÿüzSession._autobegin_tr/cCsb|j}|dkr"|jdd}|s"|S|dk    s.t‚|rT|j|d}|j|ksLt‚||_n
t d¡‚|S)aÉBegin a transaction, or nested transaction,
        on this :class:`.Session`, if one is not already begun.
 
        The :class:`_orm.Session` object features **autobegin** behavior,
        so that normally it is not necessary to call the
        :meth:`_orm.Session.begin`
        method explicitly. However, it may be used in order to control
        the scope of when the transactional state is begun.
 
        When used to begin the outermost transaction, an error is raised
        if this :class:`.Session` is already inside of a transaction.
 
        :param nested: if True, begins a SAVEPOINT transaction and is
         equivalent to calling :meth:`~.Session.begin_nested`. For
         documentation on SAVEPOINT transactions, please see
         :ref:`session_begin_nested`.
 
        :return: the :class:`.SessionTransaction` object.  Note that
         :class:`.SessionTransaction`
         acts as a Python context manager, allowing :meth:`.Session.begin`
         to be used in a "with" block.  See :ref:`session_explicit_begin` for
         an example.
 
        .. seealso::
 
            :ref:`session_autobegin`
 
            :ref:`unitofwork_transaction`
 
            :meth:`.Session.begin_nested`
 
 
        NTr™©rz/A transaction is already begun on this Session.)rrŸrr0rrÕrÖ)rŽrrlrrrrVés#   ÿz Session.begincCs |jddS)a"Begin a "nested" transaction on this Session, e.g. SAVEPOINT.
 
        The target database(s) and associated drivers must support SQL
        SAVEPOINT for this method to function correctly.
 
        For documentation on SAVEPOINT
        transactions, please see :ref:`session_begin_nested`.
 
        :return: the :class:`.SessionTransaction` object.  Note that
         :class:`.SessionTransaction` acts as a context manager, allowing
         :meth:`.Session.begin_nested` to be used in a "with" block.
         See :ref:`session_begin_nested` for a usage example.
 
        .. seealso::
 
            :ref:`session_begin_nested`
 
            :ref:`pysqlite_serializable` - special workarounds required
            with the SQLite driver in order for SAVEPOINT to work
            correctly.
 
        Tr r™rÈrrrrR szSession.begin_nestedcCs|jdkr n|jjdddS)a{Rollback the current transaction in progress.
 
        If no transaction is in progress, this method is a pass-through.
 
        The method always rolls back
        the topmost database transaction, discarding any nested
        transactions that may be in progress.
 
        .. seealso::
 
            :ref:`session_rollback`
 
            :ref:`unitofwork_transaction`
 
        NTrj)rrerÈrrrre9s
zSession.rollbackcCs&|j}|dkr| ¡}|jdddS)aeFlush pending changes and commit the current transaction.
 
        When the COMMIT operation is complete, all objects are fully
        :term:`expired`, erasing their internal contents, which will be
        automatically re-loaded when the objects are next accessed. In the
        interim, these objects are in an expired state and will not function if
        they are :term:`detached` from the :class:`.Session`. Additionally,
        this re-load operation is not supported when using asyncio-oriented
        APIs. The :paramref:`.Session.expire_on_commit` parameter may be used
        to disable this behavior.
 
        When there is no transaction in place for the :class:`.Session`,
        indicating that no operations were invoked on this :class:`.Session`
        since the previous call to :meth:`.Session.commit`, the method will
        begin and commit an internal-only "logical" transaction, that does not
        normally affect the database unless pending flush changes were
        detected, but will still invoke event handlers and object expiration
        rules.
 
        The outermost database transaction is committed unconditionally,
        automatically releasing any SAVEPOINTs in effect.
 
        .. seealso::
 
            :ref:`session_committing`
 
            :ref:`unitofwork_transaction`
 
            :ref:`asyncio_orm_avoid_lazyloads`
 
        NTrj)rrŸr_rœrrrr_Ns zSession.commitcCs"|j}|dkr| ¡}| ¡dS)axPrepare the current transaction in progress for two phase commit.
 
        If no transaction is in progress, this method raises an
        :exc:`~sqlalchemy.exc.InvalidRequestError`.
 
        Only root transactions of two phase sessions can be prepared. If the
        current transaction is not such, an
        :exc:`~sqlalchemy.exc.InvalidRequestError` is raised.
 
        N)rrŸr\rœrrrr\ts zSession.preparerÊrÁr=)r¹r·r‹cCs<|r&| dd¡}|dkr.|jf|Ž}n| ¡}|j||dS)a"Return a :class:`_engine.Connection` object corresponding to this
        :class:`.Session` object's transactional state.
 
        Either the :class:`_engine.Connection` corresponding to the current
        transaction is returned, or if no transaction is in progress, a new
        one is begun and the :class:`_engine.Connection`
        returned (note that no
        transactional state is established with the DBAPI until the first
        SQL statement is emitted).
 
        Ambiguity in multi-bind or unbound :class:`.Session` objects can be
        resolved through any of the optional keyword arguments.   This
        ultimately makes usage of the :meth:`.get_bind` method for resolution.
 
        :param bind_arguments: dictionary of bind arguments.  May include
         "mapper", "bind", "clause", other custom arguments that are passed
         to :meth:`.Session.get_bind`.
 
        :param execution_options: a dictionary of execution options that will
         be passed to :meth:`_engine.Connection.execution_options`, **when the
         connection is first procured only**.   If the connection is already
         present within the :class:`.Session`, a warning is emitted and
         the arguments are ignored.
 
         .. seealso::
 
            :ref:`session_transaction_isolation`
 
        r-N©r·)Úpopr+r,)rŽr¹r·r-rrrr.…s# þzSession.connectionrN)r:r·rŠr‹cKs,t |¡|j}|dkr | ¡}| ||¡SrŒ)r?rrrŸr,)rŽr:r·rŠrlrrrr,µs
 
zSession._connection_for_bind.)r·r¹rÏÚ
_add_eventÚ_scalar_resultroz"Optional[_CoreSingleExecuteParams]rTr¤)rµrÌr·r¹rÏr£r¤r‹cCsdSrŒr©rŽrµrÌr·r¹rÏr£r¤rrrrÙÂs zSession._execute_internalr¾rËcCsdSrŒrr¥rrrrÙÐs cCsÒt tj|¡}|si}nt|ƒ}|j dd¡dkrTt |d¡}t    rdt
|t j ƒsdt ‚nd}| d|¡t |¡}|r|| ¡}    n|jj}    |r–t|    ƒ|g}    |    r|dk    r¼| |||||d¡\}}t|||||||    ƒ}
t|    ƒD]4\} } | |
_| |
ƒ} | rØ|r|  ¡S| SqØ|
j}|
j}|dk    r<| |||||d¡\}}|jf|Ž}| |¡}|r„|s„t    rntt|ƒ}|j||p|i|dS|r¦|  |||pši|||¡}n|j!||p´i|d}|rÊ| ¡S|SdS)NZcompile_state_pluginZormÚclauseTFr¡)"rDÚexpectrFZ StatementRolerÐÚ_propagate_attrsrÜrJZ_get_plugin_class_for_pluginrràrZAbstractORMCompileStaterÚ
setdefaultr<Zcoerce_to_immutabledictrÉr Zdo_orm_executerÆZorm_pre_session_execrzÚ    enumerater»Úscalarrµr¸r+r,rr`Zorm_execute_statementÚexecute)rŽrµrÌr·r¹rÏr£r¤rÂrÃZorm_exec_stateÚidxÚfnZ    fn_resultr-rYrärrrrÙÞs¾  ÿÿÿÿ
 
 
 
úý
ù     
 
    úý
 
 
ÿú    ÿ©r·r¹rÏr£zTypedReturnsRows[_T]z
Result[_T])rµrÌr·r¹rÏr£r‹cCsdSrŒr©rŽrµrÌr·r¹rÏr£rrrr¬as zSession.executecCsdSrŒrr°rrrr¬ns cCs|j||||||dS)aÙExecute a SQL expression construct.
 
        Returns a :class:`_engine.Result` object representing
        results of the statement execution.
 
        E.g.::
 
            from sqlalchemy import select
            result = session.execute(
                select(User).where(User.id == 5)
            )
 
        The API contract of :meth:`_orm.Session.execute` is similar to that
        of :meth:`_engine.Connection.execute`, the :term:`2.0 style` version
        of :class:`_engine.Connection`.
 
        .. versionchanged:: 1.4 the :meth:`_orm.Session.execute` method is
           now the primary point of ORM statement execution when using
           :term:`2.0 style` ORM usage.
 
        :param statement:
            An executable statement (i.e. an :class:`.Executable` expression
            such as :func:`_expression.select`).
 
        :param params:
            Optional dictionary, or list of dictionaries, containing
            bound parameter values.   If a single dictionary, single-row
            execution occurs; if a list of dictionaries, an
            "executemany" will be invoked.  The keys in each dictionary
            must correspond to parameter names present in the statement.
 
        :param execution_options: optional dictionary of execution options,
         which will be associated with the statement execution.  This
         dictionary can provide a subset of the options that are accepted
         by :meth:`_engine.Connection.execution_options`, and may also
         provide additional options understood only in an ORM context.
 
         .. seealso::
 
            :ref:`orm_queryguide_execution_options` - ORM-specific execution
            options
 
        :param bind_arguments: dictionary of additional arguments to determine
         the bind.  May include "mapper", "bind", or other custom arguments.
         Contents of this dictionary are passed to the
         :meth:`.Session.get_bind` method.
 
        :return: a :class:`_engine.Result` object.
 
 
        r¯©rÙr°rrrr¬{s=ú)r·r¹zTypedReturnsRows[Tuple[_T]]z Optional[_T])rµrÌr·r¹rŠr‹cKsdSrŒr©rŽrµrÌr·r¹rŠrrrr«Ás
zSession.scalarcKsdSrŒrr²rrrr«Ís
cKs|j||f||ddœ|—ŽS)zÉExecute a statement and return a scalar result.
 
        Usage and parameters are the same as that of
        :meth:`_orm.Session.execute`; the return result is a scalar Python
        value.
 
        T)r·r¹r¤r±r²rrrr«ÙsþûúzScalarResult[_T]cKsdSrŒrr²rrrÚscalarsós
zSession.scalarszScalarResult[Any]cKsdSrŒrr²rrrr³ÿs
cKs |j|f|||ddœ|—Ž ¡S)a¸Execute a statement and return the results as scalars.
 
        Usage and parameters are the same as that of
        :meth:`_orm.Session.execute`; the return result is a
        :class:`_result.ScalarResult` filtering object which
        will return single elements rather than :class:`_row.Row` objects.
 
        :return:  a :class:`_result.ScalarResult` object
 
        .. versionadded:: 1.4.24 Added :meth:`_orm.Session.scalars`
 
        .. versionadded:: 1.4.26 Added :meth:`_orm.scoped_session.scalars`
 
        .. seealso::
 
            :ref:`orm_queryguide_select_orm_entities` - contrasts the behavior
            of :meth:`_orm.Session.execute` to :meth:`_orm.Session.scalars`
 
        F)rÌr·r¹r¤)rÙr³r²rrrr³     sÿûúcCs|jdddS)aClose out the transactional resources and ORM objects used by this
        :class:`_orm.Session`.
 
        This expunges all ORM objects associated with this
        :class:`_orm.Session`, ends any transaction in progress and
        :term:`releases` any :class:`_engine.Connection` objects which this
        :class:`_orm.Session` itself has checked out from associated
        :class:`_engine.Engine` objects. The operation then leaves the
        :class:`_orm.Session` in a state which it may be used again.
 
        .. tip::
 
            The :meth:`_orm.Session.close` method **does not prevent the
            Session from being used again**.   The :class:`_orm.Session` itself
            does not actually have a distinct "closed" state; it merely means
            the :class:`_orm.Session` will release all database connections
            and ORM objects.
 
        .. versionchanged:: 1.4  The :meth:`.Session.close` method does not
           immediately create a new :class:`.SessionTransaction` object;
           instead, the new :class:`.SessionTransaction` is created only if
           the :class:`.Session` is used again for a database operation.
 
        .. seealso::
 
            :ref:`session_closing` - detail on the semantics of
            :meth:`_orm.Session.close`
 
        F©ruN©Ú _close_implrÈrrrrW1    sz Session.closecCs|jdddS)aËClose this Session, using connection invalidation.
 
        This is a variant of :meth:`.Session.close` that will additionally
        ensure that the :meth:`_engine.Connection.invalidate`
        method will be called on each :class:`_engine.Connection` object
        that is currently in use for a transaction (typically there is only
        one connection unless the :class:`_orm.Session` is used with
        multiple engines).
 
        This can be called when the database is known to be in a state where
        the connections are no longer safe to be used.
 
        Below illustrates a scenario when using `gevent
        <https://www.gevent.org/>`_, which can produce ``Timeout`` exceptions
        that may mean the underlying connection should be discarded::
 
            import gevent
 
            try:
                sess = Session()
                sess.add(User())
                sess.commit()
            except gevent.Timeout:
                sess.invalidate()
                raise
            except:
                sess.rollback()
                raise
 
        The method additionally does everything that :meth:`_orm.Session.close`
        does, including that all ORM objects are expunged.
 
        Tr´NrµrÈrrrruQ    s"zSession.invalidatertcCs0| ¡|jdk    r,|j ¡D]}| |¡qdSrŒ)Ú expunge_allrr3rW)rŽrurZrrrr¶u    s
zSession._close_implcCsF|j ¡t|jƒ}|j ¡t ¡|_i|_i|_tj     
||¡dS)z Remove all object instances from this ``Session``.
 
        This is equivalent to calling ``expunge(obj)`` on all objects in this
        ``Session``.
 
        N) r>rCrÆrZ_killrrrrJr4rK)rŽrCrrrr·{    s 
 
zSession.expunge_allÚ_SessionBindKey)r@r-r‹c
Cs¾z t|ƒ}WnJtjk
rV}z*t|tƒs<t d|¡|‚n
||j|<W5d}~XYndXtrjt|tƒsjt    ‚t|t
ƒr€||j|<n:t |ƒr¬||j|j <|j D]}||j|<qšnt d|¡‚dS)Nz!Not an acceptable bind target: %s)rBrÕÚNoInspectionAvailableràÚtyperŒr|rrCrrHr"r¥Z _all_tables)rŽr@r-rèÚerrZ _selectablerrrr‹    s* 
ÿþ
 
ÿzSession._add_bindz_EntityBindKey[_O])rˆr-r‹cCs| ||¡dS)aºAssociate a :class:`_orm.Mapper` or arbitrary Python class with a
        "bind", e.g. an :class:`_engine.Engine` or
        :class:`_engine.Connection`.
 
        The given entity is added to a lookup used by the
        :meth:`.Session.get_bind` method.
 
        :param mapper: a :class:`_orm.Mapper` object,
         or an instance of a mapped
         class, or any Python class that is the base of a set of mapped
         classes.
 
        :param bind: an :class:`_engine.Engine` or :class:`_engine.Connection`
                    object.
 
        .. seealso::
 
            :ref:`session_partitioning`
 
            :paramref:`.Session.binds`
 
            :meth:`.Session.bind_table`
 
 
        N©r)rŽrˆr-rrrrݤ    szSession.bind_mapperrH)Útabler-r‹cCs| ||¡dS)a©Associate a :class:`_schema.Table` with a "bind", e.g. an
        :class:`_engine.Engine`
        or :class:`_engine.Connection`.
 
        The given :class:`_schema.Table` is added to a lookup used by the
        :meth:`.Session.get_bind` method.
 
        :param table: a :class:`_schema.Table` object,
         which is typically the target
         of an ORM mapping, or is present within a selectable that is
         mapped.
 
        :param bind: an :class:`_engine.Engine` or :class:`_engine.Connection`
         object.
 
        .. seealso::
 
            :ref:`session_partitioning`
 
            :paramref:`.Session.binds`
 
            :meth:`.Session.bind_mapper`
 
 
        Nr¼)rŽr½r-rrrÚ
bind_table    szSession.bind_table)r¦r-rÍÚ_sa_skip_for_implicit_returningzOptional[_EntityBindKey[_O]]zOptional[ClauseElement]zOptional[bool]zUnion[Engine, Connection])rˆr¦r-rÍr¿rŠr‹c
KsÆ|r|S|js|jr|jS|dkr@|dkr@|jr6|jSt d¡‚|dk    r–z t|ƒ}Wqštjk
r’}zt|tƒr€t     |¡|‚n‚W5d}~XYqšXnd}|jrj|rÚ|j
j D]}    |    |jkr®|j|    Sq®|dkrÚ|j }|dk    rj|j  dd¡}
|
dk    r(|
jj
j D] }    |    |jkr|j|    Sqt |¡D]6} | |jkr2trXt| tƒsXt‚|j| Sq2|jrx|jSg} |dk    r–|  d|›¡|dk    rª|  d¡t dd | ¡›d¡‚dS)    aG Return a "bind" to which this :class:`.Session` is bound.
 
        The "bind" is usually an instance of :class:`_engine.Engine`,
        except in the case where the :class:`.Session` has been
        explicitly bound directly to a :class:`_engine.Connection`.
 
        For a multiply-bound or unbound :class:`.Session`, the
        ``mapper`` or ``clause`` arguments are used to determine the
        appropriate bind to return.
 
        Note that the "mapper" argument is usually present
        when :meth:`.Session.get_bind` is called via an ORM
        operation such as a :meth:`.Session.query`, each
        individual INSERT/UPDATE/DELETE operation within a
        :meth:`.Session.flush`, call, etc.
 
        The order of resolution is:
 
        1. if mapper given and :paramref:`.Session.binds` is present,
           locate a bind based first on the mapper in use, then
           on the mapped class in use, then on any base classes that are
           present in the ``__mro__`` of the mapped class, from more specific
           superclasses to more general.
        2. if clause given and ``Session.binds`` is present,
           locate a bind based on :class:`_schema.Table` objects
           found in the given clause present in ``Session.binds``.
        3. if ``Session.binds`` is present, return that.
        4. if clause given, attempt to return a bind
           linked to the :class:`_schema.MetaData` ultimately
           associated with the clause.
        5. if mapper given, attempt to return a bind
           linked to the :class:`_schema.MetaData` ultimately
           associated with the :class:`_schema.Table` or other
           selectable to which the mapper is mapped.
        6. No bind can be found, :exc:`~sqlalchemy.exc.UnboundExecutionError`
           is raised.
 
        Note that the :meth:`.Session.get_bind` method can be overridden on
        a user-defined subclass of :class:`.Session` to provide any kind
        of bind resolution scheme.  See the example at
        :ref:`session_custom_partitioning`.
 
        :param mapper:
          Optional mapped class or corresponding :class:`_orm.Mapper` instance.
          The bind can be derived from a :class:`_orm.Mapper` first by
          consulting the "binds" map associated with this :class:`.Session`,
          and secondly by consulting the :class:`_schema.MetaData` associated
          with the :class:`_schema.Table` to which the :class:`_orm.Mapper` is
          mapped for a bind.
 
        :param clause:
            A :class:`_expression.ClauseElement` (i.e.
            :func:`_expression.select`,
            :func:`_expression.text`,
            etc.).  If the ``mapper`` argument is not present or could not
            produce a bind, the given expression construct will be searched
            for a bound element, typically a :class:`_schema.Table`
            associated with
            bound :class:`_schema.MetaData`.
 
        .. seealso::
 
             :ref:`session_partitioning`
 
             :paramref:`.Session.binds`
 
             :meth:`.Session.bind_mapper`
 
             :meth:`.Session.bind_table`
 
        NzlThis session is not bound to a single Engine or Connection, and no context was provided to locate a binding.Úplugin_subjectzmapper zSQL expressionz&Could not locate a bind configured on ú, z or this Session.)r|r-rÕZUnboundExecutionErrorrBr¹ràrºrZUnmappedClassErrorr¥Ú__mro__Zpersist_selectabler¨rÜrˆrIZiteraterrKrrØÚjoin) rŽrˆr¦r-rÍr¿rŠZinspected_mapperr»ržrÀÚobjrrrrr+Þ    sbT ÿ 
 
 
ÿ
 
 
 
ÿzSession.get_bindz_EntityType[_O]z    Query[_O])Ú_entityr‹cCsdSrŒr)rŽrÅrrrr}
sz Session.queryzTypedColumnsClauseRole[_T]zRowReturningQuery[Tuple[_T]])Ú_colexprr‹cCsdSrŒr)rŽrÆrrrr
sz
_TCCA[_T0]z
_TCCA[_T1]z"RowReturningQuery[Tuple[_T0, _T1]])Ú_Session__ent0Ú_Session__ent1r‹cCsdSrŒr)rŽrÇrÈrrrrŒ
sz
_TCCA[_T2]z'RowReturningQuery[Tuple[_T0, _T1, _T2]])rÇrÈÚ_Session__ent2r‹cCsdSrŒr)rŽrÇrÈrÉrrrr’
sz
_TCCA[_T3]z,RowReturningQuery[Tuple[_T0, _T1, _T2, _T3]])rÇrÈrÉÚ_Session__ent3r‹cCsdSrŒr)rŽrÇrÈrÉrÊrrrr˜
sz
_TCCA[_T4]z1RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4]])rÇrÈrÉrÊÚ_Session__ent4r‹cCsdSrŒr)rŽrÇrÈrÉrÊrËrrrr¢
s    z
_TCCA[_T5]z6RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4, _T5]])rÇrÈrÉrÊrËÚ_Session__ent5r‹cCsdSrŒr)rŽrÇrÈrÉrÊrËrÌrrrr­
s
z
_TCCA[_T6]z;RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6]])rÇrÈrÉrÊrËrÌÚ_Session__ent6r‹cCsdSrŒr)rŽrÇrÈrÉrÊrËrÌrÍrrrr¹
s z
_TCCA[_T7]z@RowReturningQuery[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7]])    rÇrÈrÉrÊrËrÌrÍÚ_Session__ent7r‹c        CsdSrŒr)    rŽrÇrÈrÉrÊrËrÌrÍrÎrrrrÆ
s z_ColumnsClauseArgument[Any]z
Query[Any])Úentitiesr*r‹cOsdSrŒr©rŽrÏr*rrrrÖ
scOs|j||f|ŽS)a¯Return a new :class:`_query.Query` object corresponding to this
        :class:`_orm.Session`.
 
        Note that the :class:`_query.Query` object is legacy as of
        SQLAlchemy 2.0; the :func:`_sql.select` construct is now used
        to construct ORM queries.
 
        .. seealso::
 
            :ref:`unified_tutorial`
 
            :ref:`queryguide_toplevel`
 
            :ref:`query_api_toplevel` - legacy API doc
 
        )r‚rÐrrrrÜ
sr€r£r.rõz)Union[Optional[_O], LoaderCallableStatus])rˆÚprimary_key_identityr¢Úpassiver÷r·r¹r‹c
Cs"|j||d}t ||||¡}    |    S)azLocate an object in the identity map.
 
        Given a primary key identity, constructs an identity key and then
        looks in the session's identity map.  If present, the object may
        be run through unexpiration rules (e.g. load unloaded attributes,
        check if was deleted).
 
        e.g.::
 
            obj = session._identity_lookup(inspect(SomeClass), (1, ))
 
        :param mapper: mapper in use
        :param primary_key_identity: the primary key we are searching for, as
         a tuple.
        :param identity_token: identity token that should be used to create
         the identity key.  Used as is, however overriding subclasses can
         repurpose this in order to interpret the value in a special way,
         such as if None then look among multiple target tokens.
        :param passive: passive load flag passed to
         :func:`.loading.get_from_identity`, which impacts the behavior if
         the object is found; the object may be validated and/or unexpired
         if the flag allows for SQL to be emitted.
        :param lazy_loaded_from: an :class:`.InstanceState` that is
         specifically asking for this identity as a related identity.  Used
         for sharding schemes where there is a correspondence between an object
         and a related object being lazy-loaded (or otherwise
         relationship-loaded).
 
        :return: None if the object is not found in the identity map, *or*
         if the object was unexpired and found to have been deleted.
         if passive flags disallow SQL and the object is expired, returns
         PASSIVE_NO_RESULT.   In all other cases the instance is returned.
 
        .. versionchanged:: 1.4.0 - the :meth:`.Session._identity_lookup`
           method was moved from :class:`_query.Query` to
           :class:`.Session`, to avoid having to instantiate the
           :class:`_query.Query` object.
 
 
        )r¢)Zidentity_key_from_primary_keyrZget_from_identity)
rŽrˆrÑr¢rÒr÷r·r¹r@Z return_valuerrrÚ_identity_lookupò
s 3ÿzSession._identity_lookupzIterator[Session]ccs$|j}d|_z
|VW5||_XdS)agReturn a context manager that disables autoflush.
 
        e.g.::
 
            with session.no_autoflush:
 
                some_object = SomeClass()
                session.add(some_object)
                # won't autoflush
                some_object.related_thing = session.query(SomeRelated).first()
 
        Operations that proceed within the ``with:`` block
        will not be subject to flushes occurring upon query
        access.  This is useful when initializing a series
        of objects which involve existing database queries,
        where the uncompleted object should not yet be flushed.
 
        FN)r)rŽrrrrÚ no_autoflush- s
 
zSession.no_autoflushzˆThis warning originated from the Session 'autoflush' process, which was invoked automatically in response to a user-initiated operation.c
Cs^|jrZ|jsZz | ¡Wn@tjk
rX}z | d¡| t ¡d¡‚W5d}~XYnXdS)Nzraised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurelyr9)    rr4r5rÕZStatementErrorZ
add_detailrqrorp)rŽÚerrrÚ
_autoflushI s  ÿzSession._autoflushr¨zOptional[Iterable[str]]rs)r‰Úattribute_namesÚwith_for_updater‹c Cs¶zt |¡}Wn0tjk
r>}zt |¡|‚W5d}~XYnX| ||¡| ¡|ikrft d¡‚t     
|¡}t   t |ƒ¡}tj|||j|||dddd    dkr²t dt|ƒ¡‚dS)a Expire and refresh attributes on the given instance.
 
        The selected attributes will first be expired as they would when using
        :meth:`_orm.Session.expire`; then a SELECT statement will be issued to
        the database to refresh column-oriented attributes with the current
        value available in the current transaction.
 
        :func:`_orm.relationship` oriented attributes will also be immediately
        loaded if they were already eagerly loaded on the object, using the
        same eager loading strategy that they were loaded with originally.
 
        .. versionadded:: 1.4 - the :meth:`_orm.Session.refresh` method
           can also refresh eagerly loaded attributes.
 
        :func:`_orm.relationship` oriented attributes that would normally
        load using the ``select`` (or "lazy") loader strategy will also
        load **if they are named explicitly in the attribute_names
        collection**, emitting a SELECT statement for the attribute using the
        ``immediate`` loader strategy.  If lazy-loaded relationships are not
        named in :paramref:`_orm.Session.refresh.attribute_names`, then
        they remain as "lazy loaded" attributes and are not implicitly
        refreshed.
 
        .. versionchanged:: 2.0.4  The :meth:`_orm.Session.refresh` method
           will now refresh lazy-loaded :func:`_orm.relationship` oriented
           attributes for those which are named explicitly in the
           :paramref:`_orm.Session.refresh.attribute_names` collection.
 
        .. tip::
 
            While the :meth:`_orm.Session.refresh` method is capable of
            refreshing both column and relationship oriented attributes, its
            primary focus is on refreshing of local column-oriented attributes
            on a single instance. For more open ended "refresh" functionality,
            including the ability to refresh the attributes on many objects at
            once while having explicit control over relationship loader
            strategies, use the
            :ref:`populate existing <orm_queryguide_populate_existing>` feature
            instead.
 
        Note that a highly isolated transaction will return the same values as
        were previously read in that same transaction, regardless of changes
        in database state outside of that transaction.   Refreshing
        attributes usually only makes sense at the start of a transaction
        where database rows have not yet been accessed.
 
        :param attribute_names: optional.  An iterable collection of
          string attribute names indicating a subset of attributes to
          be refreshed.
 
        :param with_for_update: optional boolean ``True`` indicating FOR UPDATE
          should be used, or may be a dictionary containing flags to
          indicate a more specific set of FOR UPDATE flags for the SELECT;
          flags should match the parameters of
          :meth:`_query.Query.with_for_update`.
          Supersedes the :paramref:`.Session.refresh.lockmode` parameter.
 
        .. seealso::
 
            :ref:`session_expire` - introductory material
 
            :meth:`.Session.expire`
 
            :meth:`.Session.expire_all`
 
            :ref:`orm_queryguide_populate_existing` - allows any ORM query
            to refresh objects as they would be loaded normally.
 
        Nzqwith_for_update should be the boolean value True, or a dictionary with options.  A blank dictionary is ambiguous.T)Z refresh_staterØZonly_load_propsZrequire_pk_colsrÔZis_user_refreshzCould not refresh instance '%s')rÚinstance_staterÚNO_STATEÚUnmappedInstanceErrorÚ _expire_staterÖrÕrŒrLÚ_from_argumentr;Úselectr,rZ load_on_identr@rÖr*)rŽr‰r×rØr r»ZstmtrrrÚrefresh_ s:K ÿ
ôòÿ
ÿzSession.refreshcCs&|j ¡D]}| |j|jj¡q
dS)aÊExpires all persistent instances within this Session.
 
        When any attributes on a persistent instance is next accessed,
        a query will be issued using the
        :class:`.Session` object's current transactional context in order to
        load all expired attributes for the given instance.   Note that
        a highly isolated transaction will return the same values as were
        previously read in that same transaction, regardless of changes
        in database state outside of that transaction.
 
        To expire individual objects and individual attributes
        on those objects, use :meth:`Session.expire`.
 
        The :class:`.Session` object's default behavior is to
        expire all state whenever the :meth:`Session.rollback`
        or :meth:`Session.commit` methods are called, so that new
        state can be loaded for the new transaction.   For this reason,
        calling :meth:`Session.expire_all` is not usually needed,
        assuming the transaction is isolated.
 
        .. seealso::
 
            :ref:`session_expire` - introductory material
 
            :meth:`.Session.expire`
 
            :meth:`.Session.refresh`
 
            :meth:`_orm.Query.populate_existing`
 
        N)r>rCrErÐrF©rŽr rrrÚ
expire_allØ s zSession.expire_all)r‰r×r‹c
CsPzt |¡}Wn0tjk
r>}zt |¡|‚W5d}~XYnX| ||¡dS)aÀExpire the attributes on an instance.
 
        Marks the attributes of an instance as out of date. When an expired
        attribute is next accessed, a query will be issued to the
        :class:`.Session` object's current transactional context in order to
        load all expired attributes for the given instance.   Note that
        a highly isolated transaction will return the same values as were
        previously read in that same transaction, regardless of changes
        in database state outside of that transaction.
 
        To expire all objects in the :class:`.Session` simultaneously,
        use :meth:`Session.expire_all`.
 
        The :class:`.Session` object's default behavior is to
        expire all state whenever the :meth:`Session.rollback`
        or :meth:`Session.commit` methods are called, so that new
        state can be loaded for the new transaction.   For this reason,
        calling :meth:`Session.expire` only makes sense for the specific
        case that a non-ORM SQL statement was emitted in the current
        transaction.
 
        :param instance: The instance to be refreshed.
        :param attribute_names: optional list of string attribute names
          indicating a subset of attributes to be expired.
 
        .. seealso::
 
            :ref:`session_expire` - introductory material
 
            :meth:`.Session.expire`
 
            :meth:`.Session.refresh`
 
            :meth:`_orm.Query.populate_existing`
 
        N)rrÙrrÚrÛrÜ)rŽr‰r×r r»rrrÚexpireû s
'zSession.expirer•)r r×r‹cCs\| |¡|r| |j|¡n:t|jj d|¡ƒ}| |¡|D]\}}}}| |¡q@dS)Nzrefresh-expire)Ú_validate_persistentÚ_expire_attributesrÐrÆÚmanagerrˆÚcascade_iteratorÚ_conditional_expire)rŽr r×ÚcascadedÚoÚmÚst_Údct_rrrrÜ( s
ÿ
zSession._expire_state)r rr‹cCs>|jr| |j|jj¡n ||jkr:|j |¡| |¡dS)z5Expire a state if persistent, else expunge if pendingN)r@rErÐr>rFrr¢Z_detach)rŽr rrrrrç: s
 
 zSession._conditional_expirer©c
Cszt |¡}Wn0tjk
r>}zt |¡|‚W5d}~XYnX|j|jk    r^t dt    |ƒ¡‚t
|j j   d|¡ƒ}| |gdd„|Dƒ¡dS)zÃRemove the `instance` from this ``Session``.
 
        This will free all internal references to the instance.  Cascading
        will be applied according to the *expunge* cascade rule.
 
        Nz*Instance %s is not present in this SessionÚexpungecSsg|]\}}}}|‘qSrr)rrérêrërìrrrrX s
z#Session.expunge.<locals>.<listcomp>)rrÙrrÚrÛÚ
session_idr~rÕrÖr/rÆrårˆrær<)rŽr‰r r»rèrrrríE s 
ÿÿzSession.expungezIterable[InstanceState[Any]])Ústatesr:r‹cCsv|D]Z}||jkr |j |¡q|j |¡rH|j |¡|j |d¡q|jr|jj |d¡qtjj    |||ddS)Nr9)
rr¢r>Úcontains_stater?rrrJr4rK)rŽrïr:r rrrr<Z s
  ÿzSession._expunge_stateszSet[InstanceState[Any]])rïr‹c
Csš|jjp
d}|D]}t|ƒ}| ¡}|dk    r| |¡}t |d¡rL|jrZt |d¡rlt     
dt |ƒ¡‚|j dkr~||_ n\|j |krÚ|j  |¡|j}|dk    s¦t‚||jkrÀ|j|d}n|j }||f|j|<||_ |j  |¡}    |    dk    r| |    ¡|kr|     ¡dk    rt d|f¡d|_qtj dd„|Dƒ|j ¡| |¡|dk    rr| |j¡D]}|||ƒq`t|ƒ |j¡D]}|j |¡q‚dS)    z´Register all persistent objects from a flush.
 
        This is used both for pending objects moving to the persistent
        state as well as already persistent objects.
 
        NraOInstance %s has a NULL identity key.  If this is an auto-generated value, check that the database table allows generation of new primary key values, and that the mapped Column object is configured to expect these generated values.  Ensure also that this flush() is not occurring at an inappropriate time, such as within a load() event.rz§Identity map already had an identity for %s, replacing it with newly flushed object.   Are there load operations occurring inside of an event handler within the flush?Fcss|]}||jfVqdSrŒ©rЩrr rrrÚ    <genexpr>² sz/Session._register_persistent.<locals>.<genexpr>)r Úpending_to_persistentr)rÄÚ_identity_key_from_stater(Ú intersectionÚallow_partial_pksÚ
issupersetrrbr/r@r>r?rrrrAr<rOÚ_orphaned_outside_of_sessionrJr4Ú_commit_all_statesÚ_register_alteredrrár¢)
rŽrïrôr rˆrÄZ instance_keyrlZorig_keyÚoldrrrÚ_register_persistentk sj 
 
 ÿþ ýùÿ
 
 
þ
 ÿ þ
ýýÿ ÿ
 
zSession._register_persistentcCs8|jr4|D](}||jkr&d|jj|<q
d|jj|<q
dS©NT)rrr)rŽrïr rrrrû¿ s
 
zSession._register_alteredcCsn|jjp
d}|D]X}|jr&d|jj|<|dk    r6| ¡}|j |¡|j |d¡d|_|dk    r|||ƒqdSrþ)r Úpersistent_to_deletedrrrÄr>r?r¢)rŽrïrÿr rÄrrrÚ_remove_newly_deletedÇ s   zSession._remove_newly_deleted)r‰Ú_warnr‹c
Csb|r|jr| d¡zt |¡}Wn0tjk
rR}zt |¡|‚W5d}~XYnX| |¡dS)a™Place an object into this :class:`_orm.Session`.
 
        Objects that are in the :term:`transient` state when passed to the
        :meth:`_orm.Session.add` method will move to the
        :term:`pending` state, until the next flush, at which point they
        will move to the :term:`persistent` state.
 
        Objects that are in the :term:`detached` state when passed to the
        :meth:`_orm.Session.add` method will move to the :term:`persistent`
        state directly.
 
        If the transaction used by the :class:`_orm.Session` is rolled back,
        objects which were transient when they were passed to
        :meth:`_orm.Session.add` will be moved back to the
        :term:`transient` state, and will no longer be present within this
        :class:`_orm.Session`.
 
        .. seealso::
 
            :meth:`_orm.Session.add_all`
 
            :ref:`session_adding` - at :ref:`session_basics`
 
        z Session.add()N)r}Ú_flush_warningrrÙrrÚrÛÚ_save_or_update_state)rŽr‰rr r»rrrrâÝ s
 
z Session.addzIterable[object])Ú    instancesr‹cCs,|jr| d¡|D]}|j|ddqdS)a2Add the given collection of instances to this :class:`_orm.Session`.
 
        See the documentation for :meth:`_orm.Session.add` for a general
        behavioral description.
 
        .. seealso::
 
            :meth:`_orm.Session.add`
 
            :ref:`session_adding` - at :ref:`session_basics`
 
        zSession.add_all()F)rN)r}rrâ)rŽrr‰rrrÚadd_all s
zSession.add_allr—cCsFd|_| |¡t|ƒ}|jd||jdD]\}}}}| |¡q*dS)NFz save-update)Zhalt_on)rùÚ_save_or_update_implr)ræÚ_contains_state)rŽr rˆrérêrërìrrrr s
ÿzSession._save_or_update_statec
Csd|jr| d¡zt |¡}Wn0tjk
rN}zt |¡|‚W5d}~XYnX|j||dddS)aVMark an instance as deleted.
 
        The object is assumed to be either :term:`persistent` or
        :term:`detached` when passed; after the method is called, the
        object will remain in the :term:`persistent` state until the next
        flush proceeds.  During this time, the object will also be a member
        of the :attr:`_orm.Session.deleted` collection.
 
        When the next flush proceeds, the object will move to the
        :term:`deleted` state, indicating a ``DELETE`` statement was emitted
        for its row within the current transaction.   When the transaction
        is successfully committed,
        the deleted object is moved to the :term:`detached` state and is
        no longer present within this :class:`_orm.Session`.
 
        .. seealso::
 
            :ref:`session_deleting` - at :ref:`session_basics`
 
        zSession.delete()NT)Úhead)r}rrrÙrrÚrÛÚ _delete_impl©rŽr‰r r»rrrÚdelete s
zSession.delete)r rÄrr‹c
Cs¼|jdkr&|r"t dt|ƒ¡‚ndS| ||¡}||jkr@dS|j |¡|r\| ||¡|rvt    |j
j   d|¡ƒ}nd}||j|<|r¸t r˜|dk    s˜t‚|D]\}}}}    | ||d¡qœdS)NúInstance '%s' is not persistedr F)r@rÕrÖr/Ú_before_attachrr>râÚ _after_attachrÆrårˆrærrr    )
rŽr rÄrÚ    to_attachZcascade_statesrérêrërìrrrr    = s.
 
ÿ 
  ÿ
 zSession._delete_impl©ÚoptionsÚpopulate_existingrØr¢r·r¹Ú_PKIdentityArgumentzOptional[Sequence[ORMOption]]z Optional[_O])    rÞr¦rrrØr¢r·r¹r‹c     Cs|j||tj||||||d    S)aûReturn an instance based on the given primary key identifier,
        or ``None`` if not found.
 
        E.g.::
 
            my_user = session.get(User, 5)
 
            some_object = session.get(VersionedFoo, (5, 10))
 
            some_object = session.get(
                VersionedFoo,
                {"id": 5, "version_id": 10}
            )
 
        .. versionadded:: 1.4 Added :meth:`_orm.Session.get`, which is moved
           from the now legacy :meth:`_orm.Query.get` method.
 
        :meth:`_orm.Session.get` is special in that it provides direct
        access to the identity map of the :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:`_orm.Session.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.
 
        :param entity: a mapped class or :class:`.Mapper` indicating the
         type of entity to be loaded.
 
        :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 = session.get(SomeClass, 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 = session.get(SomeClass, (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 = session.get(SomeClass, {"id": 5, "version_id": 10})
 
        :param options: optional sequence of loader options which will be
         applied to the query, if one is emitted.
 
        :param populate_existing: causes the method to unconditionally emit
         a SQL query and refresh the object with the newly loaded data,
         regardless of whether or not the object is already present.
 
        :param with_for_update: optional boolean ``True`` indicating FOR UPDATE
          should be used, or may be a dictionary containing flags to
          indicate a more specific set of FOR UPDATE flags for the SELECT;
          flags should match the parameters of
          :meth:`_query.Query.with_for_update`.
          Supersedes the :paramref:`.Session.refresh.lockmode` parameter.
 
        :param execution_options: optional dictionary of execution options,
         which will be associated with the query execution if one is emitted.
         This dictionary can provide a subset of the options that are
         accepted by :meth:`_engine.Connection.execution_options`, and may
         also provide additional options understood only in an ORM context.
 
         .. versionadded:: 1.4.29
 
         .. seealso::
 
            :ref:`orm_queryguide_execution_options` - ORM-specific execution
            options
 
        :param bind_arguments: dictionary of additional arguments to determine
         the bind.  May include "mapper", "bind", or other custom arguments.
         Contents of this dictionary are passed to the
         :meth:`.Session.get_bind` method.
 
         .. versionadded: 2.0.0rc1
 
        :return: The object instance, or ``None``.
 
        r)Ú    _get_implrZload_on_pk_identity)    rŽrÞr¦rrrØr¢r·r¹rrrrÜe sr÷z Session.getzCallable[..., _O]z$Optional[Sequence[ExecutableOption]])
rÞrÑÚ
db_load_fnrrrØr¢r·r¹r‹c
s
tˆƒr,tˆƒtjkr,tjtˆƒ}
|
ˆƒ‰t|ƒ} | dksB| jsPt d|¡‚tˆt    ƒ} | snt
j ˆdgd‰t ˆƒt | j ƒkr t dd dd„| j Dƒ¡¡‚| rH| j} | rät| ƒ ˆ¡}|rät    ˆƒ‰|D]}ˆ|ˆ| |<qÎzt‡fdd„| jDƒƒ‰WnFtk
rF}z&t dd d    d„| jDƒ¡¡|‚W5d}~XYnX|s¤| js¤|dkr¤|j| ˆ|||    d
}|dk    r”t|| jƒsdS|S|tjk    s¤t‚tjj}|r¾|d |i7}t  | ¡ !t"¡}|dk    rät# $|¡|_%|rô|j&|Ž}|||ˆ||||    d S) Nz(Expected mapped class or mapper, got: %r)ÚdefaultzoIncorrect number of values in identifier to formulate primary key for session.get(); primary key columns are %sú,css|]}d|VqdS©z'%s'Nr)rÚcrrrró sz$Session._get_impl.<locals>.<genexpr>c3s|]}ˆ|jVqdSrŒ©r@©rÚprop©rÑrrró!sÿz˜Incorrect names of values in identifier to formulate primary key for session.get(); primary key attribute names are %s (synonym names are also accepted)css|]}d|jVqdSrrrrrrró+sÿ)r¢r·r¹Z_populate_existing)rör¢r·r¹)'r#rºrZ_composite_gettersrBZ    is_mapperrÕrŒràrÐr<Zto_listr×Z primary_keyrÖrÃZ _pk_synonymsrárörÆZ_identity_key_propsÚKeyErrorZalways_refreshrÓr¥r+ZPASSIVE_CLASS_MISMATCHrrrürýr;rÞZset_label_stylerMrLrÝZ_for_update_argr)rŽrÞrÑrrrrØr¢r·r¹ÚgetterrˆZis_dictZ pk_synonymsZ correct_keysÚkr»r‰rörµrrrrã sºÿÿþÿÿ
ÿþÿÿþÿ þ 
þýÿø ÿþýû
 
ÿ
ÿ
ùzSession._get_impl)Úloadrr!)r‰r!rr‹cCsl|jr| d¡i}i}|r$| ¡t|ƒ|j}z,d|_|jt |¡t |¡||||dW¢S||_XdS)a Copy the state of a given instance into a corresponding instance
        within this :class:`.Session`.
 
        :meth:`.Session.merge` examines the primary key attributes of the
        source instance, and attempts to reconcile it with an instance of the
        same primary key in the session.   If not found locally, it attempts
        to load the object from the database based on primary key, and if
        none can be located, creates a new instance.  The state of each
        attribute on the source instance is then copied to the target
        instance.  The resulting target instance is then returned by the
        method; the original source instance is left unmodified, and
        un-associated with the :class:`.Session` if not already.
 
        This operation cascades to associated instances if the association is
        mapped with ``cascade="merge"``.
 
        See :ref:`unitofwork_merging` for a detailed discussion of merging.
 
        :param instance: Instance to be merged.
        :param load: Boolean, when False, :meth:`.merge` switches into
         a "high performance" mode which causes it to forego emitting history
         events as well as all database access.  This flag is used for
         cases such as transferring graphs of objects into a :class:`.Session`
         from a second level cache, or to transfer just-loaded objects
         into the :class:`.Session` owned by a worker thread or process
         without re-querying the database.
 
         The ``load=False`` use case adds the caveat that the given
         object has to be in a "clean" state, that is, has no pending changes
         to be flushed - even if the incoming object is detached from any
         :class:`.Session`.   This is so that when
         the merge operation populates local attributes and
         cascades to related objects and
         collections, the values can be "stamped" onto the
         target object as is, without generating any history or attribute
         events, and without the need to reconcile the incoming data with
         any existing related objects or collections that might not
         be loaded.  The resulting objects from ``load=False`` are always
         produced as "clean", so it is only appropriate that the given objects
         should be "clean" as well, else this suggests a mis-use of the
         method.
        :param options: optional sequence of loader options which will be
         applied to the :meth:`_orm.Session.get` method when the merge
         operation loads the existing version of the object from the database.
 
         .. versionadded:: 1.4.24
 
 
        .. seealso::
 
            :func:`.make_transient_to_detached` - provides for an alternative
            means of "merging" a single object into the :class:`.Session`
 
        zSession.merge()F)r!rÚ
_recursiveÚ_resolve_conflict_mapN)    r}rrÖr,rÚ_mergerrÙÚ instance_dict)rŽr‰r!rr"r#rrrrÚmergees&>
ú
    z Session.merge)rúInstanceState[_O]rSzDict[Any, object]z#Dict[_IdentityKeyType[Any], object])r Ú
state_dictrr!r"r#r‹c Cs¶t|ƒ}||krtt||ƒSd}|j}    |    dkrš||jkrLt dt|ƒ¡|sZt     d¡‚| 
|¡}    t j |    dko–t  |    d¡ p–|jo–t  |    d¡ }
nd}
|    |jkrÒz|j|    } WqÖtk
rÎd} YqÖXnd} | dkr`|
rü|    |krütt||    ƒ} nd|s>|jrt     d¡‚|j ¡} t | ¡} |    | _| | ¡d}n"|
r`|j|j|    d|    d|d} | dkr˜|j ¡} t | ¡} t | ¡} d}| | ¡nt | ¡} t | ¡} | ||<| ||    <|| k    rx|jdk    r8|j|||jtj d    }|j| | |jtj d    }|t j!k    r8|t j!k    r8||kr8t" #d
|t| ƒ|f¡‚|j$| _$|j%| _%|  &|¡|j'D]}| (|||| | |||¡qX|sœ|  )| |j¡| j*j+ ,| d¡|r²| j*j+ -| d¡| S) NFzrInstance %s is already pending in this Session yet is being merged again; this is probably not what you want to doz¦merge() with load=False option does not support objects transient (i.e. unpersisted) objects.  flush() all changes on mapped instances before merging with load=False.rTz“merge() with load=False option does not support objects marked as 'dirty'.  flush() all changes on mapped instances before merging with load=False.r9)r¢r©rÒzšVersion id '%s' on merged state %s does not match existing version '%s'. Leave the version attribute unset when merging to update the most recent version.).r)rr!r@rr<rOr/rÕrÖrõr+Z    NEVER_SETr(rör÷rør>rrDZ class_managerÚ new_instancerrÙrBrÜr¥r%rZversion_id_colZ_get_state_attr_by_columnr.ZPASSIVE_NO_INITIALIZEZPASSIVE_NO_RESULTrZStaleDataErrorZ    load_pathröZ_copy_callablesZiterate_propertiesr&Ú _commit_allrår Z_sa_event_merge_wo_loadr!)rŽr r(rr!r"r#rˆr*r@Zkey_is_persistentÚmergedZ merged_stateZ merged_dictÚexisting_versionZmerged_versionrrrrr$¼sè
 
þÿÿ
ÿú
 
 
 ÿ
 
 
ü
 
 
 
 
 
 
 üüÿÿÿýûýüÿ 
 
ø ÿzSession._mergecCs"|j |¡st dt|ƒ¡‚dS)Nz3Instance '%s' is not persistent within this Session)r>rðrÕrÖr/ràrrrrãbs  ÿÿzSession._validate_persistentcCsd|jdk    rt dt|ƒ¡‚| ¡}| ||¡}||jkrP||j|<t|jƒ|_|r`|     ||¡dS)NzGObject '%s' already has an identity - it can't be registered as pending)
r@rÕrÖr/rÄr rr×Z insert_orderr)rŽr rÄrrrrÚ
_save_implis
ÿÿ 
 
 zSession._save_impl)r r;r‹cCs¼|jdkrt dt|ƒ¡‚|jrH|r6|js0dS|`nt dt|ƒ¡‚| ¡}|dkr\dS| ||¡}|j |d¡|rˆ|j     
|¡n |j      |¡|r¦|  ||¡n|r¸|j  ||¡dS)Nr zsInstance '%s' has been deleted.  Use the make_transient() function to send this object back to the transient state.)r@rÕrÖr/rZ    _attachedrÄr r¢r>rArârr Zdeleted_to_persistent)rŽr r;rÄrrrrrBxs4
 
ÿýÿ  zSession._update_implcCs$|jdkr| |¡n
| |¡dSrŒ)r@r.rBràrrrr s
 zSession._save_or_update_impl)rÄr‹c
Csfzt |¡}Wn0tjk
r>}zt |¡|‚W5d}~XYnX| ||¡}d|_|rb| ||¡dS)a
Associate an object with this :class:`.Session` for related
        object loading.
 
        .. warning::
 
            :meth:`.enable_relationship_loading` exists to serve special
            use cases and is not recommended for general use.
 
        Accesses of attributes mapped with :func:`_orm.relationship`
        will attempt to load a value from the database using this
        :class:`.Session` as the source of connectivity.  The values
        will be loaded based on foreign key and primary key values
        present on this object - if not present, then those relationships
        will be unavailable.
 
        The object will be attached to this session, but will
        **not** participate in any persistence operations; its state
        for almost all purposes will remain either "transient" or
        "detached", except for the case of relationship loading.
 
        Also note that backrefs will often not work as expected.
        Altering a relationship-bound attribute on the target object
        may not fire off a backref event, if the effective value
        is what was already loaded from a foreign-key-holding value.
 
        The :meth:`.Session.enable_relationship_loading` method is
        similar to the ``load_on_pending`` flag on :func:`_orm.relationship`.
        Unlike that flag, :meth:`.Session.enable_relationship_loading` allows
        an object to remain transient while still being able to load
        related items.
 
        To make a transient object associated with a :class:`.Session`
        via :meth:`.Session.enable_relationship_loading` pending, add
        it to the :class:`.Session` using :meth:`.Session.add` normally.
        If the object instead represents an existing identity in the database,
        it should be merged using :meth:`.Session.merge`.
 
        :meth:`.Session.enable_relationship_loading` does not improve
        behavior when the ORM is used normally - object references should be
        constructed at the object level, not at the foreign key level, so
        that they are present in an ordinary way before flush()
        proceeds.  This method is not intended for general use.
 
        .. seealso::
 
            :paramref:`_orm.relationship.load_on_pending` - this flag
            allows per-relationship loading of many-to-ones on items that
            are pending.
 
            :func:`.make_transient_to_detached` - allows for an object to
            be added to a :class:`.Session` without SQL emitted, which then
            will unexpire attributes on access.
 
        NT)rrÙrrÚrÛr Z _load_pendingr)rŽrÄr r»rrrrÚenable_relationship_loading¦s7 z#Session.enable_relationship_loading)r rÄr‹cCsV| ¡|j|jkrdS|jrD|jtkrDt dt|ƒ|j|jf¡‚|j ||¡dS)NFz>Object '%s' is already attached to session '%s' (this is '%s')T)    rŸrîr~rrÕrÖr/r Z before_attach©rŽr rÄrrrr çs þÿzSession._before_attachcCsT|j|_|jr|jdkr||_|j ||¡|jrB|j ||¡n|j ||¡dSrŒ)    r~rîrDZ _strong_objr Z after_attachr@Zdetached_to_persistentZtransient_to_pendingr0rrrrøszSession._after_attachc
CsJzt |¡}Wn0tjk
r>}zt |¡|‚W5d}~XYnX| |¡S)zªReturn True if the instance is associated with this session.
 
        The instance may be pending or persistent within the Session for a
        result of True.
 
        N)rrÙrrÚrÛrr
rrrÚ __contains__s
zSession.__contains__zIterator[object]cCs tt|j ¡ƒt|j ¡ƒƒS)zWIterate over all pending or persistent instances within this
        Session.
 
        )ÚiterrÆrrcr>rÈrrrÚ__iter__sÿzSession.__iter__cCs||jkp|j |¡SrŒ)rr>rðràrrrrszSession._contains_statezOptional[Sequence[Any]])Úobjectsr‹cCs>|jrt d¡‚| ¡rdSzd|_| |¡W5d|_XdS)aíFlush all the object changes to the database.
 
        Writes out all pending object creations, deletions and modifications
        to the database as INSERTs, DELETEs, UPDATEs, etc.  Operations are
        automatically ordered by the Session's unit of work dependency
        solver.
 
        Database operations will be issued in the current transactional
        context and do not affect the state of the transaction, unless an
        error occurs, in which case the entire transaction is rolled back.
        You may flush() as often as you like within a transaction to move
        changes from Python to the database's transaction buffer.
 
        :param objects: Optional; restricts the flush operation to operate
          only on elements that are in the given collection.
 
          This feature is for an extremely narrow set of use cases where
          particular objects may need to be operated upon before the
          full flush() occurs.  It is not intended for general use.
 
        zSession is already flushingNFT)r4rÕrÖraÚ_flush)rŽr4rrrr5s
z Session.flush)Úmethodr‹cCst d|¡dS)NzÚUsage of the '%s' operation is not currently supported within the execution stage of the flush process. Results may not be consistent.  Consider using alternative event listeners or connection-level operations instead.)r<rO)rŽr6rrrr>s
ýÿzSession._flush_warningcCs|j ¡ o|j o|j SrŒ)r>Zcheck_modifiedrrrÈrrrraFs
 ÿýzSession._is_cleanzOptional[Sequence[object]]c Cs¢|j}|s&|js&|js&|jj ¡dSt|ƒ}|jjrL|j |||¡|j}t    |jƒ}t    |jƒ}t    |ƒ 
|¡}|rÎt    ƒ}|D]N}zt   |¡}Wn0t jk
r¾}    zt  |¡|    ‚W5d}    ~    XYnX| |¡q|nd}t    ƒ}
|rô| |¡ |¡ 
|¡} n| |¡ 
|¡} | D]h}t|ƒ |¡} | o$|j} | rH| sH|jrH| |g¡n&|j|| d}|sdtdƒ‚|
 |¡q|rŠ| |¡ 
|
¡} n
| 
|
¡} | D]"}|j|dd}|s˜tdƒ‚q˜|jsÈdS| ¡ ¡|_}z–d|_z | ¡W5d|_X|j  ||¡| !¡|sX|jjrXt"|jjƒ}t#j$j%dd„|jjDƒ|jdt& 'd|¡|j (||¡| )¡Wn,t& *¡|j+dd    W5QRXYnXdS)
N)Zisdeletez*Failed to add object to the flush context!TFcSsg|]}||jf‘qSrrñròrrrr§sÿz"Session._flush.<locals>.<listcomp>)r%zÿAttribute history events accumulated on %d previously clean instances within inner-flush event handlers have been reset, and will not result in database updates. Consider using set_committed_value() within inner-flush event handlers to avoid this warning.©rn),Ú _dirty_statesrrr>rFrLr8r Z before_flushráÚ
differencerrÙrrÚrÛrârÅrör)Z
_is_orphanZ has_identityrùr<Zregister_objectrZhas_workrŸr0rZr}r¬Z after_flushZfinalize_flush_changesr×rJr4rúr<rOZafter_flush_postexecr_rdre)rŽr4ÚdirtyZ flush_contextÚdeletedÚnewZobjsetrér r»Ú    processedÚprocZ    is_orphanZis_persistent_orphanZ_regrZZlen_rrrr5Ms” 
 
 ÿþýÿ
  þûûÿ 
zSession._flush)r4Úreturn_defaultsÚupdate_changed_onlyÚpreserve_orderr‹c
 
Csfdd„|Dƒ}|s"t|dd„d}dddœd    d
„}t ||¡D]"\\}}}    | ||    |d ||d ¡q>d S)aŒ Perform a bulk save of the given list of objects.
 
        .. legacy::
 
            This method is a legacy feature as of the 2.0 series of
            SQLAlchemy.   For modern bulk INSERT and UPDATE, see
            the sections :ref:`orm_queryguide_bulk_insert` and
            :ref:`orm_queryguide_bulk_update`.
 
            For general INSERT and UPDATE of existing ORM mapped objects,
            prefer standard :term:`unit of work` data management patterns,
            introduced in the :ref:`unified_tutorial` at
            :ref:`tutorial_orm_data_manipulation`.  SQLAlchemy 2.0
            now uses :ref:`engine_insertmanyvalues` with modern dialects
            which solves previous issues of bulk INSERT slowness.
 
        :param objects: a sequence of mapped object instances.  The mapped
         objects are persisted as is, and are **not** associated with the
         :class:`.Session` afterwards.
 
         For each object, whether the object is sent as an INSERT or an
         UPDATE is dependent on the same rules used by the :class:`.Session`
         in traditional operation; if the object has the
         :attr:`.InstanceState.key`
         attribute set, then the object is assumed to be "detached" and
         will result in an UPDATE.  Otherwise, an INSERT is used.
 
         In the case of an UPDATE, statements are grouped based on which
         attributes have changed, and are thus to be the subject of each
         SET clause.  If ``update_changed_only`` is False, then all
         attributes present within each object are applied to the UPDATE
         statement, which may help in allowing the statements to be grouped
         together into a larger executemany(), and will also reduce the
         overhead of checking history on attributes.
 
        :param return_defaults: when True, rows that are missing values which
         generate defaults, namely integer primary key defaults and sequences,
         will be inserted **one at a time**, so that the primary key value
         is available.  In particular this will allow joined-inheritance
         and other multi-table mappings to insert correctly without the need
         to provide primary key values ahead of time; however,
         :paramref:`.Session.bulk_save_objects.return_defaults` **greatly
         reduces the performance gains** of the method overall.  It is strongly
         advised to please use the standard :meth:`_orm.Session.add_all`
         approach.
 
        :param update_changed_only: when True, UPDATE statements are rendered
         based on those attributes in each state that have logged changes.
         When False, all attributes present are rendered into the SET clause
         with the exception of primary key attributes.
 
        :param preserve_order: when True, the order of inserts and updates
         matches exactly the order in which the objects are given.   When
         False, common types of objects are grouped into inserts
         and updates, to allow for more batching opportunities.
 
        .. seealso::
 
            :doc:`queryguide/dml`
 
            :meth:`.Session.bulk_insert_mappings`
 
            :meth:`.Session.bulk_update_mappings`
 
        css|]}t |¡VqdSrŒ)rrÙ)rrÄrrrrósz,Session.bulk_save_objects.<locals>.<genexpr>cSst|jƒ|jdk    fSrŒ)Úidrˆr@rrrrÚ<lambda>óz+Session.bulk_save_objects.<locals>.<lambda>rr'zTuple[Mapper[_O], bool]r—cSs|j|jdk    fSrŒ)rˆr@rrrrÚ grouping_keysz/Session.bulk_save_objects.<locals>.grouping_keyTFN)ÚsortedrÓÚgroupbyÚ_bulk_save_mappings)
rŽr4r?r@rAZ
obj_statesrErˆÚisupdaterïrrrÚbulk_save_objectsÅs(KþÿùzSession.bulk_save_objectsrzIterable[Dict[str, Any]])rˆÚmappingsr?Ú render_nullsr‹c    Cs| ||dd|d|¡dS)a= Perform a bulk insert of the given list of mapping dictionaries.
 
        .. legacy::
 
            This method is a legacy feature as of the 2.0 series of
            SQLAlchemy.   For modern bulk INSERT and UPDATE, see
            the sections :ref:`orm_queryguide_bulk_insert` and
            :ref:`orm_queryguide_bulk_update`.  The 2.0 API shares
            implementation details with this method and adds new features
            as well.
 
        :param mapper: a mapped class, or the actual :class:`_orm.Mapper`
         object,
         representing the single kind of object represented within the mapping
         list.
 
        :param mappings: a sequence of dictionaries, each one containing the
         state of the mapped row to be inserted, in terms of the attribute
         names on the mapped class.   If the mapping refers to multiple tables,
         such as a joined-inheritance mapping, each dictionary must contain all
         keys to be populated into all tables.
 
        :param return_defaults: when True, the INSERT process will be altered
         to ensure that newly generated primary key values will be fetched.
         The rationale for this parameter is typically to enable
         :ref:`Joined Table Inheritance <joined_inheritance>` mappings to
         be bulk inserted.
 
         .. note:: for backends that don't support RETURNING, the
            :paramref:`_orm.Session.bulk_insert_mappings.return_defaults`
            parameter can significantly decrease performance as INSERT
            statements can no longer be batched.   See
            :ref:`engine_insertmanyvalues`
            for background on which backends are affected.
 
        :param render_nulls: When True, a value of ``None`` will result
         in a NULL value being included in the INSERT statement, rather
         than the column being omitted from the INSERT.   This allows all
         the rows being INSERTed to have the identical set of columns which
         allows the full set of rows to be batched to the DBAPI.  Normally,
         each column-set that contains a different combination of NULL values
         than the previous row must omit a different series of columns from
         the rendered INSERT statement, which means it must be emitted as a
         separate statement.   By passing this flag, the full set of rows
         are guaranteed to be batchable into one batch; the cost however is
         that server-side defaults which are invoked by an omitted column will
         be skipped, so care must be taken to ensure that these are not
         necessary.
 
         .. warning::
 
            When this flag is set, **server side default SQL values will
            not be invoked** for those columns that are inserted as NULL;
            the NULL value will be sent explicitly.   Care must be taken
            to ensure that no server-side default functions need to be
            invoked for the operation as a whole.
 
        .. seealso::
 
            :doc:`queryguide/dml`
 
            :meth:`.Session.bulk_save_objects`
 
            :meth:`.Session.bulk_update_mappings`
 
        FN©rH)rŽrˆrKr?rLrrrÚbulk_insert_mappings.sIùzSession.bulk_insert_mappings)rˆrKr‹c    Cs| ||ddddd¡dS)aaPerform a bulk update of the given list of mapping dictionaries.
 
        .. legacy::
 
            This method is a legacy feature as of the 2.0 series of
            SQLAlchemy.   For modern bulk INSERT and UPDATE, see
            the sections :ref:`orm_queryguide_bulk_insert` and
            :ref:`orm_queryguide_bulk_update`.  The 2.0 API shares
            implementation details with this method and adds new features
            as well.
 
        :param mapper: a mapped class, or the actual :class:`_orm.Mapper`
         object,
         representing the single kind of object represented within the mapping
         list.
 
        :param mappings: a sequence of dictionaries, each one containing the
         state of the mapped row to be updated, in terms of the attribute names
         on the mapped class.   If the mapping refers to multiple tables, such
         as a joined-inheritance mapping, each dictionary may contain keys
         corresponding to all tables.   All those keys which are present and
         are not part of the primary key are applied to the SET clause of the
         UPDATE statement; the primary key values, which are required, are
         applied to the WHERE clause.
 
 
        .. seealso::
 
            :doc:`queryguide/dml`
 
            :meth:`.Session.bulk_insert_mappings`
 
            :meth:`.Session.bulk_save_objects`
 
        TFNrM)rŽrˆrKrrrÚbulk_update_mappingss&ÿzSession.bulk_update_mappingsz<Union[Iterable[InstanceState[_O]], Iterable[Dict[str, Any]]])rˆrKrIÚisstatesr?r@rLr‹c     Cs’t|ƒ}d|_| ¡ ¡}zjz8|r6t |||||¡nt ||||||¡| ¡Wn,t     ¡|j
ddW5QRXYnXW5d|_XdS)NTFr7) r'r4rŸr0rZ _bulk_updateZ _bulk_insertr_r<rdre)    rŽrˆrKrIrPr?r@rLrZrrrrH«s2
 ûú 
 zSession._bulk_save_mappings)r‰Úinclude_collectionsr‹c    Cspt|ƒ}|jsdS|j}|jjD]J}|s4t|jdƒs t|jdƒsBq |jj||tj    d\}}}|sd|r dSq dS)a9
Return ``True`` if the given instance has locally
        modified attributes.
 
        This method retrieves the history for each instrumented
        attribute on the instance and performs a comparison of the current
        value to its previously committed value, if any.
 
        It is in effect a more expensive and accurate
        version of checking for the given instance in the
        :attr:`.Session.dirty` collection; a full test for
        each attribute's net "dirty" status is performed.
 
        E.g.::
 
            return session.is_modified(someobject)
 
        A few caveats to this method apply:
 
        * Instances present in the :attr:`.Session.dirty` collection may
          report ``False`` when tested with this method.  This is because
          the object may have received change events via attribute mutation,
          thus placing it in :attr:`.Session.dirty`, but ultimately the state
          is the same as that loaded from the database, resulting in no net
          change here.
        * Scalar attributes may not have recorded the previously set
          value when a new value was applied, if the attribute was not loaded,
          or was expired, at the time the new value was received - in these
          cases, the attribute is assumed to have a change, even if there is
          ultimately no net change against its database value. SQLAlchemy in
          most cases does not need the "old" value when a set event occurs, so
          it skips the expense of a SQL call if the old value isn't present,
          based on the assumption that an UPDATE of the scalar value is
          usually needed, and in those few cases where it isn't, is less
          expensive on average than issuing a defensive SELECT.
 
          The "old" value is fetched unconditionally upon set only if the
          attribute container has the ``active_history`` flag set to ``True``.
          This flag is set typically for primary key attributes and scalar
          object references that are not a simple many-to-one.  To set this
          flag for any arbitrary mapped column, use the ``active_history``
          argument with :func:`.column_property`.
 
        :param instance: mapped instance to be tested for pending changes.
        :param include_collections: Indicates if multivalued collections
         should be included in the operation.  Setting this to ``False`` is a
         way to detect only local-column based properties (i.e. scalar columns
         or many-to-one foreign keys) that would result in an UPDATE for this
         instance upon flush.
 
        FZget_collectionÚ get_historyr)TN)
r-rDrÐrårÚhasattrÚimplrRr.rz)    rŽr‰rQr Zdict_ÚattrÚaddedZ    unchangedr;rrrÚ is_modifiedÓs(5 ÿ
þ
ýÿ zSession.is_modifiedcCs|jdkp|jjS)a4True if this :class:`.Session` not in "partial rollback" state.
 
        .. versionchanged:: 1.4 The :class:`_orm.Session` no longer begins
           a new transaction immediately, so this attribute will be False
           when the :class:`_orm.Session` is first instantiated.
 
        "partial rollback" state typically indicates that the flush process
        of the :class:`_orm.Session` has failed, and that the
        :meth:`_orm.Session.rollback` method must be emitted in order to
        fully roll back the transaction.
 
        If this :class:`_orm.Session` is not in a transaction at all, the
        :class:`_orm.Session` will autobegin when it is first used, so in this
        case :attr:`_orm.Session.is_active` will return True.
 
        Otherwise, if this :class:`_orm.Session` is within a transaction,
        and that transaction has not been rolled back internally, the
        :attr:`_orm.Session.is_active` will also return True.
 
        .. seealso::
 
            :ref:`faq_session_rollback`
 
            :meth:`_orm.Session.in_transaction`
 
        N)rr'rÈrrrr'szSession.is_activecCs
|j ¡S)z«The set of all persistent states considered dirty.
 
        This method returns all states that were modified including
        those that were possibly deleted.
 
        )r>r8rÈrrrr8=szSession._dirty_statesrNcst‡fdd„ˆjDƒƒS)aZThe set of all persistent instances considered dirty.
 
        E.g.::
 
            some_mapped_object in session.dirty
 
        Instances are considered dirty when they were modified but not
        deleted.
 
        Note that this 'dirty' calculation is 'optimistic'; most
        attribute-setting or collection modification operations will
        mark an instance as 'dirty' and place it in this set, even if
        there is no net change to the attribute's value.  At flush
        time, the value of each attribute is compared to its
        previously saved value, and if there's no net change, no SQL
        operation will occur (this is a more expensive operation so
        it's only done at flush time).
 
        To check if an instance has actionable net changes to its
        attributes, use the :meth:`.Session.is_modified` method.
 
        csg|]}|ˆjkr| ¡‘qSr)rrÄròrÈrrr`s
þz!Session.dirty.<locals>.<listcomp>)rNr8rÈrrÈrr:Gs
 
þÿz Session.dirtycCst t|j ¡ƒ¡S)zDThe set of all instances marked as 'deleted' within this ``Session``)r<rNrÆrrcrÈrrrr;gszSession.deletedcCst t|j ¡ƒ¡S)zAThe set of all instances marked as 'new' within this ``Session``.)r<rNrÆrrcrÈrrrr<msz Session.new)N)F)F)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)NN)N)N)F)T)F)N)N)FTT)FF)T)br‘r’r“r”Z _is_asynciorrÇr‘r’r”r˜Ú
contextlibÚcontextmanagerršrSrUrržr<Zmemoized_propertyr†rŸrVrRrer_r\r.r,rÚ
EMPTY_DICTrÙr¬r«r³rWrur¶r·rrÝr¾r+rr.Z PASSIVE_OFFrÓZnon_memoized_propertyrÔZ langhelpersZtag_method_for_warningsrÕZ    SAWarningrÖrßrárârÜrçrír<rýrûrrârrr r    rÜrr&r$rãr.rBrr/r rr1r3rr5rrar5rJrNrOrHrWrr'r8r:r;r<rrrrrwPs
þò(             7&ý3ý ý÷" ý÷"ý÷ ýø  ýø ýøFýú ýúýúýú ýúýú& $þù 
    
   ø;üüy$ÿ-ÿ ÿT#
-ö0õ4û&\û2'ÿ(A      "{ûmû"S*$)ÿL    r“c
@sÌeZdZUdZded<ed#ddddœdddddd    d
œd d „ƒZed$ddddœd ddddd    dœdd „ƒZd%eddddœdddddd    d
œdd „Zddœdd„Zd    ddœdd„Z    d    ddœdd„Z
d dœd!d"„Z dS)&rya• A configurable :class:`.Session` factory.
 
    The :class:`.sessionmaker` factory generates new
    :class:`.Session` objects when called, creating them given
    the configurational arguments established here.
 
    e.g.::
 
        from sqlalchemy import create_engine
        from sqlalchemy.orm import sessionmaker
 
        # an Engine, which the Session will use for connection
        # resources
        engine = create_engine('postgresql+psycopg2://scott:tiger@localhost/')
 
        Session = sessionmaker(engine)
 
        with Session() as session:
            session.add(some_object)
            session.add(some_other_object)
            session.commit()
 
    Context manager use is optional; otherwise, the returned
    :class:`_orm.Session` object may be closed explicitly via the
    :meth:`_orm.Session.close` method.   Using a
    ``try:/finally:`` block is optional, however will ensure that the close
    takes place even if there are database errors::
 
        session = Session()
        try:
            session.add(some_object)
            session.add(some_other_object)
            session.commit()
        finally:
            session.close()
 
    :class:`.sessionmaker` acts as a factory for :class:`_orm.Session`
    objects in the same way as an :class:`_engine.Engine` acts as a factory
    for :class:`_engine.Connection` objects.  In this way it also includes
    a :meth:`_orm.sessionmaker.begin` method, that provides a context
    manager which both begins and commits a transaction, as well as closes
    out the :class:`_orm.Session` when complete, rolling back the transaction
    if any errors occur::
 
        Session = sessionmaker(engine)
 
        with Session.begin() as session:
            session.add(some_object)
            session.add(some_other_object)
        # commits transaction, closes session
 
    .. versionadded:: 1.4
 
    When calling upon :class:`_orm.sessionmaker` to construct a
    :class:`_orm.Session`, keyword arguments may also be passed to the
    method; these arguments will override that of the globally configured
    parameters.  Below we use a :class:`_orm.sessionmaker` bound to a certain
    :class:`_engine.Engine` to produce a :class:`_orm.Session` that is instead
    bound to a specific :class:`_engine.Connection` procured from that engine::
 
        Session = sessionmaker(engine)
 
        # bind an individual session to a connection
 
        with engine.connect() as connection:
            with Session(bind=connection) as session:
                # work with session
 
    The class also includes a method :meth:`_orm.sessionmaker.configure`, which
    can be used to specify additional keyword arguments to the factory, which
    will take effect for subsequent :class:`.Session` objects generated. This
    is usually used to associate one or more :class:`_engine.Engine` objects
    with an existing
    :class:`.sessionmaker` factory before it is first used::
 
        # application starts, sessionmaker does not have
        # an engine bound yet
        Session = sessionmaker()
 
        # ... later, when an engine URL is read from a configuration
        # file or other events allow the engine to be created
        engine = create_engine('sqlite:///foo.db')
        Session.configure(bind=engine)
 
        sess = Session()
        # work with session
 
    .. seealso::
 
        :ref:`session_getting` - introductory text on creating
        sessions using :class:`.sessionmaker`.
 
    zType[_S]r¥.)rrIr†r‰rêrŠr)r-r¥rrIr†rŠcKsdSrŒr©rŽr-r¥rrIr†rŠrrrrÇØs zsessionmaker.__init__z'sessionmaker[Session]'©rŽr-rrIr†rŠcKsdSrŒrr\rrrrÇås
NT)r¥rrIr†cKsD||d<||d<||d<|dk    r(||d<||_t|j|fiƒ|_dS)a<Construct a new :class:`.sessionmaker`.
 
        All arguments here except for ``class_`` correspond to arguments
        accepted by :class:`.Session` directly.  See the
        :meth:`.Session.__init__` docstring for more details on parameters.
 
        :param bind: a :class:`_engine.Engine` or other :class:`.Connectable`
         with
         which newly created :class:`.Session` objects will be associated.
        :param class\_: class to use in order to create new :class:`.Session`
         objects.  Defaults to :class:`.Session`.
        :param autoflush: The autoflush setting to use with newly created
         :class:`.Session` objects.
 
         .. seealso::
 
            :ref:`session_flushing` - additional background on autoflush
 
        :param expire_on_commit=True: the
         :paramref:`_orm.Session.expire_on_commit` setting to use
         with newly created :class:`.Session` objects.
 
        :param info: optional dictionary of information that will be available
         via :attr:`.Session.info`.  Note this dictionary is *updated*, not
         replaced, when the ``info`` parameter is specified to the specific
         :class:`.Session` construction operation.
 
        :param \**kw: all other keyword arguments are passed to the
         constructor of newly created :class:`.Session` objects.
 
        r-rrINr†)rŠrºr‘r¥r[rrrrÇñs)z%contextlib.AbstractContextManager[_S]rcCs|ƒ}| ¡S)amProduce a context manager that both provides a new
        :class:`_orm.Session` as well as a transaction that commits.
 
 
        e.g.::
 
            Session = sessionmaker(some_engine)
 
            with Session.begin() as session:
                session.add(some_object)
 
            # commits transaction, closes session
 
        .. versionadded:: 1.4
 
 
        )rš)rŽr™rrrrV$szsessionmaker.beginr“)Úlocal_kwr‹cKs\|j ¡D]D\}}|dkrBd|krB| ¡}| |d¡||d<q
| ||¡q
|jf|ŽS)apProduce a new :class:`.Session` object using the configuration
        established in this :class:`.sessionmaker`.
 
        In Python, the ``__call__`` method is invoked on an object when
        it is "called" in the same way as a function::
 
            Session = sessionmaker(some_engine)
            session = Session()  # invokes sessionmaker.__call__()
 
        r†)rŠr=ÚcopyrÑr©r¥)rŽr]r Úvrærrrr:s 
zsessionmaker.__call__rœ)Únew_kwr‹cKs|j |¡dS)z±(Re)configure the arguments for this sessionmaker.
 
        e.g.::
 
            Session = sessionmaker()
 
            Session.configure(bind=create_engine('sqlite://'))
        N)rŠrÑ)rŽr`rrrÚ    configureNs    zsessionmaker.configurer!cCs,d|jj|jjd dd„|j ¡Dƒ¡fS)Nz%s(class_=%r, %s)rÁcss|]\}}d||fVqdS)z%s=%rNr)rr r_rrrró]sz(sessionmaker.__repr__.<locals>.<genexpr>)Ú    __class__r‘r¥rÃrŠr=rÈrrrÚ__repr__Ys
ýzsessionmaker.__repr__).).)N) r‘r’r“r”rrrÇrwrVrrarcrrrrryws6
^þù þú þù3 rœrcCst ¡D] }| ¡qdS)aOClose all sessions in memory.
 
    This function consults a global registry of all :class:`.Session` objects
    and calls :meth:`.Session.close` on them, which resets them to a clean
    state.
 
    This function is not for general use but may be useful for test suites
    within the teardown scheme.
 
    .. versionadded:: 1.3
 
    N)rrcrW)rsrrrr{as r¨r©cCsNt |¡}t|ƒ}|r"| |g¡|j ¡|jr6|`|jr@|`|jrJ|`dS)aoAlter the state of the given instance so that it is :term:`transient`.
 
    .. note::
 
        :func:`.make_transient` is a special-case function for
        advanced use cases only.
 
    The given mapped instance is assumed to be in the :term:`persistent` or
    :term:`detached` state.   The function will remove its association with any
    :class:`.Session` as well as its :attr:`.InstanceState.identity`. The
    effect is that the object will behave as though it were newly constructed,
    except retaining any attribute / collection values that were loaded at the
    time of the call.   The :attr:`.InstanceState.deleted` flag is also reset
    if this object had been deleted as a result of using
    :meth:`.Session.delete`.
 
    .. warning::
 
        :func:`.make_transient` does **not** "unexpire" or otherwise eagerly
        load ORM-mapped attributes that are not currently loaded at the time
        the function is called.   This includes attributes which:
 
        * were expired via :meth:`.Session.expire`
 
        * were expired as the natural effect of committing a session
          transaction, e.g. :meth:`.Session.commit`
 
        * are normally :term:`lazy loaded` but are not currently loaded
 
        * are "deferred" (see :ref:`orm_queryguide_column_deferral`) and are
          not yet loaded
 
        * were not present in the query which loaded this object, such as that
          which is common in joined table inheritance and other scenarios.
 
        After :func:`.make_transient` is called, unloaded attributes such
        as those above will normally resolve to the value ``None`` when
        accessed, or an empty collection for a collection-oriented attribute.
        As the object is transient and un-associated with any database
        identity, it will no longer retrieve these values.
 
    .. seealso::
 
        :func:`.make_transient_to_detached`
 
    N)    rrÙršr<Zexpired_attributesrLZ    callablesr@r)r‰r rGrrrr|ss/
 
cCsXt |¡}|js|jr t d¡‚|j |¡|_|jr8|`|     |j
¡|  |j
|j ¡dS)a­Make the given transient instance :term:`detached`.
 
    .. note::
 
        :func:`.make_transient_to_detached` is a special-case function for
        advanced use cases only.
 
    All attribute history on the given instance
    will be reset as though the instance were freshly loaded
    from a query.  Missing attributes will be marked as expired.
    The primary key attributes of the object, which are required, will be made
    into the "key" of the instance.
 
    The object can then be added to a session, or merged
    possibly with the load=False flag, at which point it will look
    as if it were loaded that way, without emitting SQL.
 
    This is a special use case function that differs from a normal
    call to :meth:`.Session.merge` in that a given persistent state
    can be manufactured without any SQL calls.
 
    .. seealso::
 
        :func:`.make_transient`
 
        :meth:`.Session.enable_relationship_loading`
 
    zGiven object must be transientN) rrÙrîr@rÕrÖrˆrõrr+rÐräZunloaded_expirable)r‰r rrrr}´s
 
 c
CsLzt |¡}Wn0tjk
r>}zt |¡|‚W5d}~XYn
Xt|ƒSdS)z¾Return the :class:`.Session` to which the given instance belongs.
 
    This is essentially the same as the :attr:`.InstanceState.session`
    accessor.  See that attribute for details.
 
    N)rrÙrrÚrÛrš)r‰r r»rrrr~Ûs
)²r”Ú
__future__rrXÚenumrrÓroÚtypingrrrrrr    r
r r r rrrrrrrrr6Úrrrrrrrrr rJÚ_typingr!r"r#r$r&Úbaser'r(r)r*r+r,r-r.r/r0r1r2r3r4Z state_changesr5r6r7Z
unitofworkr8r:rÕr;r<r=r>Z engine.utilr?Úeventr@rAZ
inspectionrBrCrDrErFrGrHrIZsql.baserJZ
sql.schemarKZsql.selectablerLrMrNZ util.typingrOrPrQrRrSrTZ
interfacesrUrVrˆrWZ path_registryrXrYrZr[r\Z engine.baser]r^Zengine.interfacesr_r`raZ engine.resultrbrcZ sql._typingrdrerfrgrhrirjrkrlrmrnZ_TCCArorpZ sql.elementsrqZ    sql.rolesrrrsrtruÚ__all__ÚWeakValueDictionaryrrrr!r¿Z_EntityBindKeyr¸rNrr†ršr›r¬Útupler°r±r²r³r´Z MemoizedSlotsrzr    rxrwr“ryr{r|r}r~ÚcounterrŽrrrrÚ<module>sz                                                                                                                 ø þ
 ÿ2    wD> kA'