TypeDAL 3.16.2__py3-none-any.whl → 3.16.3__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 +37 -32
- {typedal-3.16.2.dist-info → typedal-3.16.3.dist-info}/METADATA +1 -1
- {typedal-3.16.2.dist-info → typedal-3.16.3.dist-info}/RECORD +6 -6
- {typedal-3.16.2.dist-info → typedal-3.16.3.dist-info}/WHEEL +0 -0
- {typedal-3.16.2.dist-info → typedal-3.16.3.dist-info}/entry_points.txt +0 -0
typedal/__about__.py
CHANGED
typedal/core.py
CHANGED
|
@@ -2037,6 +2037,41 @@ class TypedTable(_TypedTable, metaclass=TableMeta):
|
|
|
2037
2037
|
|
|
2038
2038
|
return pydal2sql.generate_sql(cls)
|
|
2039
2039
|
|
|
2040
|
+
def render(self, fields=None, compact=False) -> Self:
|
|
2041
|
+
row = copy.deepcopy(self)
|
|
2042
|
+
keys = list(row)
|
|
2043
|
+
if not fields:
|
|
2044
|
+
fields = [self._table[f] for f in self._table._fields]
|
|
2045
|
+
fields = [f for f in fields if isinstance(f, Field) and f.represent]
|
|
2046
|
+
|
|
2047
|
+
for field in fields:
|
|
2048
|
+
if field._table == self._table:
|
|
2049
|
+
row[field.name] = self._db.represent(
|
|
2050
|
+
"rows_render",
|
|
2051
|
+
field,
|
|
2052
|
+
row[field.name],
|
|
2053
|
+
row,
|
|
2054
|
+
)
|
|
2055
|
+
# else: relationship, different logic:
|
|
2056
|
+
|
|
2057
|
+
for relation_name in row._with:
|
|
2058
|
+
if relation := self._relationships.get(relation_name):
|
|
2059
|
+
relation_table = relation.table
|
|
2060
|
+
|
|
2061
|
+
relation_row = row[relation_name]
|
|
2062
|
+
for fieldname in relation_row:
|
|
2063
|
+
field = relation_table[fieldname]
|
|
2064
|
+
row[relation_name][fieldname] = self._db.represent(
|
|
2065
|
+
"rows_render",
|
|
2066
|
+
field,
|
|
2067
|
+
relation_row[field.name],
|
|
2068
|
+
relation_row,
|
|
2069
|
+
)
|
|
2070
|
+
|
|
2071
|
+
if compact and len(keys) == 1 and keys[0] != "_extra": # pragma: no cover
|
|
2072
|
+
return row[keys[0]]
|
|
2073
|
+
return row
|
|
2074
|
+
|
|
2040
2075
|
|
|
2041
2076
|
# backwards compat:
|
|
2042
2077
|
TypedRow = TypedTable
|
|
@@ -2431,38 +2466,8 @@ class TypedRows(typing.Collection[T_MetaInstance], Rows):
|
|
|
2431
2466
|
"Rows.render() needs a `rows_render` representer in DAL instance",
|
|
2432
2467
|
)
|
|
2433
2468
|
|
|
2434
|
-
row =
|
|
2435
|
-
|
|
2436
|
-
if not fields:
|
|
2437
|
-
fields = [f for f in self.fields if isinstance(f, Field) and f.represent]
|
|
2438
|
-
|
|
2439
|
-
for field in fields:
|
|
2440
|
-
if field._table == self.model._table:
|
|
2441
|
-
row[field.name] = self.db.represent(
|
|
2442
|
-
"rows_render",
|
|
2443
|
-
field,
|
|
2444
|
-
row[field.name],
|
|
2445
|
-
row,
|
|
2446
|
-
)
|
|
2447
|
-
# else: relationship, different logic:
|
|
2448
|
-
|
|
2449
|
-
for relation_name in row._with:
|
|
2450
|
-
if relation := self.model._relationships.get(relation_name):
|
|
2451
|
-
relation_table = relation.table
|
|
2452
|
-
|
|
2453
|
-
relation_row = row[relation_name]
|
|
2454
|
-
for fieldname in relation_row:
|
|
2455
|
-
field = relation_table[fieldname]
|
|
2456
|
-
row[relation_name][fieldname] = self.db.represent(
|
|
2457
|
-
"rows_render",
|
|
2458
|
-
field,
|
|
2459
|
-
relation_row[field.name],
|
|
2460
|
-
relation_row,
|
|
2461
|
-
)
|
|
2462
|
-
|
|
2463
|
-
if self.compact and len(keys) == 1 and keys[0] != "_extra": # pragma: no cover
|
|
2464
|
-
return row[keys[0]]
|
|
2465
|
-
return row
|
|
2469
|
+
row = self.records[i]
|
|
2470
|
+
return row.render(fields, compact=self.compact)
|
|
2466
2471
|
|
|
2467
2472
|
|
|
2468
2473
|
from .caching import ( # noqa: E402
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
typedal/__about__.py,sha256=
|
|
1
|
+
typedal/__about__.py,sha256=07zHmfNrgHIOSZ4D_zREzoRZ1Uy35o5sVinxkwxx-6k,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=33hzCFvCaiszDGBX05k0xoWFa4a3DJOXFgf5a9mkuvg,115189
|
|
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.16.
|
|
17
|
-
typedal-3.16.
|
|
18
|
-
typedal-3.16.
|
|
19
|
-
typedal-3.16.
|
|
16
|
+
typedal-3.16.3.dist-info/METADATA,sha256=cRjhzaVmK3xSH8k4LrVdKoXifbtlgj6SjIwAAVrXnsc,10461
|
|
17
|
+
typedal-3.16.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
typedal-3.16.3.dist-info/entry_points.txt,sha256=m1wqcc_10rHWPdlQ71zEkmJDADUAnZtn7Jac_6mbyUc,44
|
|
19
|
+
typedal-3.16.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|