xn-model 1.0.14__tar.gz → 1.0.15__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.14
3
+ Version: 1.0.15
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -52,17 +52,17 @@ class Model(TortModel):
52
52
  # fields.append(fld)
53
53
 
54
54
  dcl = make_dataclass(cls.__name__ + cn, fields, bases=(BaseUpd,), kw_only=True)
55
- dcl._unq = (cls._meta.unique_together or ((),))[0]
55
+ dcl._unq = set((cls._meta.unique_together or ((),))[0])
56
56
  if with_pk:
57
- dcl._unq += ("id",)
57
+ dcl._unq |= {"id"}
58
58
  setattr(cls, cn, dcl)
59
59
 
60
60
  return getattr(cls, cn)
61
61
 
62
62
  # # # CRUD Methods # # #
63
63
  @classmethod
64
- def validate(cls, dct: dict) -> BaseUpd:
65
- dcl = cls.in_type("id" in dct)
64
+ def validate(cls, dct: dict, with_pk: bool = None) -> BaseUpd:
65
+ dcl = cls.in_type("id" in dct if with_pk is None else with_pk)
66
66
  field_names = [n.name for n in fields(dcl)]
67
67
  return dcl(**{k: v for k, v in dct.items() if k in field_names})
68
68
 
@@ -4,7 +4,7 @@ from typing import ClassVar
4
4
 
5
5
  @dataclass
6
6
  class BaseUpd:
7
- _unq: ClassVar[tuple[str]]
7
+ _unq: ClassVar[set[str]]
8
8
 
9
9
  def df_unq(self) -> dict:
10
10
  d = {k: v for k, v in asdict(self).items() if v is not None or k in self._unq}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-model
3
- Version: 1.0.14
3
+ Version: 1.0.15
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