TypeDAL 3.10.5__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 CHANGED
@@ -5,4 +5,4 @@ This file contains the Version info for this package.
5
5
  # SPDX-FileCopyrightText: 2023-present Robin van der Noord <robinvandernoord@gmail.com>
6
6
  #
7
7
  # SPDX-License-Identifier: MIT
8
- __version__ = "3.10.5"
8
+ __version__ = "3.11.0"
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!
@@ -2788,14 +2794,10 @@ class QueryBuilder(typing.Generic[T_MetaInstance]):
2788
2794
  """
2789
2795
  yield from self.collect()
2790
2796
 
2791
- def count(self, distinct: bool = None) -> int:
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):
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,37 @@ 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):
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
+
2811
2842
  def __paginate(
2812
2843
  self,
2813
2844
  limit: int,
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: TypeDAL
3
- Version: 3.10.5
3
+ Version: 3.11.0
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,9 +1,9 @@
1
- typedal/__about__.py,sha256=XwNMmzb16jawEIZSXa_bOjP7gG-UmYYc2yICqigT9ys,207
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=oDUgcDl3PZRQZYkqp8RNLPQl2Mv6OJhcxTrS4PgNaZw,103116
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.10.5.dist-info/METADATA,sha256=nSpha3NA_op7RKKPw-0uLoc_nlUxIpkjYf8ipo7ztCY,10451
17
- typedal-3.10.5.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
18
- typedal-3.10.5.dist-info/entry_points.txt,sha256=m1wqcc_10rHWPdlQ71zEkmJDADUAnZtn7Jac_6mbyUc,44
19
- typedal-3.10.5.dist-info/RECORD,,
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,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any