TypeDAL 3.11.1__py3-none-any.whl → 3.12.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.11.1"
8
+ __version__ = "3.12.0"
typedal/core.py CHANGED
@@ -11,6 +11,7 @@ import math
11
11
  import sys
12
12
  import types
13
13
  import typing
14
+ import uuid
14
15
  import warnings
15
16
  from collections import defaultdict
16
17
  from copy import copy
@@ -1179,11 +1180,21 @@ class TableMeta(type):
1179
1180
  Useful for joins when joining the same table multiple times.
1180
1181
 
1181
1182
  See Also:
1182
- http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=export_to_csv_file#One-to-many-relation
1183
+ http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#One-to-many-relation
1183
1184
  """
1184
1185
  table = self._ensure_table_defined()
1185
1186
  return typing.cast(Type[T_MetaInstance], table.with_alias(alias))
1186
1187
 
1188
+ def unique_alias(self: Type[T_MetaInstance]) -> Type[T_MetaInstance]:
1189
+ """
1190
+ Generates a unique alias for this table.
1191
+
1192
+ Useful for joins when joining the same table multiple times
1193
+ and you don't want to keep track of aliases yourself.
1194
+ """
1195
+ key = f"{self.__name__.lower()}_{hash(uuid.uuid4())}"
1196
+ return self.with_alias(key)
1197
+
1187
1198
  # hooks:
1188
1199
  def before_insert(
1189
1200
  cls: Type[T_MetaInstance],
@@ -1270,7 +1281,7 @@ class TypedField(Expression, typing.Generic[T_Value]): # pragma: no cover
1270
1281
 
1271
1282
  def __init__(
1272
1283
  self,
1273
- _type: Type[T_Value] | types.UnionType = str, # type: ignore
1284
+ _type: Type[T_Value] | types.UnionType = str, # type: ignore
1274
1285
  /,
1275
1286
  **settings: Unpack[FieldSettings],
1276
1287
  ) -> None:
@@ -2683,6 +2694,12 @@ class QueryBuilder(typing.Generic[T_MetaInstance]):
2683
2694
  if not isinstance(on, list): # pragma: no cover
2684
2695
  on = [on]
2685
2696
 
2697
+ on = [
2698
+ _
2699
+ for _ in on
2700
+ # only allow Expressions (query and such):
2701
+ if isinstance(_, pydal.objects.Expression)
2702
+ ]
2686
2703
  left.extend(on)
2687
2704
  elif method == "left":
2688
2705
  # .on not given, generate it:
@@ -2826,10 +2843,7 @@ class QueryBuilder(typing.Generic[T_MetaInstance]):
2826
2843
  db = self._get_db()
2827
2844
  query = self.__count(db, distinct=distinct)
2828
2845
 
2829
- return typing.cast(
2830
- str,
2831
- db(query)._count(distinct)
2832
- )
2846
+ return typing.cast(str, db(query)._count(distinct))
2833
2847
 
2834
2848
  def exists(self) -> bool:
2835
2849
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TypeDAL
3
- Version: 3.11.1
3
+ Version: 3.12.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=FxEaTblLPFTyRApu557gN7IPsOOYvkcUlJquX4MlDDk,207
1
+ typedal/__about__.py,sha256=JubUKNHdusOHh_ihG36I1-syCZC_hicLVOoqMvn-nlY,207
2
2
  typedal/__init__.py,sha256=QQpLiVl9w9hm2LBxey49Y_tCF_VB2bScVaS_mCjYy54,366
3
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=qqZtlRJKhUiEzjA7QKxovPpV9ety6PlUbskcrjZC-uQ,104054
6
+ typedal/core.py,sha256=da5zTuvkMXnTlUyUH0Q_BTP83cnD7dAE5wsiUdvnsDw,104609
7
7
  typedal/fields.py,sha256=ThkI0_E6Oq_2Vj30j0AWHRSOLvUEPu1gyECtStoECjs,6556
8
8
  typedal/for_py4web.py,sha256=rE1kOXF6pUx0ya9jWMjGYaoFCpbYtjcYxccSvUo9o9M,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.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,,
16
+ typedal-3.12.0.dist-info/METADATA,sha256=iYWjdfSMqz11X8a4Elo7DUBI4RoZzjFTJTBuGq1MfeU,10451
17
+ typedal-3.12.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ typedal-3.12.0.dist-info/entry_points.txt,sha256=m1wqcc_10rHWPdlQ71zEkmJDADUAnZtn7Jac_6mbyUc,44
19
+ typedal-3.12.0.dist-info/RECORD,,