xn-model 1.0.22__py3-none-any.whl → 1.0.23__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 +35 -11
- x_model/models.py +2 -2
- {xn_model-1.0.22.dist-info → xn_model-1.0.23.dist-info}/METADATA +1 -1
- xn_model-1.0.23.dist-info/RECORD +9 -0
- xn_model-1.0.22.dist-info/RECORD +0 -9
- {xn_model-1.0.22.dist-info → xn_model-1.0.23.dist-info}/WHEEL +0 -0
- {xn_model-1.0.22.dist-info → xn_model-1.0.23.dist-info}/top_level.txt +0 -0
x_model/field.py
CHANGED
|
@@ -4,7 +4,7 @@ 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, BinaryField
|
|
7
|
+
from tortoise.fields import Field, SmallIntField, IntField, FloatField, DatetimeField, BinaryField
|
|
8
8
|
from tortoise.fields.base import VALUE
|
|
9
9
|
|
|
10
10
|
|
|
@@ -12,8 +12,20 @@ class UniqBinaryField(BinaryField):
|
|
|
12
12
|
indexable = True
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
class
|
|
16
|
-
|
|
15
|
+
class UIntField(IntField):
|
|
16
|
+
def to_db_value(self, value: Any, instance: type[Model] | Model) -> Any:
|
|
17
|
+
self.validate(value)
|
|
18
|
+
return value if value is None or isinstance(value, str) else str(value)
|
|
19
|
+
|
|
20
|
+
def to_python_value(self, value: Any) -> Any:
|
|
21
|
+
return value if value is None or isinstance(value, int) else int(value)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class UInt1Field(UIntField):
|
|
25
|
+
SQL_TYPE = "UINT1"
|
|
26
|
+
|
|
27
|
+
class _db_postgres:
|
|
28
|
+
GENERATED_SQL = "UINT1 NOT NULL PRIMARY KEY"
|
|
17
29
|
|
|
18
30
|
@property
|
|
19
31
|
def constraints(self) -> dict:
|
|
@@ -23,8 +35,11 @@ class UInt1Field(SmallIntField):
|
|
|
23
35
|
}
|
|
24
36
|
|
|
25
37
|
|
|
26
|
-
class UInt2Field(
|
|
27
|
-
SQL_TYPE = "
|
|
38
|
+
class UInt2Field(UIntField):
|
|
39
|
+
SQL_TYPE = "UINT2"
|
|
40
|
+
|
|
41
|
+
class _db_postgres:
|
|
42
|
+
GENERATED_SQL = "UINT2 NOT NULL PRIMARY KEY"
|
|
28
43
|
|
|
29
44
|
@property
|
|
30
45
|
def constraints(self) -> dict:
|
|
@@ -34,8 +49,11 @@ class UInt2Field(IntField):
|
|
|
34
49
|
}
|
|
35
50
|
|
|
36
51
|
|
|
37
|
-
class UIntField
|
|
38
|
-
SQL_TYPE = "
|
|
52
|
+
class UInt4Field(UIntField):
|
|
53
|
+
SQL_TYPE = "UINT4"
|
|
54
|
+
|
|
55
|
+
class _db_postgres:
|
|
56
|
+
GENERATED_SQL = "UINT4 NOT NULL PRIMARY KEY"
|
|
39
57
|
|
|
40
58
|
@property
|
|
41
59
|
def constraints(self) -> dict:
|
|
@@ -45,8 +63,11 @@ class UIntField(BigIntField):
|
|
|
45
63
|
}
|
|
46
64
|
|
|
47
65
|
|
|
48
|
-
class UInt8Field(
|
|
49
|
-
SQL_TYPE = "
|
|
66
|
+
class UInt8Field(UIntField):
|
|
67
|
+
SQL_TYPE = "UINT8"
|
|
68
|
+
|
|
69
|
+
class _db_postgres:
|
|
70
|
+
GENERATED_SQL = "UINT8 NOT NULL PRIMARY KEY"
|
|
50
71
|
|
|
51
72
|
@property
|
|
52
73
|
def constraints(self) -> dict:
|
|
@@ -56,8 +77,11 @@ class UInt8Field(BigIntField):
|
|
|
56
77
|
}
|
|
57
78
|
|
|
58
79
|
|
|
59
|
-
class UInt16Field(
|
|
60
|
-
SQL_TYPE = "
|
|
80
|
+
class UInt16Field(UIntField):
|
|
81
|
+
SQL_TYPE = "UINT16"
|
|
82
|
+
|
|
83
|
+
class _db_postgres:
|
|
84
|
+
GENERATED_SQL = "UINT16 NOT NULL PRIMARY KEY"
|
|
61
85
|
|
|
62
86
|
@property
|
|
63
87
|
def constraints(self) -> dict:
|
x_model/models.py
CHANGED
|
@@ -6,7 +6,7 @@ from pydantic import ConfigDict
|
|
|
6
6
|
from tortoise import Model as TortModel
|
|
7
7
|
from tortoise.signals import Signals
|
|
8
8
|
|
|
9
|
-
from x_model.field import DatetimeSecField,
|
|
9
|
+
from x_model.field import DatetimeSecField, IntField
|
|
10
10
|
from x_model.types import BaseUpd
|
|
11
11
|
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ class TsTrait:
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class Model(TortModel):
|
|
19
|
-
id: int =
|
|
19
|
+
id: int = IntField(True)
|
|
20
20
|
|
|
21
21
|
_in_type: type[BaseUpd] = None # overridable
|
|
22
22
|
_name: tuple[str] = ("name",)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
x_model/__init__.py,sha256=1Lgvr-SZwkM4R7L0ceVLyArzzMJiFLgaid-RUOk_ypM,344
|
|
2
|
+
x_model/field.py,sha256=Qf2nua1Qj_6OAtjLCCxC5h9dtEGNOWIA-Z8est_BoKY,4533
|
|
3
|
+
x_model/func.py,sha256=flj89sCOou7NJlriPYbIpX8rdbugbe-vjT2C0ORl9DY,312
|
|
4
|
+
x_model/models.py,sha256=apHNmhnzjjJ9ATUxSSdei7uixEUrNzc2PcwJhN4rayM,3791
|
|
5
|
+
x_model/types.py,sha256=CITb6DSLZ3KHmEgQRjZCFRUId4x-_pecwZdh6xXt0HE,339
|
|
6
|
+
xn_model-1.0.23.dist-info/METADATA,sha256=bCfadu4c_mKcDPS3K4R_j4eKEjFn8BPnPvnqbrUWpCw,986
|
|
7
|
+
xn_model-1.0.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
xn_model-1.0.23.dist-info/top_level.txt,sha256=QCYyfv5AA_8jPPtCpShkBXzQRUCGuuW7Ro0mqysDE8E,8
|
|
9
|
+
xn_model-1.0.23.dist-info/RECORD,,
|
xn_model-1.0.22.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
x_model/__init__.py,sha256=1Lgvr-SZwkM4R7L0ceVLyArzzMJiFLgaid-RUOk_ypM,344
|
|
2
|
-
x_model/field.py,sha256=C2eV5-FIWsMVknuQSUr9i8NjrScwvuEIuoPQik2qdd8,3866
|
|
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.22.dist-info/METADATA,sha256=uL5UvNS6UxzOZy4ZfxVm1lbYL3FT1SsFM4CxaLrWDpM,986
|
|
7
|
-
xn_model-1.0.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
xn_model-1.0.22.dist-info/top_level.txt,sha256=QCYyfv5AA_8jPPtCpShkBXzQRUCGuuW7Ro0mqysDE8E,8
|
|
9
|
-
xn_model-1.0.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|