xn-model 1.0.16__py3-none-any.whl → 1.0.18__py3-none-any.whl

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.
x_model/__init__.py CHANGED
@@ -1,11 +1,9 @@
1
- from types import ModuleType
2
-
3
1
  from tortoise import Tortoise, connections
4
2
  from tortoise.backends.asyncpg import AsyncpgDBClient
5
3
 
6
4
 
7
- async def init_db(dsn: str, models: ModuleType, create_tables: bool = True) -> AsyncpgDBClient | str:
8
- await Tortoise.init(db_url=dsn, modules={"models": [models]})
5
+ async def init_db(conf: dict, create_tables: bool = True) -> AsyncpgDBClient | str:
6
+ await Tortoise.init(conf)
9
7
  if create_tables:
10
8
  await Tortoise.generate_schemas()
11
9
  cn: AsyncpgDBClient = connections.get("default")
x_model/models.py CHANGED
@@ -52,7 +52,8 @@ 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 = set((cls._meta.unique_together or ((),))[0])
55
+ dcl._unq = {o + "_id" for o in cls._meta.o2o_fields}
56
+ dcl._unq |= set((cls._meta.unique_together or ((),))[0])
56
57
  if with_pk:
57
58
  dcl._unq |= {"id"}
58
59
  setattr(cls, cn, dcl)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-model
3
- Version: 1.0.16
3
+ Version: 1.0.18
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -0,0 +1,9 @@
1
+ x_model/__init__.py,sha256=1Lgvr-SZwkM4R7L0ceVLyArzzMJiFLgaid-RUOk_ypM,344
2
+ x_model/field.py,sha256=zVszcPZFVEwsurqbFQF-_caiSLruh3TRSZdgQqwWJV8,2776
3
+ x_model/func.py,sha256=flj89sCOou7NJlriPYbIpX8rdbugbe-vjT2C0ORl9DY,312
4
+ x_model/models.py,sha256=8k1GqdYSQ1h1VLcLqQVa4kVoz6XHrZR5xxOIwCgyisQ,3668
5
+ x_model/types.py,sha256=iES9Oxj45hEBB1tvZlNAOM4eS7w3Y8iC37X7FmcEwe4,318
6
+ xn_model-1.0.18.dist-info/METADATA,sha256=3ZoZZdb4BxOpbQuk93f6toQcq81jK3sGO6jddVJbPqA,986
7
+ xn_model-1.0.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ xn_model-1.0.18.dist-info/top_level.txt,sha256=QCYyfv5AA_8jPPtCpShkBXzQRUCGuuW7Ro0mqysDE8E,8
9
+ xn_model-1.0.18.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- x_model/__init__.py,sha256=JRsYD3P-8pHpEkCUgy6GuodkT7ZaY1AEeEK1CbpgZw4,428
2
- x_model/field.py,sha256=zVszcPZFVEwsurqbFQF-_caiSLruh3TRSZdgQqwWJV8,2776
3
- x_model/func.py,sha256=flj89sCOou7NJlriPYbIpX8rdbugbe-vjT2C0ORl9DY,312
4
- x_model/models.py,sha256=IMql5xfU1dw7n1uYba5pXQnsK7_1pzLTScGRWYUW2NA,3602
5
- x_model/types.py,sha256=iES9Oxj45hEBB1tvZlNAOM4eS7w3Y8iC37X7FmcEwe4,318
6
- xn_model-1.0.16.dist-info/METADATA,sha256=XD9qURCotfDXy2ry3iAFNYaqLSjQwiG28wzlrlj1v7U,986
7
- xn_model-1.0.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- xn_model-1.0.16.dist-info/top_level.txt,sha256=QCYyfv5AA_8jPPtCpShkBXzQRUCGuuW7Ro0mqysDE8E,8
9
- xn_model-1.0.16.dist-info/RECORD,,