python-general-be-lib 0.2.0__py3-none-any.whl → 0.3.0__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.
@@ -1,3 +1,4 @@
1
1
  from .base_handler import *
2
2
  from .ilike_handler import *
3
3
  from .interval_handler import *
4
+ from .json_handler import *
@@ -0,0 +1,25 @@
1
+ __all__ = ["JsonHandler"]
2
+
3
+ from typing import Any
4
+
5
+ from sqlalchemy import Column, Select, Update, Delete
6
+ from sqlalchemy.sql.base import ReadOnlyColumnCollection
7
+
8
+ from .base_handler import BaseHandler
9
+
10
+
11
+ class JsonHandler(BaseHandler):
12
+ __slots__ = "json_column"
13
+ json_column: str
14
+
15
+ def __init__(self, columns: ReadOnlyColumnCollection[str, Column[Any]]):
16
+ self.columns = columns
17
+ self.json_column = {key for key, column in columns.items() if column.type.python_type == dict}.pop()
18
+
19
+ def prepare_statement(self, stmt: Select | Update | Delete, **where):
20
+ json_keys = {key for key in where.keys() if key not in self.columns}
21
+ json_conditions = {key: where.pop(key) for key in json_keys}
22
+
23
+ stmt = super().prepare_statement(stmt=stmt, **where)
24
+ stmt = stmt.where(*[self.columns[self.json_column][key].as_string() == str(value) for key, value in json_conditions.items()])
25
+ return stmt
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-general-be-lib
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: General purpose backend library — SQLAlchemy CRUD/Geometry repositories, FastAPI exceptions, Pydantic base models, logger utilities.
5
5
  Author-email: Andrea Di Placido <a.diplacido@arpes.it>, "Arpes S.r.l." <it.admin@arpes.it>
6
6
  License: MIT
@@ -17,12 +17,13 @@ general/interface/repository/crud_repository.py,sha256=OR0mlVnoUvRDuxTwvNTEHvmUf
17
17
  general/interface/repository/geometry_repository.py,sha256=Rfmmzlt_U5iai0syS28jMxFpgfsJLO2im0AAiphXwXg,5756
18
18
  general/interface/repository/many_to_many_repository.py,sha256=znvKMww6HED96dJVIB2ApPRjPK-9ifY5cbRvamYiTik,4399
19
19
  general/interface/repository/view_repository.py,sha256=amohSpucY20R6IE5ZSi1OpgzkLostZKxfI56eJOP4NY,2482
20
- general/interface/repository/handler/__init__.py,sha256=F7xWahG0ANb1RxlUqfiicvgGy91PYJwf4w9mKvNHSRc,89
20
+ general/interface/repository/handler/__init__.py,sha256=PDRZrSEVNJScJdSrFKJIr1PNaOLZoGddrnIJKt5DyC4,117
21
21
  general/interface/repository/handler/base_handler.py,sha256=hGbkHmCPirbWqVXBvWb7-97bVKpZpI602__ClF407mM,1559
22
22
  general/interface/repository/handler/ilike_handler.py,sha256=dDXSsQR7cROh5azT3lt6zOTvNiD_r17_19NE1EQwOrE,1471
23
23
  general/interface/repository/handler/interval_handler.py,sha256=CuZYX8hLOrglQIme5UrUC8Hd8cfGk3zjQx6V_FpbNMs,1204
24
- python_general_be_lib-0.2.0.dist-info/licenses/LICENSE,sha256=iUaO1XZyB9P3Tmog0OILuTisP6vXGe3QKz-4yRTxOFk,1069
25
- python_general_be_lib-0.2.0.dist-info/METADATA,sha256=3_OOVLhRh11rm5t8b6fmbWrkbMqiWSYzsqrydcN2fW4,1384
26
- python_general_be_lib-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- python_general_be_lib-0.2.0.dist-info/top_level.txt,sha256=tTZePW8_CNUqSgKFd2SEH72ZbnhS0OYjRsgcv0ikSFY,8
28
- python_general_be_lib-0.2.0.dist-info/RECORD,,
24
+ general/interface/repository/handler/json_handler.py,sha256=SWx3PGffQm_N4VWa3DOLkRKZxq7ztNJ8op5W3fYJuMw,941
25
+ python_general_be_lib-0.3.0.dist-info/licenses/LICENSE,sha256=iUaO1XZyB9P3Tmog0OILuTisP6vXGe3QKz-4yRTxOFk,1069
26
+ python_general_be_lib-0.3.0.dist-info/METADATA,sha256=mls2tfN8_i2qL1Sy68Xetyr5WVRqunKlVFS6owfKHPk,1384
27
+ python_general_be_lib-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
+ python_general_be_lib-0.3.0.dist-info/top_level.txt,sha256=tTZePW8_CNUqSgKFd2SEH72ZbnhS0OYjRsgcv0ikSFY,8
29
+ python_general_be_lib-0.3.0.dist-info/RECORD,,