maleo-database 0.0.22__tar.gz → 0.0.24__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.
Files changed (27) hide show
  1. {maleo_database-0.0.22 → maleo_database-0.0.24}/PKG-INFO +1 -1
  2. {maleo_database-0.0.22 → maleo_database-0.0.24}/maleo_database.egg-info/PKG-INFO +1 -1
  3. {maleo_database-0.0.22 → maleo_database-0.0.24}/maleo_database.egg-info/SOURCES.txt +1 -0
  4. {maleo_database-0.0.22 → maleo_database-0.0.24}/pyproject.toml +1 -1
  5. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/handlers.py +16 -9
  6. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/managers/__init__.py +15 -10
  7. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/orm/queries.py +12 -12
  8. maleo_database-0.0.24/src/types.py +5 -0
  9. {maleo_database-0.0.22 → maleo_database-0.0.24}/LICENSE +0 -0
  10. {maleo_database-0.0.22 → maleo_database-0.0.24}/README.md +0 -0
  11. {maleo_database-0.0.22 → maleo_database-0.0.24}/maleo_database.egg-info/dependency_links.txt +0 -0
  12. {maleo_database-0.0.22 → maleo_database-0.0.24}/maleo_database.egg-info/requires.txt +0 -0
  13. {maleo_database-0.0.22 → maleo_database-0.0.24}/maleo_database.egg-info/top_level.txt +0 -0
  14. {maleo_database-0.0.22 → maleo_database-0.0.24}/setup.cfg +0 -0
  15. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/__init__.py +0 -0
  16. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/config/__init__.py +0 -0
  17. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/config/additional.py +0 -0
  18. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/config/connection.py +0 -0
  19. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/config/identifier.py +0 -0
  20. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/config/pooling.py +0 -0
  21. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/dtos.py +0 -0
  22. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/enums.py +0 -0
  23. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/managers/client.py +0 -0
  24. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/managers/engine.py +0 -0
  25. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/managers/session.py +0 -0
  26. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/orm/__init__.py +0 -0
  27. {maleo_database-0.0.22 → maleo_database-0.0.24}/src/orm/mixins.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo-database
3
- Version: 0.0.22
3
+ Version: 0.0.24
4
4
  Summary: Database package for MaleoSuite
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: Proprietary
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo-database
3
- Version: 0.0.22
3
+ Version: 0.0.24
4
4
  Summary: Database package for MaleoSuite
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: Proprietary
@@ -10,6 +10,7 @@ src/__init__.py
10
10
  src/dtos.py
11
11
  src/enums.py
12
12
  src/handlers.py
13
+ src/types.py
13
14
  src/config/__init__.py
14
15
  src/config/additional.py
15
16
  src/config/connection.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo-database"
7
- version = "0.0.22"
7
+ version = "0.0.24"
8
8
  description = "Database package for MaleoSuite"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
@@ -1,5 +1,4 @@
1
1
  from pydantic import BaseModel, ConfigDict, Field
2
- from sqlalchemy.orm import DeclarativeBase
3
2
  from typing import Generic, Optional, TypeVar
4
3
  from .config import (
5
4
  ElasticsearchConfig,
@@ -21,6 +20,7 @@ from .managers import (
21
20
  SQLServerManager,
22
21
  ManagerT,
23
22
  )
23
+ from .types import DeclarativeBaseT
24
24
 
25
25
 
26
26
  class Handler(
@@ -51,22 +51,29 @@ class RedisHandler(Handler[RedisConfig, RedisManager]):
51
51
  pass
52
52
 
53
53
 
54
- T = TypeVar("T", bound=DeclarativeBase)
55
-
56
-
57
- class MySQLHandler(Handler[MySQLConfig, MySQLManager[T]], Generic[T]):
54
+ class MySQLHandler(
55
+ Handler[MySQLConfig, MySQLManager[DeclarativeBaseT]], Generic[DeclarativeBaseT]
56
+ ):
58
57
  pass
59
58
 
60
59
 
61
- class PostgreSQLHandler(Handler[PostgreSQLConfig, PostgreSQLManager[T]], Generic[T]):
60
+ class PostgreSQLHandler(
61
+ Handler[PostgreSQLConfig, PostgreSQLManager[DeclarativeBaseT]],
62
+ Generic[DeclarativeBaseT],
63
+ ):
62
64
  pass
63
65
 
64
66
 
65
- class SQLiteHandler(Handler[SQLiteConfig, SQLiteManager[T]], Generic[T]):
67
+ class SQLiteHandler(
68
+ Handler[SQLiteConfig, SQLiteManager[DeclarativeBaseT]], Generic[DeclarativeBaseT]
69
+ ):
66
70
  pass
67
71
 
68
72
 
69
- class SQLServerHandler(Handler[SQLServerConfig, SQLServerManager[T]], Generic[T]):
73
+ class SQLServerHandler(
74
+ Handler[SQLServerConfig, SQLServerManager[DeclarativeBaseT]],
75
+ Generic[DeclarativeBaseT],
76
+ ):
70
77
  pass
71
78
 
72
79
 
@@ -167,7 +174,7 @@ class Handlers(
167
174
  ],
168
175
  ):
169
176
  nosql: NoSQLHandlersT = Field(..., description="NoSQL handlers")
170
- sql: NoSQLHandlersT = Field(..., description="SQL handlers")
177
+ sql: SQLHandlersT = Field(..., description="SQL handlers")
171
178
 
172
179
 
173
180
  HandlersT = TypeVar("HandlersT", bound=Optional[Handlers])
@@ -6,7 +6,6 @@ from motor.motor_asyncio import AsyncIOMotorClient
6
6
  from pymongo import MongoClient
7
7
  from redis.asyncio import Redis as AsyncRedis
8
8
  from redis import Redis as SyncRedis
9
- from sqlalchemy.orm import DeclarativeBase
10
9
  from sqlalchemy import text
11
10
  from typing import Generic, Optional, Type, TypeVar
12
11
  from uuid import uuid4
@@ -44,6 +43,7 @@ from ..config import (
44
43
  ConfigT,
45
44
  )
46
45
  from ..enums import Connection
46
+ from ..types import DeclarativeBaseT
47
47
  from .client import (
48
48
  AsyncClientT,
49
49
  SyncClientT,
@@ -97,13 +97,10 @@ class Manager(ABC, Generic[ConfigT]):
97
97
  pass
98
98
 
99
99
 
100
- T = TypeVar("T", bound=DeclarativeBase)
101
-
102
-
103
- class SQLManager(Manager[SQLConfigT], Generic[SQLConfigT, T]):
100
+ class SQLManager(Manager[SQLConfigT], Generic[SQLConfigT, DeclarativeBaseT]):
104
101
  def __init__(
105
102
  self,
106
- Base: Type[T],
103
+ Base: Type[DeclarativeBaseT],
107
104
  config: SQLConfigT,
108
105
  logger: Database,
109
106
  service_context: Optional[ServiceContext] = None,
@@ -255,19 +252,27 @@ class SQLManager(Manager[SQLConfigT], Generic[SQLConfigT, T]):
255
252
  await self._engine_manager.dispose()
256
253
 
257
254
 
258
- class MySQLManager(SQLManager[MySQLConfig, T], Generic[T]):
255
+ class MySQLManager(
256
+ SQLManager[MySQLConfig, DeclarativeBaseT], Generic[DeclarativeBaseT]
257
+ ):
259
258
  pass
260
259
 
261
260
 
262
- class PostgreSQLManager(SQLManager[PostgreSQLConfig, T], Generic[T]):
261
+ class PostgreSQLManager(
262
+ SQLManager[PostgreSQLConfig, DeclarativeBaseT], Generic[DeclarativeBaseT]
263
+ ):
263
264
  pass
264
265
 
265
266
 
266
- class SQLiteManager(SQLManager[SQLiteConfig, T], Generic[T]):
267
+ class SQLiteManager(
268
+ SQLManager[SQLiteConfig, DeclarativeBaseT], Generic[DeclarativeBaseT]
269
+ ):
267
270
  pass
268
271
 
269
272
 
270
- class SQLServerManager(SQLManager[SQLServerConfig, T], Generic[T]):
273
+ class SQLServerManager(
274
+ SQLManager[SQLServerConfig, DeclarativeBaseT], Generic[DeclarativeBaseT]
275
+ ):
271
276
  pass
272
277
 
273
278
 
@@ -1,5 +1,5 @@
1
1
  from sqlalchemy import asc, cast, desc, or_, select
2
- from sqlalchemy.orm import DeclarativeBase, Session, aliased
2
+ from sqlalchemy.orm import Session, aliased
3
3
  from sqlalchemy.orm.attributes import InstrumentedAttribute
4
4
  from sqlalchemy.sql import Select
5
5
  from sqlalchemy.types import DATE, String, TEXT, TIMESTAMP
@@ -11,9 +11,9 @@ from maleo.types.base.boolean import OptionalBoolean
11
11
  from maleo.types.base.integer import OptionalListOfIntegers
12
12
  from maleo.types.base.string import OptionalListOfStrings, OptionalString
13
13
  from maleo.types.enums.status import OptionalListOfDataStatuses
14
+ from ..types import DeclarativeBaseT
14
15
 
15
16
 
16
- T = TypeVar("T", bound=DeclarativeBase)
17
17
  R = TypeVar(
18
18
  "R", bound=Tuple[Any, ...]
19
19
  ) # result shape inferred from Select (tuple[...])
@@ -21,7 +21,7 @@ R = TypeVar(
21
21
 
22
22
  def filter_column(
23
23
  stmt: Select[R],
24
- table: Type[T],
24
+ table: Type[DeclarativeBaseT],
25
25
  column: str,
26
26
  value: OptionalAny = None,
27
27
  include_null: bool = False,
@@ -44,7 +44,7 @@ def filter_column(
44
44
 
45
45
  def filter_ids(
46
46
  stmt: Select[R],
47
- table: Type[T],
47
+ table: Type[DeclarativeBaseT],
48
48
  column: str,
49
49
  ids: OptionalListOfIntegers = None,
50
50
  include_null: bool = False,
@@ -67,7 +67,7 @@ def filter_ids(
67
67
 
68
68
  def filter_timestamps(
69
69
  stmt: Select[R],
70
- table: Type[T],
70
+ table: Type[DeclarativeBaseT],
71
71
  date_filters: Sequence[DateFilter],
72
72
  ) -> Select[R]:
73
73
  if date_filters:
@@ -94,7 +94,7 @@ def filter_timestamps(
94
94
 
95
95
  def filter_statuses(
96
96
  stmt: Select[R],
97
- table: Type[T],
97
+ table: Type[DeclarativeBaseT],
98
98
  statuses: OptionalListOfDataStatuses,
99
99
  ) -> Select[R]:
100
100
  if statuses is not None:
@@ -105,7 +105,7 @@ def filter_statuses(
105
105
 
106
106
  def filter_is_root(
107
107
  stmt: Select[R],
108
- table: Type[T],
108
+ table: Type[DeclarativeBaseT],
109
109
  parent_column: str = "parent_id",
110
110
  is_root: OptionalBoolean = None,
111
111
  ) -> Select[R]:
@@ -122,7 +122,7 @@ def filter_is_root(
122
122
  def filter_is_parent(
123
123
  session: Session,
124
124
  stmt: Select[R],
125
- table: Type[T],
125
+ table: Type[DeclarativeBaseT],
126
126
  id_column: str = "id",
127
127
  parent_column: str = "parent_id",
128
128
  is_parent: OptionalBoolean = None,
@@ -143,7 +143,7 @@ def filter_is_parent(
143
143
 
144
144
  def filter_is_child(
145
145
  stmt: Select[R],
146
- table: Type[T],
146
+ table: Type[DeclarativeBaseT],
147
147
  parent_column: str = "parent_id",
148
148
  is_child: OptionalBoolean = None,
149
149
  ) -> Select[R]:
@@ -160,7 +160,7 @@ def filter_is_child(
160
160
  def filter_is_leaf(
161
161
  session: Session,
162
162
  stmt: Select[R],
163
- table: Type[T],
163
+ table: Type[DeclarativeBaseT],
164
164
  id_column: str = "id",
165
165
  parent_column: str = "parent_id",
166
166
  is_leaf: OptionalBoolean = None,
@@ -181,7 +181,7 @@ def filter_is_leaf(
181
181
 
182
182
  def search(
183
183
  stmt: Select[R],
184
- table: Type[T],
184
+ table: Type[DeclarativeBaseT],
185
185
  search: OptionalString = None,
186
186
  columns: OptionalListOfStrings = None,
187
187
  ) -> Select[R]:
@@ -215,7 +215,7 @@ def search(
215
215
 
216
216
  def sort(
217
217
  stmt: Select[R],
218
- table: Type[T],
218
+ table: Type[DeclarativeBaseT],
219
219
  sort_columns: Sequence[SortColumn],
220
220
  ) -> Select[R]:
221
221
  for sort_column in sort_columns:
@@ -0,0 +1,5 @@
1
+ from sqlalchemy.orm import DeclarativeBase
2
+ from typing import TypeVar
3
+
4
+
5
+ DeclarativeBaseT = TypeVar("DeclarativeBaseT", bound=DeclarativeBase)
File without changes