xn-model 0.10.4__tar.gz → 0.11.0__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-0.10.4/xn_model.egg-info → xn_model-0.11.0}/PKG-INFO +1 -1
- {xn_model-0.10.4 → xn_model-0.11.0}/x_model/model.py +2 -2
- {xn_model-0.10.4 → xn_model-0.11.0/xn_model.egg-info}/PKG-INFO +1 -1
- {xn_model-0.10.4 → xn_model-0.11.0}/.env.sample +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/.gitignore +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/.pre-commit-config.yaml +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/README.md +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/makefile +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/pyproject.toml +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/setup.cfg +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/tests/__init__.py +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/tests/test_db.py +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/x_model/__init__.py +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/x_model/field.py +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/x_model/func.py +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/x_model/pydantic.py +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/xn_model.egg-info/SOURCES.txt +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/xn_model.egg-info/dependency_links.txt +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/xn_model.egg-info/requires.txt +0 -0
- {xn_model-0.10.4 → xn_model-0.11.0}/xn_model.egg-info/top_level.txt +0 -0
|
@@ -42,7 +42,7 @@ class BaseModel(TortoiseModel):
|
|
|
42
42
|
async def upsert(cls, data: dict, oid=None):
|
|
43
43
|
meta: MetaInfo = cls._meta
|
|
44
44
|
|
|
45
|
-
# pop fields for relations from general data dict
|
|
45
|
+
# pop fields for relations from general data dict # todo: add backwards fields for save
|
|
46
46
|
m2ms = {k: data.pop(k) for k in meta.m2m_fields if k in data}
|
|
47
47
|
# bfks = {k: data.pop(k) for k in meta.backward_fk_fields if k in data}
|
|
48
48
|
# bo2os = {k: data.pop(k) for k in meta.backward_o2o_fields if k in data}
|
|
@@ -54,7 +54,7 @@ class BaseModel(TortoiseModel):
|
|
|
54
54
|
# unq = {key: data.pop(key) for key, ft in meta.fields_map.items() if ft.unique and key in data.keys()}
|
|
55
55
|
# # unq = meta.unique_together
|
|
56
56
|
# obj, is_created = await cls.update_or_create(data, **unq)
|
|
57
|
-
obj = (await cls.update_or_create(data,
|
|
57
|
+
obj = (await cls.update_or_create(data, id=oid))[0] if oid else await cls.create(**data)
|
|
58
58
|
|
|
59
59
|
# save relations
|
|
60
60
|
for k, ids in m2ms.items():
|
|
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
|
|
File without changes
|