apexdevkit 1.23.8__tar.gz → 1.23.10__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.
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/PKG-INFO +1 -1
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/annotation/deprecate.py +1 -1
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/sql.py +40 -13
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/sqlite.py +27 -3
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/pyproject.toml +1 -1
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/LICENSE +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/README.md +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/date.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/environment.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/error.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/name.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/request.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/http/httpx/__init__.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/http/httpx/client.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/http/httpx/hooks.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/id.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/query/__init__.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/query/generator.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/query/query.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/decorator.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/mssql.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/repository/repository.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/server.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/synchronization.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/testing/rest.py +0 -0
- {apexdevkit-1.23.8 → apexdevkit-1.23.10}/apexdevkit/value.py +0 -0
|
@@ -23,7 +23,7 @@ def deprecated(warning: str) -> Callable[[F], F]:
|
|
|
23
23
|
|
|
24
24
|
def decorator(obj: F) -> F:
|
|
25
25
|
if inspect.isfunction(obj) or inspect.ismethod(obj):
|
|
26
|
-
return
|
|
26
|
+
return _wrap_function(obj, warning)
|
|
27
27
|
if inspect.isclass(obj):
|
|
28
28
|
return cast(F, _deprecate_class(obj, warning))
|
|
29
29
|
raise TypeError(
|
|
@@ -14,6 +14,7 @@ class NotNone:
|
|
|
14
14
|
class _SqlField:
|
|
15
15
|
name: str
|
|
16
16
|
is_id: bool = False
|
|
17
|
+
is_selectable: bool = False
|
|
17
18
|
is_composite: bool = False
|
|
18
19
|
include_in_insert: bool = True
|
|
19
20
|
include_in_update: bool = True
|
|
@@ -35,6 +36,7 @@ class _SqlField:
|
|
|
35
36
|
class SqlFieldBuilder:
|
|
36
37
|
_name: str = field(init=False)
|
|
37
38
|
_is_id: bool = False
|
|
39
|
+
_is_selectable: bool = False
|
|
38
40
|
_is_composite: bool = False
|
|
39
41
|
_include_in_insert: bool = True
|
|
40
42
|
_include_in_update: bool = True
|
|
@@ -61,6 +63,11 @@ class SqlFieldBuilder:
|
|
|
61
63
|
|
|
62
64
|
return self
|
|
63
65
|
|
|
66
|
+
def as_selectable(self) -> SqlFieldBuilder:
|
|
67
|
+
self._is_selectable = True
|
|
68
|
+
|
|
69
|
+
return self
|
|
70
|
+
|
|
64
71
|
def as_composite(self) -> SqlFieldBuilder:
|
|
65
72
|
self._is_composite = True
|
|
66
73
|
|
|
@@ -104,6 +111,7 @@ class SqlFieldBuilder:
|
|
|
104
111
|
return _SqlField(
|
|
105
112
|
name=self._name,
|
|
106
113
|
is_id=self._is_id,
|
|
114
|
+
is_selectable=self._is_selectable,
|
|
107
115
|
is_composite=self._is_composite,
|
|
108
116
|
include_in_insert=self._include_in_insert,
|
|
109
117
|
include_in_update=self._include_in_update,
|
|
@@ -194,21 +202,40 @@ class SqlFieldManager:
|
|
|
194
202
|
return ""
|
|
195
203
|
|
|
196
204
|
def _id_filter(self, include_id: bool, read_id: bool) -> str:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
)
|
|
208
|
-
if
|
|
209
|
-
else ""
|
|
205
|
+
if not include_id:
|
|
206
|
+
return ""
|
|
207
|
+
|
|
208
|
+
clauses = []
|
|
209
|
+
|
|
210
|
+
id_field = next((key for key in self.fields if key.is_id), None)
|
|
211
|
+
if id_field is None:
|
|
212
|
+
raise ValueError("Id field is required.")
|
|
213
|
+
|
|
214
|
+
value_expr = (
|
|
215
|
+
self.value_formatter.replace("x", id_field.name)
|
|
216
|
+
if not read_id or id_field.include_in_insert
|
|
217
|
+
else "SCOPE_IDENTITY()"
|
|
218
|
+
)
|
|
219
|
+
clauses.append(
|
|
220
|
+
f"{self.key_formatter.replace('x', id_field.name)} = {value_expr}"
|
|
210
221
|
)
|
|
211
222
|
|
|
223
|
+
if not read_id:
|
|
224
|
+
selectable_fields = [
|
|
225
|
+
selectable
|
|
226
|
+
for selectable in self.fields
|
|
227
|
+
if selectable.is_selectable and not selectable.is_id
|
|
228
|
+
]
|
|
229
|
+
for selectable in selectable_fields:
|
|
230
|
+
key_expr = self.key_formatter.replace("x", selectable.name)
|
|
231
|
+
val_expr = self.value_formatter.replace("x", id_field.name)
|
|
232
|
+
clauses.append(f"{key_expr} = {val_expr}")
|
|
233
|
+
|
|
234
|
+
if len(clauses) == 1:
|
|
235
|
+
return clauses[0]
|
|
236
|
+
|
|
237
|
+
return "(" + " OR ".join(clauses) + ")"
|
|
238
|
+
|
|
212
239
|
def _general_filters(self) -> str:
|
|
213
240
|
statements: list[str] = [] + self.custom_filters
|
|
214
241
|
for key in self.fields:
|
|
@@ -105,14 +105,25 @@ class SqliteTableBuilder(Generic[ItemT]):
|
|
|
105
105
|
table_name: str | None = None
|
|
106
106
|
formatter: Formatter[Mapping[str, Any], ItemT] | None = None
|
|
107
107
|
fields: list[_SqlField] | None = None
|
|
108
|
+
custom_filters: list[str] | None = None
|
|
108
109
|
|
|
109
110
|
def with_name(self, value: str) -> SqliteTableBuilder[ItemT]:
|
|
110
|
-
return SqliteTableBuilder[ItemT](
|
|
111
|
+
return SqliteTableBuilder[ItemT](
|
|
112
|
+
value,
|
|
113
|
+
self.formatter,
|
|
114
|
+
self.fields,
|
|
115
|
+
self.custom_filters,
|
|
116
|
+
)
|
|
111
117
|
|
|
112
118
|
def with_formatter(
|
|
113
119
|
self, value: Formatter[Mapping[str, Any], ItemT]
|
|
114
120
|
) -> SqliteTableBuilder[ItemT]:
|
|
115
|
-
return SqliteTableBuilder[ItemT](
|
|
121
|
+
return SqliteTableBuilder[ItemT](
|
|
122
|
+
self.table_name,
|
|
123
|
+
value,
|
|
124
|
+
self.fields,
|
|
125
|
+
self.custom_filters,
|
|
126
|
+
)
|
|
116
127
|
|
|
117
128
|
def with_fields(self, value: Iterable[_SqlField]) -> SqliteTableBuilder[ItemT]:
|
|
118
129
|
key_list = list(value)
|
|
@@ -135,16 +146,29 @@ class SqliteTableBuilder(Generic[ItemT]):
|
|
|
135
146
|
self.table_name,
|
|
136
147
|
self.formatter,
|
|
137
148
|
key_list,
|
|
149
|
+
self.custom_filters,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
def with_custom_filters(self, filters: Iterable[str]) -> SqliteTableBuilder[ItemT]:
|
|
153
|
+
return SqliteTableBuilder[ItemT](
|
|
154
|
+
self.table_name,
|
|
155
|
+
self.formatter,
|
|
156
|
+
self.fields,
|
|
157
|
+
list(filters),
|
|
138
158
|
)
|
|
139
159
|
|
|
140
160
|
def build(self) -> SqlTable[ItemT]:
|
|
141
161
|
if not self.table_name or not self.formatter or not self.fields:
|
|
142
162
|
raise ValueError("Parameter missing.")
|
|
143
163
|
|
|
164
|
+
field_manager = SqlFieldManager.Builder().with_fields(self.fields)
|
|
165
|
+
if self.custom_filters and len(self.custom_filters) > 0:
|
|
166
|
+
field_manager = field_manager.with_custom_filters(self.custom_filters)
|
|
167
|
+
|
|
144
168
|
return _DefaultSqlTable(
|
|
145
169
|
self.table_name,
|
|
146
170
|
self.formatter,
|
|
147
|
-
|
|
171
|
+
field_manager.for_sqlite().build(),
|
|
148
172
|
)
|
|
149
173
|
|
|
150
174
|
|
|
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
|
|
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
|