xn-model 1.0.19__py3-none-any.whl → 1.0.21__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.
x_model/field.py CHANGED
@@ -4,10 +4,69 @@ from typing import Any
4
4
  from asyncpg import Range, Point # Box, Polygon,
5
5
  from tortoise import Model
6
6
  from tortoise.contrib.postgres.fields import ArrayField
7
- from tortoise.fields import Field, SmallIntField, IntField, FloatField, DatetimeField
7
+ from tortoise.fields import Field, SmallIntField, IntField, FloatField, DatetimeField, BinaryField, BigIntField
8
8
  from tortoise.fields.base import VALUE
9
9
 
10
10
 
11
+ class UniqBinaryField(BinaryField):
12
+ indexable = True
13
+
14
+
15
+ class UInt1Field(IntField):
16
+ SQL_TYPE = "UINT2"
17
+
18
+ @property
19
+ def constraints(self) -> dict:
20
+ return {
21
+ "ge": 0,
22
+ "le": 255,
23
+ }
24
+
25
+
26
+ class UInt2Field(IntField):
27
+ SQL_TYPE = "UINT2"
28
+
29
+ @property
30
+ def constraints(self) -> dict:
31
+ return {
32
+ "ge": 0,
33
+ "le": 65535,
34
+ }
35
+
36
+
37
+ class UIntField(IntField):
38
+ SQL_TYPE = "UINT4"
39
+
40
+ @property
41
+ def constraints(self) -> dict:
42
+ return {
43
+ "ge": 0,
44
+ "le": 4_294_967_295,
45
+ }
46
+
47
+
48
+ class UInt8Field(BigIntField):
49
+ SQL_TYPE = "UINT8"
50
+
51
+ @property
52
+ def constraints(self) -> dict:
53
+ return {
54
+ "ge": 0,
55
+ "le": 18_446_744_073_709_551_615,
56
+ }
57
+
58
+
59
+ class UInt16Field(BigIntField):
60
+ SQL_TYPE = "UINT16"
61
+
62
+ @property
63
+ def constraints(self) -> dict:
64
+ return {
65
+ "ge": 0,
66
+ "le": 340282366920938463463374607431768211455,
67
+ }
68
+
69
+
11
70
  class ListField(Field[VALUE]):
12
71
  base_field = Field[VALUE]
13
72
  labels: tuple
x_model/models.py CHANGED
@@ -4,10 +4,9 @@ from typing import Self
4
4
 
5
5
  from pydantic import ConfigDict
6
6
  from tortoise import Model as TortModel
7
- from tortoise.fields import IntField
8
7
  from tortoise.signals import Signals
9
8
 
10
- from x_model.field import DatetimeSecField
9
+ from x_model.field import DatetimeSecField, UIntField
11
10
  from x_model.types import BaseUpd
12
11
 
13
12
 
@@ -17,7 +16,7 @@ class TsTrait:
17
16
 
18
17
 
19
18
  class Model(TortModel):
20
- id: int = IntField(True)
19
+ id: int = UIntField(True)
21
20
 
22
21
  _in_type: type[BaseUpd] = None # overridable
23
22
  _name: tuple[str] = ("name",)
x_model/types.py CHANGED
@@ -6,6 +6,6 @@ from typing import ClassVar
6
6
  class BaseUpd:
7
7
  _unq: ClassVar[set[str]]
8
8
 
9
- def df_unq(self) -> dict:
10
- d = {k: v for k, v in asdict(self).items() if v is not None or k in self._unq}
9
+ def df_unq(self, **kwargs) -> dict:
10
+ d = {k: v for k, v in (asdict(self) | kwargs).items() if v is not None or k in self._unq}
11
11
  return {**{k: d.pop(k, None) for k in self._unq}, "defaults": d}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-model
3
- Version: 1.0.19
3
+ Version: 1.0.21
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -0,0 +1,9 @@
1
+ x_model/__init__.py,sha256=1Lgvr-SZwkM4R7L0ceVLyArzzMJiFLgaid-RUOk_ypM,344
2
+ x_model/field.py,sha256=1PzHWYodsjx5waC9aH07faAC4WBrEhpWgXL39SyKYQU,3809
3
+ x_model/func.py,sha256=flj89sCOou7NJlriPYbIpX8rdbugbe-vjT2C0ORl9DY,312
4
+ x_model/models.py,sha256=Pdkcemb2jSFU0x7YSz9nWVmoGyShF-TzAo2SOUjVbvM,3793
5
+ x_model/types.py,sha256=CITb6DSLZ3KHmEgQRjZCFRUId4x-_pecwZdh6xXt0HE,339
6
+ xn_model-1.0.21.dist-info/METADATA,sha256=EIxiWmHURXnDjfMNcdah-x2-P9segJeggINIK7-IBTA,986
7
+ xn_model-1.0.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ xn_model-1.0.21.dist-info/top_level.txt,sha256=QCYyfv5AA_8jPPtCpShkBXzQRUCGuuW7Ro0mqysDE8E,8
9
+ xn_model-1.0.21.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- x_model/__init__.py,sha256=1Lgvr-SZwkM4R7L0ceVLyArzzMJiFLgaid-RUOk_ypM,344
2
- x_model/field.py,sha256=zVszcPZFVEwsurqbFQF-_caiSLruh3TRSZdgQqwWJV8,2776
3
- x_model/func.py,sha256=flj89sCOou7NJlriPYbIpX8rdbugbe-vjT2C0ORl9DY,312
4
- x_model/models.py,sha256=aR55uKzYyIZNOIwWlzPym5EViyfcOFrVcMGIu8mItCA,3818
5
- x_model/types.py,sha256=iES9Oxj45hEBB1tvZlNAOM4eS7w3Y8iC37X7FmcEwe4,318
6
- xn_model-1.0.19.dist-info/METADATA,sha256=uOYNBeMcIc6GcdvagSwSsKzvxbjaPMeEAOhiBvFisSE,986
7
- xn_model-1.0.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- xn_model-1.0.19.dist-info/top_level.txt,sha256=QCYyfv5AA_8jPPtCpShkBXzQRUCGuuW7Ro0mqysDE8E,8
9
- xn_model-1.0.19.dist-info/RECORD,,