xn-model 1.0.15__tar.gz → 1.0.17__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.15
3
+ Version: 1.0.17
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -9,6 +9,13 @@ load_dotenv()
9
9
 
10
10
  PG_DSN = f"postgres://{env('POSTGRES_USER')}:{env('POSTGRES_PASSWORD')}@{env('POSTGRES_HOST', 'xyncdbs')}:{env('POSTGRES_PORT', 5432)}/{env('POSTGRES_DB', env('POSTGRES_USER'))}"
11
11
 
12
+ TORM = {
13
+ "connections": {"default": PG_DSN},
14
+ "apps": {"models": {"models": [models]}},
15
+ "use_tz": False,
16
+ "timezone": "UTC",
17
+ }
18
+
12
19
 
13
20
  def test_init_db():
14
- assert isinstance(run(init_db(PG_DSN, models)), AsyncpgDBClient), "DB corrupt"
21
+ assert isinstance(run(init_db(TORM)), AsyncpgDBClient), "DB corrupt"
@@ -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")
@@ -1,10 +1,10 @@
1
- from pypika.terms import AggregateFunction
1
+ from pypika_tortoise.terms import AggregateFunction, Field
2
2
  from tortoise.expressions import Function
3
3
 
4
4
 
5
5
  class ArrayAgg(AggregateFunction):
6
6
  def __init__(self, term, alias=None):
7
- super(ArrayAgg, self).__init__("array_agg", term, alias=alias)
7
+ super(ArrayAgg, self).__init__("array_agg", Field(term), alias=alias)
8
8
 
9
9
 
10
10
  class Array(Function):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-model
3
- Version: 1.0.15
3
+ Version: 1.0.17
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