TypeDAL 3.15.5__py3-none-any.whl → 3.16.0__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.
Potentially problematic release.
This version of TypeDAL might be problematic. Click here for more details.
- typedal/__about__.py +1 -1
- typedal/core.py +40 -0
- {typedal-3.15.5.dist-info → typedal-3.16.0.dist-info}/METADATA +1 -1
- {typedal-3.15.5.dist-info → typedal-3.16.0.dist-info}/RECORD +6 -6
- {typedal-3.15.5.dist-info → typedal-3.16.0.dist-info}/WHEEL +0 -0
- {typedal-3.15.5.dist-info → typedal-3.16.0.dist-info}/entry_points.txt +0 -0
typedal/__about__.py
CHANGED
typedal/core.py
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Core functionality of TypeDAL.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
5
7
|
import contextlib
|
|
6
8
|
import csv
|
|
7
9
|
import datetime as dt
|
|
@@ -826,6 +828,31 @@ P = typing.ParamSpec("P")
|
|
|
826
828
|
R = typing.TypeVar("R")
|
|
827
829
|
|
|
828
830
|
|
|
831
|
+
def reorder_fields(
|
|
832
|
+
table: pydal.objects.Table, fields: list[str | Field | TypedField], keep_others: bool = True
|
|
833
|
+
) -> None:
|
|
834
|
+
"""
|
|
835
|
+
Reorder fields of a pydal table.
|
|
836
|
+
|
|
837
|
+
Args:
|
|
838
|
+
table: The pydal table object (e.g., db.mytable).
|
|
839
|
+
fields: List of field names (str) or Field objects in desired order.
|
|
840
|
+
keep_others (bool):
|
|
841
|
+
- True (default): keep other fields at the end, in their original order.
|
|
842
|
+
- False: remove other fields (only keep what's specified).
|
|
843
|
+
"""
|
|
844
|
+
# Normalize input to field names
|
|
845
|
+
desired = [f.name if isinstance(f, (TypedField, Field, pydal.objects.Field)) else str(f) for f in fields]
|
|
846
|
+
|
|
847
|
+
new_order = [f for f in desired if f in table._fields]
|
|
848
|
+
|
|
849
|
+
if keep_others:
|
|
850
|
+
# Start with desired fields, then append the rest
|
|
851
|
+
new_order.extend(f for f in table._fields if f not in desired)
|
|
852
|
+
|
|
853
|
+
table._fields = new_order
|
|
854
|
+
|
|
855
|
+
|
|
829
856
|
class TableMeta(type):
|
|
830
857
|
"""
|
|
831
858
|
This metaclass contains functionality on table classes, that doesn't exist on its instances.
|
|
@@ -1367,6 +1394,19 @@ class TableMeta(type):
|
|
|
1367
1394
|
"""
|
|
1368
1395
|
return cls._hook_once(cls._after_delete, fn)
|
|
1369
1396
|
|
|
1397
|
+
def reorder_fields(cls, fields: list[str | Field | TypedField], keep_others: bool = True):
|
|
1398
|
+
"""
|
|
1399
|
+
Reorder fields of a typedal table.
|
|
1400
|
+
|
|
1401
|
+
Args:
|
|
1402
|
+
fields: List of field names (str) or Field objects in desired order.
|
|
1403
|
+
keep_others (bool):
|
|
1404
|
+
- True (default): keep other fields at the end, in their original order.
|
|
1405
|
+
- False: remove other fields (only keep what's specified).
|
|
1406
|
+
"""
|
|
1407
|
+
|
|
1408
|
+
return reorder_fields(cls._table, fields, keep_others=keep_others)
|
|
1409
|
+
|
|
1370
1410
|
|
|
1371
1411
|
class TypedField(Expression, typing.Generic[T_Value]): # pragma: no cover
|
|
1372
1412
|
"""
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
typedal/__about__.py,sha256=
|
|
1
|
+
typedal/__about__.py,sha256=ObX7s3UzFK2tDsgoSc9qNVBMDNoRrE7wOynSY0tJgTM,207
|
|
2
2
|
typedal/__init__.py,sha256=Y6LT5UE3HrfWND_drJddYFbDjfnvqQER8MxZiEREFGw,366
|
|
3
3
|
typedal/caching.py,sha256=6YUzUMpan56nSy3D-Jl0FS-8V4LbTnpRSoDJHj6yPYo,11782
|
|
4
4
|
typedal/cli.py,sha256=SnWceLPDd-t90VPHAV9O3RR7JZtpVniT55TqtrRv3VM,19255
|
|
5
5
|
typedal/config.py,sha256=0qy1zrTUdtmXPM9jHzFnSR1DJsqGJqcdG6pvhzKQHe0,11625
|
|
6
|
-
typedal/core.py,sha256=
|
|
6
|
+
typedal/core.py,sha256=GEgcEW2EVOeSh7d05U1atFmhvO1uFF3qTCBFeV6bpU8,112221
|
|
7
7
|
typedal/fields.py,sha256=oOmTonXG-g4Lpj5_gSr8GJ-EZIEqO435Fm8-MS_cmoc,7356
|
|
8
8
|
typedal/for_py4web.py,sha256=KIIu8XgnAfRQCJfZCra79k8SInOHiFuLDKUv3hzTJng,1908
|
|
9
9
|
typedal/for_web2py.py,sha256=xn7zo6ImsmTkH6LacbjLQl2oqyBvP0zLqRxEJvMQk1w,1929
|
|
@@ -13,7 +13,7 @@ typedal/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
13
13
|
typedal/types.py,sha256=1FIgv1s0be0E8r5Wd9E1nvDvK4ETV8u2NlfI7_P6UUY,6752
|
|
14
14
|
typedal/web2py_py4web_shared.py,sha256=UYmD0_aK1bSVBt_f3j59Mxq-zOmQNkYkb8sPDUibq68,1539
|
|
15
15
|
typedal/serializers/as_json.py,sha256=3JZlFhPrdvZVFAmH7P5DUAz8-TIk-br0F1CjKG3PFDM,2246
|
|
16
|
-
typedal-3.
|
|
17
|
-
typedal-3.
|
|
18
|
-
typedal-3.
|
|
19
|
-
typedal-3.
|
|
16
|
+
typedal-3.16.0.dist-info/METADATA,sha256=jpzmQFRP_Ky-ecu2QSs-m6VoQtwqCX09Dh3akCZG6oo,10461
|
|
17
|
+
typedal-3.16.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
typedal-3.16.0.dist-info/entry_points.txt,sha256=m1wqcc_10rHWPdlQ71zEkmJDADUAnZtn7Jac_6mbyUc,44
|
|
19
|
+
typedal-3.16.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|