apexdevkit 1.8.7__tar.gz → 1.8.8__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.8.7 → apexdevkit-1.8.8}/PKG-INFO +1 -1
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/repository/sqlite.py +11 -3
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/pyproject.toml +1 -1
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/LICENSE +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/README.md +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/error.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.8.7 → apexdevkit-1.8.8}/apexdevkit/testing/rest.py +0 -0
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from sqlite3 import IntegrityError
|
|
5
|
-
from typing import Any,
|
|
5
|
+
from typing import Any, Generic, Iterator, TypeVar
|
|
6
6
|
|
|
7
7
|
from apexdevkit.error import DoesNotExistError, ExistsError
|
|
8
8
|
from apexdevkit.repository import Database, DatabaseCommand
|
|
@@ -14,7 +14,6 @@ ItemT = TypeVar("ItemT")
|
|
|
14
14
|
class SqliteRepository(Generic[ItemT]):
|
|
15
15
|
db: Database
|
|
16
16
|
table: SqlTable[ItemT]
|
|
17
|
-
duplicate_criteria: Callable[[ItemT], str] = lambda i: "Unknown"
|
|
18
17
|
|
|
19
18
|
def __iter__(self) -> Iterator[ItemT]:
|
|
20
19
|
for raw in self.db.execute(self.table.select_all()).fetch_all():
|
|
@@ -32,7 +31,10 @@ class SqliteRepository(Generic[ItemT]):
|
|
|
32
31
|
try:
|
|
33
32
|
return self.table.load(self.db.execute(self.table.insert(item)).fetch_one())
|
|
34
33
|
except IntegrityError: # pragma: no cover
|
|
35
|
-
|
|
34
|
+
item = self.table.load(
|
|
35
|
+
self.db.execute(self.table.select_duplicate(item)).fetch_one()
|
|
36
|
+
)
|
|
37
|
+
self.table.duplicate(item).fire()
|
|
36
38
|
return item
|
|
37
39
|
|
|
38
40
|
def create_many(self, items: list[ItemT]) -> list[ItemT]:
|
|
@@ -70,6 +72,9 @@ class SqlTable(Generic[ItemT]): # pragma: no cover
|
|
|
70
72
|
def select(self, item_id: str) -> DatabaseCommand:
|
|
71
73
|
raise NotImplementedError("Not implemented")
|
|
72
74
|
|
|
75
|
+
def select_duplicate(self, item: ItemT) -> DatabaseCommand:
|
|
76
|
+
raise NotImplementedError("Not implemented")
|
|
77
|
+
|
|
73
78
|
def select_all(self) -> DatabaseCommand:
|
|
74
79
|
raise NotImplementedError("Not implemented")
|
|
75
80
|
|
|
@@ -85,6 +90,9 @@ class SqlTable(Generic[ItemT]): # pragma: no cover
|
|
|
85
90
|
def load(self, data: dict[str, Any]) -> ItemT:
|
|
86
91
|
raise NotImplementedError("Not implemented")
|
|
87
92
|
|
|
93
|
+
def duplicate(self, item: ItemT) -> ExistsError:
|
|
94
|
+
return ExistsError(item).with_duplicate(lambda i: "Unknown")
|
|
95
|
+
|
|
88
96
|
|
|
89
97
|
@dataclass
|
|
90
98
|
class UnknownError(Exception):
|
|
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
|