piccolo 1.4.2__py3-none-any.whl → 1.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- piccolo/__init__.py +1 -1
- piccolo/apps/asgi/commands/new.py +1 -0
- piccolo/apps/asgi/commands/templates/app/_lilya_app.py.jinja +45 -0
- piccolo/apps/asgi/commands/templates/app/app.py.jinja +2 -0
- piccolo/apps/asgi/commands/templates/app/home/_lilya_endpoints.py.jinja +21 -0
- piccolo/apps/asgi/commands/templates/app/home/endpoints.py.jinja +2 -0
- piccolo/apps/asgi/commands/templates/app/home/templates/home.html.jinja_raw +5 -0
- piccolo/apps/migrations/auto/migration_manager.py +9 -9
- piccolo/apps/migrations/auto/serialisation.py +2 -4
- piccolo/apps/migrations/commands/backwards.py +9 -7
- piccolo/apps/migrations/commands/base.py +3 -3
- piccolo/apps/migrations/commands/forwards.py +3 -3
- piccolo/apps/playground/commands/run.py +1 -0
- piccolo/apps/user/tables.py +1 -0
- piccolo/columns/base.py +5 -3
- piccolo/columns/column_types.py +97 -116
- piccolo/columns/reference.py +1 -0
- piccolo/conf/apps.py +1 -2
- piccolo/query/methods/objects.py +8 -8
- piccolo/query/methods/select.py +4 -8
- piccolo/query/mixins.py +3 -3
- piccolo/query/proxy.py +3 -2
- piccolo/table.py +19 -13
- piccolo/utils/pydantic.py +6 -0
- {piccolo-1.4.2.dist-info → piccolo-1.5.1.dist-info}/METADATA +2 -2
- {piccolo-1.4.2.dist-info → piccolo-1.5.1.dist-info}/RECORD +35 -33
- tests/columns/test_array.py +22 -0
- tests/columns/test_reference.py +1 -0
- tests/conf/example.py +1 -0
- tests/table/test_metaclass.py +12 -0
- tests/utils/test_pydantic.py +28 -0
- {piccolo-1.4.2.dist-info → piccolo-1.5.1.dist-info}/LICENSE +0 -0
- {piccolo-1.4.2.dist-info → piccolo-1.5.1.dist-info}/WHEEL +0 -0
- {piccolo-1.4.2.dist-info → piccolo-1.5.1.dist-info}/entry_points.txt +0 -0
- {piccolo-1.4.2.dist-info → piccolo-1.5.1.dist-info}/top_level.txt +0 -0
piccolo/columns/column_types.py
CHANGED
@@ -350,12 +350,10 @@ class Varchar(Column):
|
|
350
350
|
# Descriptors
|
351
351
|
|
352
352
|
@t.overload
|
353
|
-
def __get__(self, obj: Table, objtype=None) -> str:
|
354
|
-
...
|
353
|
+
def __get__(self, obj: Table, objtype=None) -> str: ...
|
355
354
|
|
356
355
|
@t.overload
|
357
|
-
def __get__(self, obj: None, objtype=None) -> Varchar:
|
358
|
-
...
|
356
|
+
def __get__(self, obj: None, objtype=None) -> Varchar: ...
|
359
357
|
|
360
358
|
def __get__(self, obj, objtype=None):
|
361
359
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -389,12 +387,10 @@ class Secret(Varchar):
|
|
389
387
|
# Descriptors
|
390
388
|
|
391
389
|
@t.overload
|
392
|
-
def __get__(self, obj: Table, objtype=None) -> str:
|
393
|
-
...
|
390
|
+
def __get__(self, obj: Table, objtype=None) -> str: ...
|
394
391
|
|
395
392
|
@t.overload
|
396
|
-
def __get__(self, obj: None, objtype=None) -> Secret:
|
397
|
-
...
|
393
|
+
def __get__(self, obj: None, objtype=None) -> Secret: ...
|
398
394
|
|
399
395
|
def __get__(self, obj, objtype=None):
|
400
396
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -456,12 +452,10 @@ class Text(Column):
|
|
456
452
|
# Descriptors
|
457
453
|
|
458
454
|
@t.overload
|
459
|
-
def __get__(self, obj: Table, objtype=None) -> str:
|
460
|
-
...
|
455
|
+
def __get__(self, obj: Table, objtype=None) -> str: ...
|
461
456
|
|
462
457
|
@t.overload
|
463
|
-
def __get__(self, obj: None, objtype=None) -> Text:
|
464
|
-
...
|
458
|
+
def __get__(self, obj: None, objtype=None) -> Text: ...
|
465
459
|
|
466
460
|
def __get__(self, obj, objtype=None):
|
467
461
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -521,12 +515,10 @@ class UUID(Column):
|
|
521
515
|
# Descriptors
|
522
516
|
|
523
517
|
@t.overload
|
524
|
-
def __get__(self, obj: Table, objtype=None) -> uuid.UUID:
|
525
|
-
...
|
518
|
+
def __get__(self, obj: Table, objtype=None) -> uuid.UUID: ...
|
526
519
|
|
527
520
|
@t.overload
|
528
|
-
def __get__(self, obj: None, objtype=None) -> UUID:
|
529
|
-
...
|
521
|
+
def __get__(self, obj: None, objtype=None) -> UUID: ...
|
530
522
|
|
531
523
|
def __get__(self, obj, objtype=None):
|
532
524
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -641,12 +633,10 @@ class Integer(Column):
|
|
641
633
|
# Descriptors
|
642
634
|
|
643
635
|
@t.overload
|
644
|
-
def __get__(self, obj: Table, objtype=None) -> int:
|
645
|
-
...
|
636
|
+
def __get__(self, obj: Table, objtype=None) -> int: ...
|
646
637
|
|
647
638
|
@t.overload
|
648
|
-
def __get__(self, obj: None, objtype=None) -> Integer:
|
649
|
-
...
|
639
|
+
def __get__(self, obj: None, objtype=None) -> Integer: ...
|
650
640
|
|
651
641
|
def __get__(self, obj, objtype=None):
|
652
642
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -699,12 +689,10 @@ class BigInt(Integer):
|
|
699
689
|
# Descriptors
|
700
690
|
|
701
691
|
@t.overload
|
702
|
-
def __get__(self, obj: Table, objtype=None) -> int:
|
703
|
-
...
|
692
|
+
def __get__(self, obj: Table, objtype=None) -> int: ...
|
704
693
|
|
705
694
|
@t.overload
|
706
|
-
def __get__(self, obj: None, objtype=None) -> BigInt:
|
707
|
-
...
|
695
|
+
def __get__(self, obj: None, objtype=None) -> BigInt: ...
|
708
696
|
|
709
697
|
def __get__(self, obj, objtype=None):
|
710
698
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -749,12 +737,10 @@ class SmallInt(Integer):
|
|
749
737
|
# Descriptors
|
750
738
|
|
751
739
|
@t.overload
|
752
|
-
def __get__(self, obj: Table, objtype=None) -> int:
|
753
|
-
...
|
740
|
+
def __get__(self, obj: Table, objtype=None) -> int: ...
|
754
741
|
|
755
742
|
@t.overload
|
756
|
-
def __get__(self, obj: None, objtype=None) -> SmallInt:
|
757
|
-
...
|
743
|
+
def __get__(self, obj: None, objtype=None) -> SmallInt: ...
|
758
744
|
|
759
745
|
def __get__(self, obj, objtype=None):
|
760
746
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -801,12 +787,10 @@ class Serial(Column):
|
|
801
787
|
# Descriptors
|
802
788
|
|
803
789
|
@t.overload
|
804
|
-
def __get__(self, obj: Table, objtype=None) -> int:
|
805
|
-
...
|
790
|
+
def __get__(self, obj: Table, objtype=None) -> int: ...
|
806
791
|
|
807
792
|
@t.overload
|
808
|
-
def __get__(self, obj: None, objtype=None) -> Serial:
|
809
|
-
...
|
793
|
+
def __get__(self, obj: None, objtype=None) -> Serial: ...
|
810
794
|
|
811
795
|
def __get__(self, obj, objtype=None):
|
812
796
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -835,12 +819,10 @@ class BigSerial(Serial):
|
|
835
819
|
# Descriptors
|
836
820
|
|
837
821
|
@t.overload
|
838
|
-
def __get__(self, obj: Table, objtype=None) -> int:
|
839
|
-
...
|
822
|
+
def __get__(self, obj: Table, objtype=None) -> int: ...
|
840
823
|
|
841
824
|
@t.overload
|
842
|
-
def __get__(self, obj: None, objtype=None) -> BigSerial:
|
843
|
-
...
|
825
|
+
def __get__(self, obj: None, objtype=None) -> BigSerial: ...
|
844
826
|
|
845
827
|
def __get__(self, obj, objtype=None):
|
846
828
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -870,12 +852,10 @@ class PrimaryKey(Serial):
|
|
870
852
|
# Descriptors
|
871
853
|
|
872
854
|
@t.overload
|
873
|
-
def __get__(self, obj: Table, objtype=None) -> int:
|
874
|
-
...
|
855
|
+
def __get__(self, obj: Table, objtype=None) -> int: ...
|
875
856
|
|
876
857
|
@t.overload
|
877
|
-
def __get__(self, obj: None, objtype=None) -> PrimaryKey:
|
878
|
-
...
|
858
|
+
def __get__(self, obj: None, objtype=None) -> PrimaryKey: ...
|
879
859
|
|
880
860
|
def __get__(self, obj, objtype=None):
|
881
861
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -960,12 +940,10 @@ class Timestamp(Column):
|
|
960
940
|
# Descriptors
|
961
941
|
|
962
942
|
@t.overload
|
963
|
-
def __get__(self, obj: Table, objtype=None) -> datetime:
|
964
|
-
...
|
943
|
+
def __get__(self, obj: Table, objtype=None) -> datetime: ...
|
965
944
|
|
966
945
|
@t.overload
|
967
|
-
def __get__(self, obj: None, objtype=None) -> Timestamp:
|
968
|
-
...
|
946
|
+
def __get__(self, obj: None, objtype=None) -> Timestamp: ...
|
969
947
|
|
970
948
|
def __get__(self, obj, objtype=None):
|
971
949
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1057,12 +1035,10 @@ class Timestamptz(Column):
|
|
1057
1035
|
# Descriptors
|
1058
1036
|
|
1059
1037
|
@t.overload
|
1060
|
-
def __get__(self, obj: Table, objtype=None) -> datetime:
|
1061
|
-
...
|
1038
|
+
def __get__(self, obj: Table, objtype=None) -> datetime: ...
|
1062
1039
|
|
1063
1040
|
@t.overload
|
1064
|
-
def __get__(self, obj: None, objtype=None) -> Timestamptz:
|
1065
|
-
...
|
1041
|
+
def __get__(self, obj: None, objtype=None) -> Timestamptz: ...
|
1066
1042
|
|
1067
1043
|
def __get__(self, obj, objtype=None):
|
1068
1044
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1137,12 +1113,10 @@ class Date(Column):
|
|
1137
1113
|
# Descriptors
|
1138
1114
|
|
1139
1115
|
@t.overload
|
1140
|
-
def __get__(self, obj: Table, objtype=None) -> date:
|
1141
|
-
...
|
1116
|
+
def __get__(self, obj: Table, objtype=None) -> date: ...
|
1142
1117
|
|
1143
1118
|
@t.overload
|
1144
|
-
def __get__(self, obj: None, objtype=None) -> Date:
|
1145
|
-
...
|
1119
|
+
def __get__(self, obj: None, objtype=None) -> Date: ...
|
1146
1120
|
|
1147
1121
|
def __get__(self, obj, objtype=None):
|
1148
1122
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1214,12 +1188,10 @@ class Time(Column):
|
|
1214
1188
|
# Descriptors
|
1215
1189
|
|
1216
1190
|
@t.overload
|
1217
|
-
def __get__(self, obj: Table, objtype=None) -> time:
|
1218
|
-
...
|
1191
|
+
def __get__(self, obj: Table, objtype=None) -> time: ...
|
1219
1192
|
|
1220
1193
|
@t.overload
|
1221
|
-
def __get__(self, obj: None, objtype=None) -> Time:
|
1222
|
-
...
|
1194
|
+
def __get__(self, obj: None, objtype=None) -> Time: ...
|
1223
1195
|
|
1224
1196
|
def __get__(self, obj, objtype=None):
|
1225
1197
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1305,12 +1277,10 @@ class Interval(Column):
|
|
1305
1277
|
# Descriptors
|
1306
1278
|
|
1307
1279
|
@t.overload
|
1308
|
-
def __get__(self, obj: Table, objtype=None) -> timedelta:
|
1309
|
-
...
|
1280
|
+
def __get__(self, obj: Table, objtype=None) -> timedelta: ...
|
1310
1281
|
|
1311
1282
|
@t.overload
|
1312
|
-
def __get__(self, obj: None, objtype=None) -> Interval:
|
1313
|
-
...
|
1283
|
+
def __get__(self, obj: None, objtype=None) -> Interval: ...
|
1314
1284
|
|
1315
1285
|
def __get__(self, obj, objtype=None):
|
1316
1286
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1399,12 +1369,10 @@ class Boolean(Column):
|
|
1399
1369
|
# Descriptors
|
1400
1370
|
|
1401
1371
|
@t.overload
|
1402
|
-
def __get__(self, obj: Table, objtype=None) -> bool:
|
1403
|
-
...
|
1372
|
+
def __get__(self, obj: Table, objtype=None) -> bool: ...
|
1404
1373
|
|
1405
1374
|
@t.overload
|
1406
|
-
def __get__(self, obj: None, objtype=None) -> Boolean:
|
1407
|
-
...
|
1375
|
+
def __get__(self, obj: None, objtype=None) -> Boolean: ...
|
1408
1376
|
|
1409
1377
|
def __get__(self, obj, objtype=None):
|
1410
1378
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1502,12 +1470,10 @@ class Numeric(Column):
|
|
1502
1470
|
# Descriptors
|
1503
1471
|
|
1504
1472
|
@t.overload
|
1505
|
-
def __get__(self, obj: Table, objtype=None) -> decimal.Decimal:
|
1506
|
-
...
|
1473
|
+
def __get__(self, obj: Table, objtype=None) -> decimal.Decimal: ...
|
1507
1474
|
|
1508
1475
|
@t.overload
|
1509
|
-
def __get__(self, obj: None, objtype=None) -> Numeric:
|
1510
|
-
...
|
1476
|
+
def __get__(self, obj: None, objtype=None) -> Numeric: ...
|
1511
1477
|
|
1512
1478
|
def __get__(self, obj, objtype=None):
|
1513
1479
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1525,12 +1491,10 @@ class Decimal(Numeric):
|
|
1525
1491
|
# Descriptors
|
1526
1492
|
|
1527
1493
|
@t.overload
|
1528
|
-
def __get__(self, obj: Table, objtype=None) -> decimal.Decimal:
|
1529
|
-
...
|
1494
|
+
def __get__(self, obj: Table, objtype=None) -> decimal.Decimal: ...
|
1530
1495
|
|
1531
1496
|
@t.overload
|
1532
|
-
def __get__(self, obj: None, objtype=None) -> Decimal:
|
1533
|
-
...
|
1497
|
+
def __get__(self, obj: None, objtype=None) -> Decimal: ...
|
1534
1498
|
|
1535
1499
|
def __get__(self, obj, objtype=None):
|
1536
1500
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1576,12 +1540,10 @@ class Real(Column):
|
|
1576
1540
|
# Descriptors
|
1577
1541
|
|
1578
1542
|
@t.overload
|
1579
|
-
def __get__(self, obj: Table, objtype=None) -> float:
|
1580
|
-
...
|
1543
|
+
def __get__(self, obj: Table, objtype=None) -> float: ...
|
1581
1544
|
|
1582
1545
|
@t.overload
|
1583
|
-
def __get__(self, obj: None, objtype=None) -> Real:
|
1584
|
-
...
|
1546
|
+
def __get__(self, obj: None, objtype=None) -> Real: ...
|
1585
1547
|
|
1586
1548
|
def __get__(self, obj, objtype=None):
|
1587
1549
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1599,12 +1561,10 @@ class Float(Real):
|
|
1599
1561
|
# Descriptors
|
1600
1562
|
|
1601
1563
|
@t.overload
|
1602
|
-
def __get__(self, obj: Table, objtype=None) -> float:
|
1603
|
-
...
|
1564
|
+
def __get__(self, obj: Table, objtype=None) -> float: ...
|
1604
1565
|
|
1605
1566
|
@t.overload
|
1606
|
-
def __get__(self, obj: None, objtype=None) -> Float:
|
1607
|
-
...
|
1567
|
+
def __get__(self, obj: None, objtype=None) -> Float: ...
|
1608
1568
|
|
1609
1569
|
def __get__(self, obj, objtype=None):
|
1610
1570
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1626,12 +1586,10 @@ class DoublePrecision(Real):
|
|
1626
1586
|
# Descriptors
|
1627
1587
|
|
1628
1588
|
@t.overload
|
1629
|
-
def __get__(self, obj: Table, objtype=None) -> float:
|
1630
|
-
...
|
1589
|
+
def __get__(self, obj: Table, objtype=None) -> float: ...
|
1631
1590
|
|
1632
1591
|
@t.overload
|
1633
|
-
def __get__(self, obj: None, objtype=None) -> DoublePrecision:
|
1634
|
-
...
|
1592
|
+
def __get__(self, obj: None, objtype=None) -> DoublePrecision: ...
|
1635
1593
|
|
1636
1594
|
def __get__(self, obj, objtype=None):
|
1637
1595
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -1871,8 +1829,7 @@ class ForeignKey(Column, t.Generic[ReferencedTable]):
|
|
1871
1829
|
on_update: OnUpdate = OnUpdate.cascade,
|
1872
1830
|
target_column: t.Union[str, Column, None] = None,
|
1873
1831
|
**kwargs,
|
1874
|
-
) -> None:
|
1875
|
-
...
|
1832
|
+
) -> None: ...
|
1876
1833
|
|
1877
1834
|
@t.overload
|
1878
1835
|
def __init__(
|
@@ -1884,8 +1841,7 @@ class ForeignKey(Column, t.Generic[ReferencedTable]):
|
|
1884
1841
|
on_update: OnUpdate = OnUpdate.cascade,
|
1885
1842
|
target_column: t.Union[str, Column, None] = None,
|
1886
1843
|
**kwargs,
|
1887
|
-
) -> None:
|
1888
|
-
...
|
1844
|
+
) -> None: ...
|
1889
1845
|
|
1890
1846
|
@t.overload
|
1891
1847
|
def __init__(
|
@@ -1897,8 +1853,7 @@ class ForeignKey(Column, t.Generic[ReferencedTable]):
|
|
1897
1853
|
on_update: OnUpdate = OnUpdate.cascade,
|
1898
1854
|
target_column: t.Union[str, Column, None] = None,
|
1899
1855
|
**kwargs,
|
1900
|
-
) -> None:
|
1901
|
-
...
|
1856
|
+
) -> None: ...
|
1902
1857
|
|
1903
1858
|
def __init__(
|
1904
1859
|
self,
|
@@ -2248,16 +2203,15 @@ class ForeignKey(Column, t.Generic[ReferencedTable]):
|
|
2248
2203
|
# Descriptors
|
2249
2204
|
|
2250
2205
|
@t.overload
|
2251
|
-
def __get__(self, obj: Table, objtype=None) -> t.Any:
|
2252
|
-
...
|
2206
|
+
def __get__(self, obj: Table, objtype=None) -> t.Any: ...
|
2253
2207
|
|
2254
2208
|
@t.overload
|
2255
|
-
def __get__(
|
2256
|
-
|
2209
|
+
def __get__(
|
2210
|
+
self, obj: None, objtype=None
|
2211
|
+
) -> ForeignKey[ReferencedTable]: ...
|
2257
2212
|
|
2258
2213
|
@t.overload
|
2259
|
-
def __get__(self, obj: t.Any, objtype=None) -> t.Any:
|
2260
|
-
...
|
2214
|
+
def __get__(self, obj: t.Any, objtype=None) -> t.Any: ...
|
2261
2215
|
|
2262
2216
|
def __get__(self, obj, objtype=None):
|
2263
2217
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -2317,12 +2271,10 @@ class JSON(Column):
|
|
2317
2271
|
# Descriptors
|
2318
2272
|
|
2319
2273
|
@t.overload
|
2320
|
-
def __get__(self, obj: Table, objtype=None) -> str:
|
2321
|
-
...
|
2274
|
+
def __get__(self, obj: Table, objtype=None) -> str: ...
|
2322
2275
|
|
2323
2276
|
@t.overload
|
2324
|
-
def __get__(self, obj: None, objtype=None) -> JSON:
|
2325
|
-
...
|
2277
|
+
def __get__(self, obj: None, objtype=None) -> JSON: ...
|
2326
2278
|
|
2327
2279
|
def __get__(self, obj, objtype=None):
|
2328
2280
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -2387,12 +2339,10 @@ class JSONB(JSON):
|
|
2387
2339
|
# Descriptors
|
2388
2340
|
|
2389
2341
|
@t.overload
|
2390
|
-
def __get__(self, obj: Table, objtype=None) -> str:
|
2391
|
-
...
|
2342
|
+
def __get__(self, obj: Table, objtype=None) -> str: ...
|
2392
2343
|
|
2393
2344
|
@t.overload
|
2394
|
-
def __get__(self, obj: None, objtype=None) -> JSONB:
|
2395
|
-
...
|
2345
|
+
def __get__(self, obj: None, objtype=None) -> JSONB: ...
|
2396
2346
|
|
2397
2347
|
def __get__(self, obj, objtype=None):
|
2398
2348
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -2460,12 +2410,10 @@ class Bytea(Column):
|
|
2460
2410
|
# Descriptors
|
2461
2411
|
|
2462
2412
|
@t.overload
|
2463
|
-
def __get__(self, obj: Table, objtype=None) -> bytes:
|
2464
|
-
...
|
2413
|
+
def __get__(self, obj: Table, objtype=None) -> bytes: ...
|
2465
2414
|
|
2466
2415
|
@t.overload
|
2467
|
-
def __get__(self, obj: None, objtype=None) -> Bytea:
|
2468
|
-
...
|
2416
|
+
def __get__(self, obj: None, objtype=None) -> Bytea: ...
|
2469
2417
|
|
2470
2418
|
def __get__(self, obj, objtype=None):
|
2471
2419
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -2483,12 +2431,10 @@ class Blob(Bytea):
|
|
2483
2431
|
# Descriptors
|
2484
2432
|
|
2485
2433
|
@t.overload
|
2486
|
-
def __get__(self, obj: Table, objtype=None) -> bytes:
|
2487
|
-
...
|
2434
|
+
def __get__(self, obj: Table, objtype=None) -> bytes: ...
|
2488
2435
|
|
2489
2436
|
@t.overload
|
2490
|
-
def __get__(self, obj: None, objtype=None) -> Blob:
|
2491
|
-
...
|
2437
|
+
def __get__(self, obj: None, objtype=None) -> Blob: ...
|
2492
2438
|
|
2493
2439
|
def __get__(self, obj, objtype=None):
|
2494
2440
|
return obj.__dict__[self._meta.name] if obj else self
|
@@ -2597,6 +2543,43 @@ class Array(Column):
|
|
2597
2543
|
if isinstance(self.base_column, Array):
|
2598
2544
|
self.base_column._setup_base_column(table_class=table_class)
|
2599
2545
|
|
2546
|
+
def _get_dimensions(self, start: int = 0) -> int:
|
2547
|
+
"""
|
2548
|
+
A helper function to get the number of dimensions for the array. For
|
2549
|
+
example::
|
2550
|
+
|
2551
|
+
>>> Array(Varchar())._get_dimensions()
|
2552
|
+
1
|
2553
|
+
|
2554
|
+
>>> Array(Array(Varchar()))._get_dimensions()
|
2555
|
+
2
|
2556
|
+
|
2557
|
+
:param start:
|
2558
|
+
Ignore this - it's just used for calling this method recursively.
|
2559
|
+
|
2560
|
+
"""
|
2561
|
+
if isinstance(self.base_column, Array):
|
2562
|
+
return self.base_column._get_dimensions(start=start + 1)
|
2563
|
+
else:
|
2564
|
+
return start + 1
|
2565
|
+
|
2566
|
+
def _get_inner_value_type(self) -> t.Type:
|
2567
|
+
"""
|
2568
|
+
A helper function to get the innermost value type for the array. For
|
2569
|
+
example::
|
2570
|
+
|
2571
|
+
>>> Array(Varchar())._get_inner_value_type()
|
2572
|
+
str
|
2573
|
+
|
2574
|
+
>>> Array(Array(Varchar()))._get_inner_value_type()
|
2575
|
+
str
|
2576
|
+
|
2577
|
+
"""
|
2578
|
+
if isinstance(self.base_column, Array):
|
2579
|
+
return self.base_column._get_inner_value_type()
|
2580
|
+
else:
|
2581
|
+
return self.base_column.value_type
|
2582
|
+
|
2600
2583
|
def __getitem__(self, value: int) -> Array:
|
2601
2584
|
"""
|
2602
2585
|
Allows queries which retrieve an item from the array. The index starts
|
@@ -2719,12 +2702,10 @@ class Array(Column):
|
|
2719
2702
|
# Descriptors
|
2720
2703
|
|
2721
2704
|
@t.overload
|
2722
|
-
def __get__(self, obj: Table, objtype=None) -> t.List[t.Any]:
|
2723
|
-
...
|
2705
|
+
def __get__(self, obj: Table, objtype=None) -> t.List[t.Any]: ...
|
2724
2706
|
|
2725
2707
|
@t.overload
|
2726
|
-
def __get__(self, obj: None, objtype=None) -> Array:
|
2727
|
-
...
|
2708
|
+
def __get__(self, obj: None, objtype=None) -> Array: ...
|
2728
2709
|
|
2729
2710
|
def __get__(self, obj, objtype=None):
|
2730
2711
|
return obj.__dict__[self._meta.name] if obj else self
|
piccolo/columns/reference.py
CHANGED
piccolo/conf/apps.py
CHANGED
piccolo/query/methods/objects.py
CHANGED
@@ -124,10 +124,10 @@ class First(
|
|
124
124
|
|
125
125
|
results = objects[0] if objects else None
|
126
126
|
|
127
|
-
modified_response: t.Optional[
|
128
|
-
|
129
|
-
|
130
|
-
|
127
|
+
modified_response: t.Optional[TableInstance] = (
|
128
|
+
await self.query.callback_delegate.invoke(
|
129
|
+
results=results, kind=CallbackType.success
|
130
|
+
)
|
131
131
|
)
|
132
132
|
return modified_response
|
133
133
|
|
@@ -355,10 +355,10 @@ class Objects(
|
|
355
355
|
# With callbacks, the user can return any data that they want.
|
356
356
|
# Assume that most of the time they will still return a list of
|
357
357
|
# Table instances.
|
358
|
-
modified: t.List[
|
359
|
-
|
360
|
-
|
361
|
-
|
358
|
+
modified: t.List[TableInstance] = (
|
359
|
+
await self.callback_delegate.invoke(
|
360
|
+
results, kind=CallbackType.success
|
361
|
+
)
|
362
362
|
)
|
363
363
|
return modified
|
364
364
|
else:
|
piccolo/query/methods/select.py
CHANGED
@@ -604,20 +604,16 @@ class Select(Query[TableInstance, t.List[t.Dict[str, t.Any]]]):
|
|
604
604
|
return self
|
605
605
|
|
606
606
|
@t.overload
|
607
|
-
def output(self: Self, *, as_list: bool) -> SelectList:
|
608
|
-
...
|
607
|
+
def output(self: Self, *, as_list: bool) -> SelectList: ...
|
609
608
|
|
610
609
|
@t.overload
|
611
|
-
def output(self: Self, *, as_json: bool) -> SelectJSON:
|
612
|
-
...
|
610
|
+
def output(self: Self, *, as_json: bool) -> SelectJSON: ...
|
613
611
|
|
614
612
|
@t.overload
|
615
|
-
def output(self: Self, *, load_json: bool) -> Self:
|
616
|
-
...
|
613
|
+
def output(self: Self, *, load_json: bool) -> Self: ...
|
617
614
|
|
618
615
|
@t.overload
|
619
|
-
def output(self: Self, *, nested: bool) -> Self:
|
620
|
-
...
|
616
|
+
def output(self: Self, *, nested: bool) -> Self: ...
|
621
617
|
|
622
618
|
def output(
|
623
619
|
self: Self,
|
piccolo/query/mixins.py
CHANGED
@@ -639,9 +639,9 @@ class OnConflictAction(str, Enum):
|
|
639
639
|
class OnConflictItem:
|
640
640
|
target: t.Optional[t.Union[str, Column, t.Tuple[Column, ...]]] = None
|
641
641
|
action: t.Optional[OnConflictAction] = None
|
642
|
-
values: t.Optional[
|
643
|
-
|
644
|
-
|
642
|
+
values: t.Optional[t.Sequence[t.Union[Column, t.Tuple[Column, t.Any]]]] = (
|
643
|
+
None
|
644
|
+
)
|
645
645
|
where: t.Optional[Combinable] = None
|
646
646
|
|
647
647
|
@property
|
piccolo/query/proxy.py
CHANGED
@@ -8,8 +8,9 @@ from piccolo.utils.sync import run_sync
|
|
8
8
|
|
9
9
|
|
10
10
|
class Runnable(Protocol):
|
11
|
-
async def run(
|
12
|
-
|
11
|
+
async def run(
|
12
|
+
self, node: t.Optional[str] = None, in_pool: bool = True
|
13
|
+
): ...
|
13
14
|
|
14
15
|
|
15
16
|
QueryType = t.TypeVar("QueryType", bound=Runnable)
|
piccolo/table.py
CHANGED
@@ -78,6 +78,7 @@ class TableMeta:
|
|
78
78
|
columns: t.List[Column] = field(default_factory=list)
|
79
79
|
default_columns: t.List[Column] = field(default_factory=list)
|
80
80
|
non_default_columns: t.List[Column] = field(default_factory=list)
|
81
|
+
array_columns: t.List[Array] = field(default_factory=list)
|
81
82
|
email_columns: t.List[Email] = field(default_factory=list)
|
82
83
|
foreign_key_columns: t.List[ForeignKey] = field(default_factory=list)
|
83
84
|
primary_key: Column = field(default_factory=Column)
|
@@ -267,6 +268,7 @@ class Table(metaclass=TableMetaclass):
|
|
267
268
|
columns: t.List[Column] = []
|
268
269
|
default_columns: t.List[Column] = []
|
269
270
|
non_default_columns: t.List[Column] = []
|
271
|
+
array_columns: t.List[Array] = []
|
270
272
|
foreign_key_columns: t.List[ForeignKey] = []
|
271
273
|
secret_columns: t.List[Secret] = []
|
272
274
|
json_columns: t.List[t.Union[JSON, JSONB]] = []
|
@@ -304,6 +306,7 @@ class Table(metaclass=TableMetaclass):
|
|
304
306
|
|
305
307
|
if isinstance(column, Array):
|
306
308
|
column._setup_base_column(table_class=cls)
|
309
|
+
array_columns.append(column)
|
307
310
|
|
308
311
|
if isinstance(column, Email):
|
309
312
|
email_columns.append(column)
|
@@ -337,6 +340,7 @@ class Table(metaclass=TableMetaclass):
|
|
337
340
|
columns=columns,
|
338
341
|
default_columns=default_columns,
|
339
342
|
non_default_columns=non_default_columns,
|
343
|
+
array_columns=array_columns,
|
340
344
|
email_columns=email_columns,
|
341
345
|
primary_key=primary_key,
|
342
346
|
foreign_key_columns=foreign_key_columns,
|
@@ -562,12 +566,10 @@ class Table(metaclass=TableMetaclass):
|
|
562
566
|
@t.overload
|
563
567
|
def get_related(
|
564
568
|
self, foreign_key: ForeignKey[ReferencedTable]
|
565
|
-
) -> First[ReferencedTable]:
|
566
|
-
...
|
569
|
+
) -> First[ReferencedTable]: ...
|
567
570
|
|
568
571
|
@t.overload
|
569
|
-
def get_related(self, foreign_key: str) -> First[Table]:
|
570
|
-
...
|
572
|
+
def get_related(self, foreign_key: str) -> First[Table]: ...
|
571
573
|
|
572
574
|
def get_related(
|
573
575
|
self, foreign_key: t.Union[str, ForeignKey[ReferencedTable]]
|
@@ -741,9 +743,9 @@ class Table(metaclass=TableMetaclass):
|
|
741
743
|
if isinstance(value, Table):
|
742
744
|
value = value.to_dict(*columns)
|
743
745
|
|
744
|
-
output[
|
745
|
-
|
746
|
-
|
746
|
+
output[alias_names.get(column._meta.name) or column._meta.name] = (
|
747
|
+
value
|
748
|
+
)
|
747
749
|
return output
|
748
750
|
|
749
751
|
def __setitem__(self, key: str, value: t.Any):
|
@@ -809,9 +811,11 @@ class Table(metaclass=TableMetaclass):
|
|
809
811
|
# If unquoted, dump it straight into the query.
|
810
812
|
query = ",".join(
|
811
813
|
[
|
812
|
-
|
813
|
-
|
814
|
-
|
814
|
+
(
|
815
|
+
args_dict[column._meta.name].value
|
816
|
+
if is_unquoted(args_dict[column._meta.name])
|
817
|
+
else "{}"
|
818
|
+
)
|
815
819
|
for column in self._meta.columns
|
816
820
|
]
|
817
821
|
)
|
@@ -995,9 +999,11 @@ class Table(metaclass=TableMetaclass):
|
|
995
999
|
Convert any string arguments to column instances.
|
996
1000
|
"""
|
997
1001
|
return [
|
998
|
-
|
999
|
-
|
1000
|
-
|
1002
|
+
(
|
1003
|
+
cls._meta.get_column_by_name(column)
|
1004
|
+
if (isinstance(column, str))
|
1005
|
+
else column
|
1006
|
+
)
|
1001
1007
|
for column in columns
|
1002
1008
|
]
|
1003
1009
|
|
piccolo/utils/pydantic.py
CHANGED
@@ -280,6 +280,7 @@ def create_pydantic_model(
|
|
280
280
|
"choices": column._meta.get_choices_dict(),
|
281
281
|
"secret": column._meta.secret,
|
282
282
|
"nullable": column._meta.null,
|
283
|
+
"unique": column._meta.unique,
|
283
284
|
}
|
284
285
|
|
285
286
|
if isinstance(column, ForeignKey):
|
@@ -333,6 +334,11 @@ def create_pydantic_model(
|
|
333
334
|
elif isinstance(column, Timestamptz):
|
334
335
|
extra["widget"] = "timestamptz"
|
335
336
|
|
337
|
+
# It is useful for Piccolo API and Piccolo Admin to easily know
|
338
|
+
# how many dimensions the array has.
|
339
|
+
if isinstance(column, Array):
|
340
|
+
extra["dimensions"] = column._get_dimensions()
|
341
|
+
|
336
342
|
field = pydantic.Field(
|
337
343
|
json_schema_extra={"extra": extra},
|
338
344
|
**params,
|