xn-model 1.0.18__tar.gz → 1.0.19__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.4
2
2
  Name: xn-model
3
- Version: 1.0.18
3
+ Version: 1.0.19
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -5,6 +5,7 @@ from typing import Self
5
5
  from pydantic import ConfigDict
6
6
  from tortoise import Model as TortModel
7
7
  from tortoise.fields import IntField
8
+ from tortoise.signals import Signals
8
9
 
9
10
  from x_model.field import DatetimeSecField
10
11
  from x_model.types import BaseUpd
@@ -50,9 +51,9 @@ class Model(TortModel):
50
51
  # if f.default or f.allows_generated or f.null or not f.required:
51
52
  # fld += (field(default=f.default),)
52
53
  # fields.append(fld)
53
-
54
+ pre_saves = [f.__name__ for f in cls._listeners[Signals.pre_save].get(cls, [])]
54
55
  dcl = make_dataclass(cls.__name__ + cn, fields, bases=(BaseUpd,), kw_only=True)
55
- dcl._unq = {o + "_id" for o in cls._meta.o2o_fields}
56
+ dcl._unq = {o + "_id" for o in cls._meta.o2o_fields if o not in pre_saves}
56
57
  dcl._unq |= set((cls._meta.unique_together or ((),))[0])
57
58
  if with_pk:
58
59
  dcl._unq |= {"id"}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-model
3
- Version: 1.0.18
3
+ Version: 1.0.19
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