TypeDAL 3.10.5__py3-none-any.whl → 3.11.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.
- typedal/__about__.py +1 -1
- typedal/caching.py +1 -1
- typedal/core.py +43 -9
- typedal/for_py4web.py +2 -2
- {typedal-3.10.5.dist-info → typedal-3.11.1.dist-info}/METADATA +2 -2
- {typedal-3.10.5.dist-info → typedal-3.11.1.dist-info}/RECORD +8 -8
- {typedal-3.10.5.dist-info → typedal-3.11.1.dist-info}/WHEEL +1 -1
- {typedal-3.10.5.dist-info → typedal-3.11.1.dist-info}/entry_points.txt +0 -0
typedal/__about__.py
CHANGED
typedal/caching.py
CHANGED
|
@@ -385,7 +385,7 @@ def _calculate_stats(db: "TypeDAL", query: Query) -> GenericStats:
|
|
|
385
385
|
sum_len_field = _TypedalCache.data.len().sum()
|
|
386
386
|
size_row = db(query).select(sum_len_field).first()
|
|
387
387
|
|
|
388
|
-
size = size_row[sum_len_field] if size_row else 0
|
|
388
|
+
size = size_row[sum_len_field] if size_row else 0
|
|
389
389
|
|
|
390
390
|
return {
|
|
391
391
|
"entries": _TypedalCache.where(query).count(),
|
typedal/core.py
CHANGED
|
@@ -189,7 +189,7 @@ class Relationship(typing.Generic[To_Type]):
|
|
|
189
189
|
and_code = inspect.getsource(c_and).strip()
|
|
190
190
|
src_code += " AND " + and_code
|
|
191
191
|
else:
|
|
192
|
-
cls_name = self._type if isinstance(self._type, str) else self._type.__name__
|
|
192
|
+
cls_name = self._type if isinstance(self._type, str) else self._type.__name__
|
|
193
193
|
src_code = f"to {cls_name} (missing condition)"
|
|
194
194
|
|
|
195
195
|
join = f":{self.join}" if self.join else ""
|
|
@@ -1041,6 +1041,12 @@ class TableMeta(type):
|
|
|
1041
1041
|
"""
|
|
1042
1042
|
return QueryBuilder(self).count()
|
|
1043
1043
|
|
|
1044
|
+
def exists(self: Type[T_MetaInstance]) -> bool:
|
|
1045
|
+
"""
|
|
1046
|
+
See QueryBuilder.exists!
|
|
1047
|
+
"""
|
|
1048
|
+
return QueryBuilder(self).exists()
|
|
1049
|
+
|
|
1044
1050
|
def first(self: Type[T_MetaInstance]) -> T_MetaInstance | None:
|
|
1045
1051
|
"""
|
|
1046
1052
|
See QueryBuilder.first!
|
|
@@ -1264,9 +1270,9 @@ class TypedField(Expression, typing.Generic[T_Value]): # pragma: no cover
|
|
|
1264
1270
|
|
|
1265
1271
|
def __init__(
|
|
1266
1272
|
self,
|
|
1267
|
-
_type: Type[T_Value] | types.UnionType = str,
|
|
1273
|
+
_type: Type[T_Value] | types.UnionType = str, # type: ignore
|
|
1268
1274
|
/,
|
|
1269
|
-
**settings: Unpack[FieldSettings],
|
|
1275
|
+
**settings: Unpack[FieldSettings],
|
|
1270
1276
|
) -> None:
|
|
1271
1277
|
"""
|
|
1272
1278
|
Typed version of pydal.Field, which will be converted to a normal Field in the background.
|
|
@@ -2788,14 +2794,10 @@ class QueryBuilder(typing.Generic[T_MetaInstance]):
|
|
|
2788
2794
|
"""
|
|
2789
2795
|
yield from self.collect()
|
|
2790
2796
|
|
|
2791
|
-
def
|
|
2792
|
-
|
|
2793
|
-
Return the amount of rows matching the current query.
|
|
2794
|
-
"""
|
|
2795
|
-
db = self._get_db()
|
|
2797
|
+
def __count(self, db: TypeDAL, distinct: bool = None) -> Query:
|
|
2798
|
+
# internal, shared logic between .count and ._count
|
|
2796
2799
|
model = self.model
|
|
2797
2800
|
query = self.query
|
|
2798
|
-
|
|
2799
2801
|
for key, relation in self.relationships.items():
|
|
2800
2802
|
if (not relation.condition or relation.join != "inner") and not distinct:
|
|
2801
2803
|
continue
|
|
@@ -2806,8 +2808,40 @@ class QueryBuilder(typing.Generic[T_MetaInstance]):
|
|
|
2806
2808
|
other = other.with_alias(f"{key}_{hash(relation)}")
|
|
2807
2809
|
query &= relation.condition(model, other)
|
|
2808
2810
|
|
|
2811
|
+
return query
|
|
2812
|
+
|
|
2813
|
+
def count(self, distinct: bool = None) -> int:
|
|
2814
|
+
"""
|
|
2815
|
+
Return the amount of rows matching the current query.
|
|
2816
|
+
"""
|
|
2817
|
+
db = self._get_db()
|
|
2818
|
+
query = self.__count(db, distinct=distinct)
|
|
2819
|
+
|
|
2809
2820
|
return db(query).count(distinct)
|
|
2810
2821
|
|
|
2822
|
+
def _count(self, distinct: bool = None) -> str:
|
|
2823
|
+
"""
|
|
2824
|
+
Return the SQL for .count().
|
|
2825
|
+
"""
|
|
2826
|
+
db = self._get_db()
|
|
2827
|
+
query = self.__count(db, distinct=distinct)
|
|
2828
|
+
|
|
2829
|
+
return typing.cast(
|
|
2830
|
+
str,
|
|
2831
|
+
db(query)._count(distinct)
|
|
2832
|
+
)
|
|
2833
|
+
|
|
2834
|
+
def exists(self) -> bool:
|
|
2835
|
+
"""
|
|
2836
|
+
Determines if any records exist matching the current query.
|
|
2837
|
+
|
|
2838
|
+
Returns True if one or more records exist; otherwise, False.
|
|
2839
|
+
|
|
2840
|
+
Returns:
|
|
2841
|
+
bool: A boolean indicating whether any records exist.
|
|
2842
|
+
"""
|
|
2843
|
+
return bool(self.count())
|
|
2844
|
+
|
|
2811
2845
|
def __paginate(
|
|
2812
2846
|
self,
|
|
2813
2847
|
limit: int,
|
typedal/for_py4web.py
CHANGED
|
@@ -22,9 +22,9 @@ class Fixture(_Fixture): # type: ignore
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class PY4WEB_DAL_SINGLETON(MetaDAL):
|
|
25
|
-
_instances: typing.ClassVar[typing.MutableMapping[str,
|
|
25
|
+
_instances: typing.ClassVar[typing.MutableMapping[str, TypeDAL]] = {}
|
|
26
26
|
|
|
27
|
-
def __call__(cls, uri: typing.Optional[str] = None, *args: typing.Any, **kwargs: typing.Any) ->
|
|
27
|
+
def __call__(cls, uri: typing.Optional[str] = None, *args: typing.Any, **kwargs: typing.Any) -> TypeDAL:
|
|
28
28
|
db_uid = kwargs.get("db_uid", hashlib_md5(repr(uri or (args, kwargs))).hexdigest())
|
|
29
29
|
if db_uid not in cls._instances:
|
|
30
30
|
cls._instances[db_uid] = super().__call__(uri, *args, **kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: TypeDAL
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.11.1
|
|
4
4
|
Summary: Typing support for PyDAL
|
|
5
5
|
Project-URL: Documentation, https://typedal.readthedocs.io/
|
|
6
6
|
Project-URL: Issues, https://github.com/trialandsuccess/TypeDAL/issues
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
typedal/__about__.py,sha256=
|
|
1
|
+
typedal/__about__.py,sha256=FxEaTblLPFTyRApu557gN7IPsOOYvkcUlJquX4MlDDk,207
|
|
2
2
|
typedal/__init__.py,sha256=QQpLiVl9w9hm2LBxey49Y_tCF_VB2bScVaS_mCjYy54,366
|
|
3
|
-
typedal/caching.py,sha256=
|
|
3
|
+
typedal/caching.py,sha256=6YUzUMpan56nSy3D-Jl0FS-8V4LbTnpRSoDJHj6yPYo,11782
|
|
4
4
|
typedal/cli.py,sha256=FInI6LuhCbJXhh6qAqXpaPPckdkIQKGydnGYOo0_cm8,19253
|
|
5
5
|
typedal/config.py,sha256=0qy1zrTUdtmXPM9jHzFnSR1DJsqGJqcdG6pvhzKQHe0,11625
|
|
6
|
-
typedal/core.py,sha256=
|
|
6
|
+
typedal/core.py,sha256=qqZtlRJKhUiEzjA7QKxovPpV9ety6PlUbskcrjZC-uQ,104054
|
|
7
7
|
typedal/fields.py,sha256=ThkI0_E6Oq_2Vj30j0AWHRSOLvUEPu1gyECtStoECjs,6556
|
|
8
|
-
typedal/for_py4web.py,sha256=
|
|
8
|
+
typedal/for_py4web.py,sha256=rE1kOXF6pUx0ya9jWMjGYaoFCpbYtjcYxccSvUo9o9M,1946
|
|
9
9
|
typedal/for_web2py.py,sha256=xn7zo6ImsmTkH6LacbjLQl2oqyBvP0zLqRxEJvMQk1w,1929
|
|
10
10
|
typedal/helpers.py,sha256=uej96exzJ9qVBd6LudP8uJ_7Cmq6vKraerdKvSRBVjc,8128
|
|
11
11
|
typedal/mixins.py,sha256=ySF55URmSMyUCdMhiQJSKjkz4s5XGaO1pvmpJAOLUSU,7821
|
|
@@ -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=VK9T8P5UwVLvfNBsY4q79ANcABv-jX76YKADt1Zz_co,1539
|
|
15
15
|
typedal/serializers/as_json.py,sha256=ffo152W-sARYXym4BzwX709rrO2-QwKk2KunWY8RNl4,2229
|
|
16
|
-
typedal-3.
|
|
17
|
-
typedal-3.
|
|
18
|
-
typedal-3.
|
|
19
|
-
typedal-3.
|
|
16
|
+
typedal-3.11.1.dist-info/METADATA,sha256=8syVmQaBPZZ2d_8a_sJeT9g6PNEkpOzAqjP82ZoZS7o,10451
|
|
17
|
+
typedal-3.11.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
typedal-3.11.1.dist-info/entry_points.txt,sha256=m1wqcc_10rHWPdlQ71zEkmJDADUAnZtn7Jac_6mbyUc,44
|
|
19
|
+
typedal-3.11.1.dist-info/RECORD,,
|
|
File without changes
|