statikk 0.1.25__tar.gz → 0.1.26__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.
Files changed (43) hide show
  1. {statikk-0.1.25 → statikk-0.1.26}/PKG-INFO +1 -1
  2. {statikk-0.1.25 → statikk-0.1.26}/src/statikk/engine.py +15 -1
  3. {statikk-0.1.25 → statikk-0.1.26}/src/statikk/models.py +3 -0
  4. {statikk-0.1.25 → statikk-0.1.26}/src/statikk.egg-info/PKG-INFO +1 -1
  5. {statikk-0.1.25 → statikk-0.1.26}/tests/test_engine.py +1 -1
  6. {statikk-0.1.25 → statikk-0.1.26}/.coveragerc +0 -0
  7. {statikk-0.1.25 → statikk-0.1.26}/.gitignore +0 -0
  8. {statikk-0.1.25 → statikk-0.1.26}/.readthedocs.yml +0 -0
  9. {statikk-0.1.25 → statikk-0.1.26}/AUTHORS.rst +0 -0
  10. {statikk-0.1.25 → statikk-0.1.26}/CHANGELOG.rst +0 -0
  11. {statikk-0.1.25 → statikk-0.1.26}/CONTRIBUTING.rst +0 -0
  12. {statikk-0.1.25 → statikk-0.1.26}/LICENSE.txt +0 -0
  13. {statikk-0.1.25 → statikk-0.1.26}/README.rst +0 -0
  14. {statikk-0.1.25 → statikk-0.1.26}/assets/favicon.png +0 -0
  15. {statikk-0.1.25 → statikk-0.1.26}/assets/logo.png +0 -0
  16. {statikk-0.1.25 → statikk-0.1.26}/docs/Makefile +0 -0
  17. {statikk-0.1.25 → statikk-0.1.26}/docs/_static/.gitignore +0 -0
  18. {statikk-0.1.25 → statikk-0.1.26}/docs/authors.rst +0 -0
  19. {statikk-0.1.25 → statikk-0.1.26}/docs/changelog.rst +0 -0
  20. {statikk-0.1.25 → statikk-0.1.26}/docs/conf.py +0 -0
  21. {statikk-0.1.25 → statikk-0.1.26}/docs/contributing.rst +0 -0
  22. {statikk-0.1.25 → statikk-0.1.26}/docs/index.rst +0 -0
  23. {statikk-0.1.25 → statikk-0.1.26}/docs/license.rst +0 -0
  24. {statikk-0.1.25 → statikk-0.1.26}/docs/readme.rst +0 -0
  25. {statikk-0.1.25 → statikk-0.1.26}/docs/requirements.txt +0 -0
  26. {statikk-0.1.25 → statikk-0.1.26}/docs/usage.rst +0 -0
  27. {statikk-0.1.25 → statikk-0.1.26}/pyproject.toml +0 -0
  28. {statikk-0.1.25 → statikk-0.1.26}/setup.cfg +0 -0
  29. {statikk-0.1.25 → statikk-0.1.26}/setup.py +0 -0
  30. {statikk-0.1.25 → statikk-0.1.26}/src/statikk/__init__.py +0 -0
  31. {statikk-0.1.25 → statikk-0.1.26}/src/statikk/conditions.py +0 -0
  32. {statikk-0.1.25 → statikk-0.1.26}/src/statikk/expressions.py +0 -0
  33. {statikk-0.1.25 → statikk-0.1.26}/src/statikk/fields.py +0 -0
  34. {statikk-0.1.25 → statikk-0.1.26}/src/statikk/typing.py +0 -0
  35. {statikk-0.1.25 → statikk-0.1.26}/src/statikk.egg-info/SOURCES.txt +0 -0
  36. {statikk-0.1.25 → statikk-0.1.26}/src/statikk.egg-info/dependency_links.txt +0 -0
  37. {statikk-0.1.25 → statikk-0.1.26}/src/statikk.egg-info/not-zip-safe +0 -0
  38. {statikk-0.1.25 → statikk-0.1.26}/src/statikk.egg-info/requires.txt +0 -0
  39. {statikk-0.1.25 → statikk-0.1.26}/src/statikk.egg-info/top_level.txt +0 -0
  40. {statikk-0.1.25 → statikk-0.1.26}/tests/conftest.py +0 -0
  41. {statikk-0.1.25 → statikk-0.1.26}/tests/test_expressions.py +0 -0
  42. {statikk-0.1.25 → statikk-0.1.26}/tests/test_models.py +0 -0
  43. {statikk-0.1.25 → statikk-0.1.26}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: statikk
3
- Version: 0.1.25
3
+ Version: 0.1.26
4
4
  Summary: statikk is a single table application (STA) library for DynamoDb.
5
5
  Home-page: https://github.com/terinia/statikk
6
6
  Author: Balint Biro
@@ -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.
@@ -519,6 +532,7 @@ class Table:
519
532
  continue
520
533
  if value is not None:
521
534
  setattr(item, key, value)
535
+ item.model_rebuild(force=True)
522
536
  return item
523
537
 
524
538
  def _serialize_item(self, item: DatabaseModel):
@@ -629,7 +643,7 @@ class Table:
629
643
  def _perform_batch_write(
630
644
  self, put_items: List[DatabaseModel], delete_items: List[DatabaseModel], delete_keys: list[dict[str, Any]]
631
645
  ):
632
- if len(put_items) == 0 and len(delete_items) == 0:
646
+ if len(put_items) == 0 and len(delete_items) == 0 and (len(delete_keys) == 0):
633
647
  return
634
648
 
635
649
  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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: statikk
3
- Version: 0.1.25
3
+ Version: 0.1.26
4
4
  Summary: statikk is a single table application (STA) library for DynamoDb.
5
5
  Home-page: https://github.com/terinia/statikk
6
6
  Author: Balint Biro
@@ -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.delete()
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