statikk 0.1.25__tar.gz → 0.1.27__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.
- {statikk-0.1.25 → statikk-0.1.27}/PKG-INFO +1 -1
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk/engine.py +14 -1
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk/models.py +3 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk.egg-info/PKG-INFO +1 -1
- {statikk-0.1.25 → statikk-0.1.27}/tests/test_engine.py +1 -1
- {statikk-0.1.25 → statikk-0.1.27}/.coveragerc +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/.gitignore +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/.readthedocs.yml +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/AUTHORS.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/CHANGELOG.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/CONTRIBUTING.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/LICENSE.txt +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/README.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/assets/favicon.png +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/assets/logo.png +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/Makefile +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/_static/.gitignore +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/authors.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/changelog.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/conf.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/contributing.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/index.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/license.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/readme.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/requirements.txt +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/docs/usage.rst +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/pyproject.toml +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/setup.cfg +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/setup.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk/__init__.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk/conditions.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk/expressions.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk/fields.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk/typing.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk.egg-info/SOURCES.txt +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk.egg-info/dependency_links.txt +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk.egg-info/not-zip-safe +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk.egg-info/requires.txt +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/src/statikk.egg-info/top_level.txt +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/tests/conftest.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/tests/test_expressions.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/tests/test_models.py +0 -0
- {statikk-0.1.25 → statikk-0.1.27}/tox.ini +0 -0
@@ -209,6 +209,19 @@ class Table:
|
|
209
209
|
data[key] = self._deserialize_value(value, model_class.model_fields[key])
|
210
210
|
return model_class(**data)
|
211
211
|
|
212
|
+
def delete_hierarchy(self, model: DatabaseModel):
|
213
|
+
"""
|
214
|
+
Deletes an item and all its children from the database by id, using the partition key of the table.
|
215
|
+
:param id: The id of the item to delete.
|
216
|
+
"""
|
217
|
+
with self.batch_write() as batch:
|
218
|
+
for key in model._db_snapshot_keys | self._create_snapshot_representation(model):
|
219
|
+
hash_key, sort_key = key.split("#", 1)
|
220
|
+
delete_params = {self.key_schema.hash_key: hash_key}
|
221
|
+
if sort_key:
|
222
|
+
delete_params[self.key_schema.sort_key] = sort_key
|
223
|
+
batch.delete_by_key(delete_params)
|
224
|
+
|
212
225
|
def delete_item(self, model: DatabaseModel):
|
213
226
|
"""
|
214
227
|
Deletes an item from the database by id, using the partition key of the table.
|
@@ -629,7 +642,7 @@ class Table:
|
|
629
642
|
def _perform_batch_write(
|
630
643
|
self, put_items: List[DatabaseModel], delete_items: List[DatabaseModel], delete_keys: list[dict[str, Any]]
|
631
644
|
):
|
632
|
-
if len(put_items) == 0 and len(delete_items) == 0:
|
645
|
+
if len(put_items) == 0 and len(delete_items) == 0 and (len(delete_keys) == 0):
|
633
646
|
return
|
634
647
|
|
635
648
|
dynamodb_table = self._get_dynamodb_table()
|
@@ -256,6 +256,9 @@ class DatabaseModel(BaseModel, TrackingMixin):
|
|
256
256
|
def delete(self):
|
257
257
|
return self._table.delete_item(self)
|
258
258
|
|
259
|
+
def delete_hierarchy(self):
|
260
|
+
return self._table.delete_hierarchy(self)
|
261
|
+
|
259
262
|
def update(self, sort_key: Optional[str] = None) -> DatabaseModelUpdateExpressionBuilder:
|
260
263
|
return DatabaseModelUpdateExpressionBuilder(self, sort_key)
|
261
264
|
|
@@ -894,7 +894,7 @@ def test_nested_hierarchies():
|
|
894
894
|
hierarchy.save()
|
895
895
|
hierarchy = ModelHierarchy.query_hierarchy(hash_key=Equals("foo_id"))
|
896
896
|
assert len(hierarchy.nested.doubly_nested[0].items) == 0
|
897
|
-
hierarchy.
|
897
|
+
hierarchy.delete_hierarchy()
|
898
898
|
assert list(table.scan()) == []
|
899
899
|
|
900
900
|
|
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
|