python-general-be-lib 0.5.4__py3-none-any.whl → 0.5.5__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.
@@ -5,8 +5,9 @@ from typing import Optional, Any, Type, Iterable, Sequence
5
5
 
6
6
  from pydantic import BaseModel
7
7
  from sqlalchemy import MetaData, Engine, Column, Table, inspect, Connection, select, RowMapping, CursorResult, not_
8
+ from sqlalchemy.exc import NoSuchTableError
8
9
 
9
- from ...exception.crud_exceptions import HasNoAttributeException
10
+ from ...exception.crud_exceptions import HasNoAttributeException, InternalServerException
10
11
 
11
12
 
12
13
  class CrudMetadata:
@@ -158,7 +159,10 @@ class CrudMetadata:
158
159
  def get_table(self, name: str) -> Optional[Table]:
159
160
  table = self._get_table(name=name)
160
161
  if table is None:
161
- table = Table(name, self.metadata, schema=self.schema, autoload_with=self.engine)
162
+ try:
163
+ table = Table(name, self.metadata, schema=self.schema, autoload_with=self.engine)
164
+ except NoSuchTableError:
165
+ raise InternalServerException(f"No such table {name}")
162
166
  return table
163
167
 
164
168
  def has_table(self, name: str):
@@ -509,7 +509,8 @@ class CrudRepository[Entity: Base | Type[Base]]:
509
509
  """
510
510
  pk = self.entity.primary_key()[0]
511
511
  stmt = select(count(pk))
512
- stmt = stmt.where(where)
512
+ if where is not None:
513
+ stmt = stmt.where(where)
513
514
  result = session.execute(stmt).all()[0]
514
515
  return result[0]
515
516
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-general-be-lib
3
- Version: 0.5.4
3
+ Version: 0.5.5
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
@@ -10,10 +10,10 @@ general/interface/base/__init__.py,sha256=SDlTi28M8rzJ9yiKefo5l7V3K109LnnBHW-SuZ
10
10
  general/interface/base/base_model.py,sha256=SVrYl1kSAj37yCScfO3Qe6ELyLxou65njpvbYmjTG00,2215
11
11
  general/interface/base/declarative_base.py,sha256=5hw2VpJHHebjixuI3d4wpkyAentGBGN54QXcniaoJ-A,5236
12
12
  general/interface/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- general/interface/metadata/crud_metadata.py,sha256=z1fTh77K7fkhDgNus5Xrv4EYerbdlPVl4F1NLbSxqcM,8478
13
+ general/interface/metadata/crud_metadata.py,sha256=qZLYakASWkA9120HA4n4-9EOb8ZbkIpNip96jwdmjNU,8676
14
14
  general/interface/metadata/geom_metadata.py,sha256=CZPzlqos5XuDWn_FeKLxxYqOuGx1Bg9C0xH5-ZR0vXw,5326
15
15
  general/interface/repository/__init__.py,sha256=EcRukwf61Ua-9-JfM_ingVv1wXNRV8HBrrWwjj8m23w,136
16
- general/interface/repository/crud_repository.py,sha256=wFO_OhyDDh_KxzQbO0QjACLacF83SMdbsOD2MJa6510,29210
16
+ general/interface/repository/crud_repository.py,sha256=HFWFDaHqcCbI1Ks4gTRDrbG4ih43id4lDIrxWuvx01E,29244
17
17
  general/interface/repository/geometry_repository.py,sha256=bJVPhsr-fGhVTywdHwx9Qt_inWPHk5wqq9EFWFLfuGU,11181
18
18
  general/interface/repository/many_to_many_repository.py,sha256=iEhWyD8nPZSAPL8Z2wXrK-aRBnoh3evaSN-voaf0EP0,8662
19
19
  general/interface/repository/view_repository.py,sha256=Sm591FUP0iBYlI-ULNWszD5fOvTGwXX0iYoeDbUqo34,5397
@@ -24,8 +24,8 @@ general/interface/repository/handler/interval_handler.py,sha256=XxMQr6UuWnoCtbOO
24
24
  general/interface/repository/handler/json_handler.py,sha256=7bS59seB-It5KHsWXTbHGsEvbQZ6lYyvX-d29BcRLVE,2956
25
25
  general/interface/repository/handler/json_ilike_handler.py,sha256=yDuKER3yqtnHpVWndF8PVEaqDThcq1EhZzLaqxbQ0bU,4491
26
26
  general/interface/repository/handler/statement_manager.py,sha256=sGDMU4fPkF0_9-SbDmAw8Vpel1Z7eImBs8fHO-5Lr_0,4429
27
- python_general_be_lib-0.5.4.dist-info/licenses/LICENSE,sha256=iUaO1XZyB9P3Tmog0OILuTisP6vXGe3QKz-4yRTxOFk,1069
28
- python_general_be_lib-0.5.4.dist-info/METADATA,sha256=oOe-yd6hkXQ1wumjhGiEO90OI7bRcZRJw0UlamThdaU,1384
29
- python_general_be_lib-0.5.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- python_general_be_lib-0.5.4.dist-info/top_level.txt,sha256=tTZePW8_CNUqSgKFd2SEH72ZbnhS0OYjRsgcv0ikSFY,8
31
- python_general_be_lib-0.5.4.dist-info/RECORD,,
27
+ python_general_be_lib-0.5.5.dist-info/licenses/LICENSE,sha256=iUaO1XZyB9P3Tmog0OILuTisP6vXGe3QKz-4yRTxOFk,1069
28
+ python_general_be_lib-0.5.5.dist-info/METADATA,sha256=tlgM7YpM6ii5vsqSp59qp3Bx3VqTkNxSBb0iqgBnoPI,1384
29
+ python_general_be_lib-0.5.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ python_general_be_lib-0.5.5.dist-info/top_level.txt,sha256=tTZePW8_CNUqSgKFd2SEH72ZbnhS0OYjRsgcv0ikSFY,8
31
+ python_general_be_lib-0.5.5.dist-info/RECORD,,