sqlphilosophy 0.1.3__tar.gz → 0.1.6__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.
Potentially problematic release.
This version of sqlphilosophy might be problematic. Click here for more details.
- {sqlphilosophy-0.1.3/src/sqlphilosophy.egg-info → sqlphilosophy-0.1.6}/PKG-INFO +1 -1
- sqlphilosophy-0.1.6/src/sqlphilosophy/VERSION +1 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/sql.py +33 -4
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/sync/repository.py +5 -8
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6/src/sqlphilosophy.egg-info}/PKG-INFO +1 -1
- sqlphilosophy-0.1.3/src/sqlphilosophy/VERSION +0 -1
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/LICENSE +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/MANIFEST.in +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/README.md +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/pyproject.toml +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/setup.cfg +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/__init__.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/aio/__init__.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/aio/protocols.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/aio/query.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/aio/repository.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/audit/__init__.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/audit/context.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/audit/fields.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/audit/listener.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/audit/model.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/py.typed +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/sorting.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/sync/__init__.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/sync/protocols.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/sync/query.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy/types.py +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy.egg-info/SOURCES.txt +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy.egg-info/dependency_links.txt +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy.egg-info/requires.txt +0 -0
- {sqlphilosophy-0.1.3 → sqlphilosophy-0.1.6}/src/sqlphilosophy.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlphilosophy
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Portable SQLAlchemy repository kit: sync and async CRUD, statement builders, sort/pagination, and SQL helpers.
|
|
5
5
|
Author-email: Josh Martin <denverprogrammer@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.6
|
|
@@ -17,6 +17,7 @@ from sqlalchemy import desc
|
|
|
17
17
|
from sqlalchemy import func
|
|
18
18
|
from sqlalchemy import inspect as sa_inspect
|
|
19
19
|
from sqlalchemy import literal_column
|
|
20
|
+
from sqlalchemy.exc import NoInspectionAvailable
|
|
20
21
|
from sqlalchemy import select
|
|
21
22
|
from sqlalchemy import update
|
|
22
23
|
from sqlalchemy.orm import DeclarativeBase
|
|
@@ -42,6 +43,21 @@ from sqlphilosophy.types import SqlTable
|
|
|
42
43
|
_ModelT = TypeVar("_ModelT", bound=DeclarativeBase)
|
|
43
44
|
|
|
44
45
|
|
|
46
|
+
def _mapped_model_class_for(value: object) -> type[DeclarativeBase] | None:
|
|
47
|
+
candidate: object = value if isinstance(value, type) else value.__class__
|
|
48
|
+
|
|
49
|
+
if not isinstance(candidate, type):
|
|
50
|
+
return None
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
sa_inspect(candidate)
|
|
54
|
+
except NoInspectionAvailable:
|
|
55
|
+
if not hasattr(candidate, "__mapper__"):
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
return cast(type[DeclarativeBase], candidate)
|
|
59
|
+
|
|
60
|
+
|
|
45
61
|
def sql_table(table_name: str, *column_names: str) -> SqlTable:
|
|
46
62
|
"""Lightweight Core table — prefer ORM models unless you need Core performance."""
|
|
47
63
|
return table(table_name, *[column(c) for c in column_names])
|
|
@@ -49,10 +65,23 @@ def sql_table(table_name: str, *column_names: str) -> SqlTable:
|
|
|
49
65
|
|
|
50
66
|
def get_column_value(entity: object) -> ApiObject:
|
|
51
67
|
"""Return mapped column values for an ORM entity instance."""
|
|
52
|
-
|
|
53
|
-
if
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
instance_state = sa_inspect(entity, raiseerr=False)
|
|
69
|
+
if instance_state is not None and hasattr(instance_state, "mapper"):
|
|
70
|
+
mapper = instance_state.mapper
|
|
71
|
+
else:
|
|
72
|
+
from sqlphilosophy.sync.repository import BaseRepository
|
|
73
|
+
|
|
74
|
+
model_cls = _mapped_model_class_for(entity)
|
|
75
|
+
if model_cls is None:
|
|
76
|
+
raise TypeError(f"{type(entity)!r} is not a mapped SQLAlchemy entity")
|
|
77
|
+
try:
|
|
78
|
+
insp = BaseRepository.inspect_model(model_cls)
|
|
79
|
+
except Exception as exc:
|
|
80
|
+
raise TypeError(f"{type(entity)!r} is not a mapped SQLAlchemy entity") from exc
|
|
81
|
+
if not hasattr(insp, "mapper"):
|
|
82
|
+
raise TypeError(f"{type(entity)!r} is not a mapped SQLAlchemy entity")
|
|
83
|
+
mapper = insp.mapper
|
|
84
|
+
return {attr.key: getattr(entity, attr.key) for attr in mapper.column_attrs}
|
|
56
85
|
|
|
57
86
|
|
|
58
87
|
def row_mapping(row: object) -> RowMapping:
|
|
@@ -14,7 +14,6 @@ from sqlalchemy.orm import Session
|
|
|
14
14
|
from sqlalchemy.orm.interfaces import LoaderOption
|
|
15
15
|
from sqlphilosophy.sorting import ListQuery
|
|
16
16
|
from sqlphilosophy.sorting import SortConfig
|
|
17
|
-
from sqlphilosophy.sql import apply_mappings_page
|
|
18
17
|
from sqlphilosophy.sql import delete_by_ids_model
|
|
19
18
|
from sqlphilosophy.sql import partial_update_model
|
|
20
19
|
from sqlphilosophy.sql import rows_mapping
|
|
@@ -114,13 +113,11 @@ class BaseRepository[T: DeclarativeBase]:
|
|
|
114
113
|
params: RowMapping | None = None,
|
|
115
114
|
) -> list[RowMapping]:
|
|
116
115
|
"""Execute ``stmt`` with limit/offset; return normalized row mappings."""
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
params=params,
|
|
123
|
-
)
|
|
116
|
+
if limit < 0:
|
|
117
|
+
raise ValueError("limit must be >= 0")
|
|
118
|
+
if offset < 0:
|
|
119
|
+
raise ValueError("offset must be >= 0")
|
|
120
|
+
return self.fetch_statement_mappings(stmt.limit(limit).offset(offset), params)
|
|
124
121
|
|
|
125
122
|
def fetch_sorted_mappings(
|
|
126
123
|
self,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlphilosophy
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Portable SQLAlchemy repository kit: sync and async CRUD, statement builders, sort/pagination, and SQL helpers.
|
|
5
5
|
Author-email: Josh Martin <denverprogrammer@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.1.3
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|