TypeDAL 3.10.4__py3-none-any.whl → 3.11.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 +42 -7
- {typedal-3.10.4.dist-info → typedal-3.11.0.dist-info}/METADATA +1 -1
- {typedal-3.10.4.dist-info → typedal-3.11.0.dist-info}/RECORD +6 -6
- {typedal-3.10.4.dist-info → typedal-3.11.0.dist-info}/WHEEL +0 -0
- {typedal-3.10.4.dist-info → typedal-3.11.0.dist-info}/entry_points.txt +0 -0
typedal/__about__.py
CHANGED
typedal/core.py
CHANGED
|
@@ -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!
|
|
@@ -1977,7 +1983,11 @@ class TypedRows(typing.Collection[T_MetaInstance], Rows):
|
|
|
1977
1983
|
Print a table on repr().
|
|
1978
1984
|
"""
|
|
1979
1985
|
data = self.as_dict()
|
|
1980
|
-
|
|
1986
|
+
try:
|
|
1987
|
+
headers = list(next(iter(data.values())).keys())
|
|
1988
|
+
except StopIteration:
|
|
1989
|
+
headers = []
|
|
1990
|
+
|
|
1981
1991
|
return mktable(data, headers)
|
|
1982
1992
|
|
|
1983
1993
|
def group_by_value(
|
|
@@ -2784,14 +2794,10 @@ class QueryBuilder(typing.Generic[T_MetaInstance]):
|
|
|
2784
2794
|
"""
|
|
2785
2795
|
yield from self.collect()
|
|
2786
2796
|
|
|
2787
|
-
def
|
|
2788
|
-
|
|
2789
|
-
Return the amount of rows matching the current query.
|
|
2790
|
-
"""
|
|
2791
|
-
db = self._get_db()
|
|
2797
|
+
def __count(self, db: TypeDAL, distinct: bool = None):
|
|
2798
|
+
# internal, shared logic between .count and ._count
|
|
2792
2799
|
model = self.model
|
|
2793
2800
|
query = self.query
|
|
2794
|
-
|
|
2795
2801
|
for key, relation in self.relationships.items():
|
|
2796
2802
|
if (not relation.condition or relation.join != "inner") and not distinct:
|
|
2797
2803
|
continue
|
|
@@ -2802,8 +2808,37 @@ class QueryBuilder(typing.Generic[T_MetaInstance]):
|
|
|
2802
2808
|
other = other.with_alias(f"{key}_{hash(relation)}")
|
|
2803
2809
|
query &= relation.condition(model, other)
|
|
2804
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
|
+
|
|
2805
2820
|
return db(query).count(distinct)
|
|
2806
2821
|
|
|
2822
|
+
def _count(self, distinct: bool = None):
|
|
2823
|
+
"""
|
|
2824
|
+
Return the SQL for .count().
|
|
2825
|
+
"""
|
|
2826
|
+
db = self._get_db()
|
|
2827
|
+
query = self.__count(db, distinct=distinct)
|
|
2828
|
+
|
|
2829
|
+
return db(query)._count(distinct)
|
|
2830
|
+
|
|
2831
|
+
def exists(self) -> bool:
|
|
2832
|
+
"""
|
|
2833
|
+
Determines if any records exist matching the current query.
|
|
2834
|
+
|
|
2835
|
+
Returns True if one or more records exist; otherwise, False.
|
|
2836
|
+
|
|
2837
|
+
Returns:
|
|
2838
|
+
bool: A boolean indicating whether any records exist.
|
|
2839
|
+
"""
|
|
2840
|
+
return bool(self.count())
|
|
2841
|
+
|
|
2807
2842
|
def __paginate(
|
|
2808
2843
|
self,
|
|
2809
2844
|
limit: int,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
typedal/__about__.py,sha256=
|
|
1
|
+
typedal/__about__.py,sha256=1f7MoVpdTqkypZlQgcrYujT2Vp73v7SEpR97CAm84Ns,207
|
|
2
2
|
typedal/__init__.py,sha256=QQpLiVl9w9hm2LBxey49Y_tCF_VB2bScVaS_mCjYy54,366
|
|
3
3
|
typedal/caching.py,sha256=SMcJsahLlZ79yykWCveERFx1ZJUNEKhA9SPmCTIuLp8,11798
|
|
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=lmcnH77H1RqDhHNow7UZbH7tsgKn2rItMNLB5sxdMc4,104003
|
|
7
7
|
typedal/fields.py,sha256=ThkI0_E6Oq_2Vj30j0AWHRSOLvUEPu1gyECtStoECjs,6556
|
|
8
8
|
typedal/for_py4web.py,sha256=plb08K6HmxbM1_5GuBFFzovAJIT7Q3g9ocNjUJOBngY,1946
|
|
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=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.0.dist-info/METADATA,sha256=S1zaibVo4aKtJjrJrjiIH-HeAoSHS6CC0rr8JVMkZj8,10451
|
|
17
|
+
typedal-3.11.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
typedal-3.11.0.dist-info/entry_points.txt,sha256=m1wqcc_10rHWPdlQ71zEkmJDADUAnZtn7Jac_6mbyUc,44
|
|
19
|
+
typedal-3.11.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|