xn-model 1.0.10__tar.gz → 1.0.12__tar.gz
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.
- {xn_model-1.0.10/xn_model.egg-info → xn_model-1.0.12}/PKG-INFO +2 -2
- {xn_model-1.0.10 → xn_model-1.0.12}/x_model/field.py +8 -6
- xn_model-1.0.12/x_model/types.py +16 -0
- {xn_model-1.0.10 → xn_model-1.0.12/xn_model.egg-info}/PKG-INFO +2 -2
- xn_model-1.0.10/x_model/types.py +0 -17
- {xn_model-1.0.10 → xn_model-1.0.12}/.env.sample +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/.gitignore +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/.pre-commit-config.yaml +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/README.md +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/makefile +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/pyproject.toml +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/setup.cfg +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/tests/__init__.py +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/tests/test_db.py +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/x_model/__init__.py +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/x_model/func.py +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/x_model/models.py +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/xn_model.egg-info/SOURCES.txt +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/xn_model.egg-info/dependency_links.txt +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/xn_model.egg-info/requires.txt +0 -0
- {xn_model-1.0.10 → xn_model-1.0.12}/xn_model.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from enum import IntEnum
|
|
2
2
|
from typing import Any
|
|
3
3
|
|
|
4
|
-
from asyncpg import Range # Box,
|
|
4
|
+
from asyncpg import Range, Point # Box, Polygon,
|
|
5
5
|
from tortoise import Model
|
|
6
6
|
from tortoise.contrib.postgres.fields import ArrayField
|
|
7
7
|
from tortoise.fields import Field, SmallIntField, IntField, FloatField, DatetimeField
|
|
@@ -51,11 +51,13 @@ class RangeField(CollectionField[Range]):
|
|
|
51
51
|
return value
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
class PointField(CollectionField[Point]):
|
|
55
|
+
SQL_TYPE = "POINT"
|
|
56
|
+
field_type = Point
|
|
57
|
+
base_field = FloatField
|
|
58
|
+
labels = ("lat", "lon")
|
|
59
|
+
|
|
60
|
+
|
|
59
61
|
#
|
|
60
62
|
#
|
|
61
63
|
# class PolygonField(ListField[Polygon]):
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
from pydantic import BaseModel
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class New(BaseModel):
|
|
6
|
+
_unq: ClassVar[tuple[str]] = ()
|
|
7
|
+
|
|
8
|
+
def df_unq(self) -> dict:
|
|
9
|
+
d = {k: v for k, v in self.model_dump(exclude_none=True).items()}
|
|
10
|
+
return {**{k: d.pop(k, None) for k in set(self._unq)}, "defaults": d}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Upd(New):
|
|
14
|
+
_unq = ("id",)
|
|
15
|
+
|
|
16
|
+
id: int
|
xn_model-1.0.10/x_model/types.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from typing import ClassVar
|
|
2
|
-
from msgspec import Struct
|
|
3
|
-
from msgspec.structs import asdict
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class New(Struct):
|
|
7
|
-
_unq: ClassVar[tuple[str]] = ()
|
|
8
|
-
|
|
9
|
-
def df_unq(self, frozen_props: tuple[str] = ()) -> dict:
|
|
10
|
-
d = {k: v for k, v in asdict(self).items() if v is not None or k in frozen_props}
|
|
11
|
-
return {**{k: d.pop(k) for k in set(self._unq) & d.keys()}, "defaults": d}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class Upd(New):
|
|
15
|
-
_unq = ("id",)
|
|
16
|
-
|
|
17
|
-
id: int
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|