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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xn-model
3
- Version: 0.10.4
3
+ Version: 0.11.0
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -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, **{meta.pk_attr: oid}))[0] if oid else await cls.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():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xn-model
3
- Version: 0.10.4
3
+ Version: 0.11.0
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
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