statikk 0.1.6__tar.gz → 0.1.7__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.6 → statikk-0.1.7}/PKG-INFO +1 -1
  2. {statikk-0.1.6 → statikk-0.1.7}/src/statikk/engine.py +5 -1
  3. {statikk-0.1.6 → statikk-0.1.7}/src/statikk/models.py +4 -0
  4. {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/PKG-INFO +1 -1
  5. {statikk-0.1.6 → statikk-0.1.7}/tests/test_engine.py +8 -3
  6. {statikk-0.1.6 → statikk-0.1.7}/.coveragerc +0 -0
  7. {statikk-0.1.6 → statikk-0.1.7}/.gitignore +0 -0
  8. {statikk-0.1.6 → statikk-0.1.7}/.readthedocs.yml +0 -0
  9. {statikk-0.1.6 → statikk-0.1.7}/AUTHORS.rst +0 -0
  10. {statikk-0.1.6 → statikk-0.1.7}/CHANGELOG.rst +0 -0
  11. {statikk-0.1.6 → statikk-0.1.7}/CONTRIBUTING.rst +0 -0
  12. {statikk-0.1.6 → statikk-0.1.7}/LICENSE.txt +0 -0
  13. {statikk-0.1.6 → statikk-0.1.7}/README.rst +0 -0
  14. {statikk-0.1.6 → statikk-0.1.7}/assets/favicon.png +0 -0
  15. {statikk-0.1.6 → statikk-0.1.7}/assets/logo.png +0 -0
  16. {statikk-0.1.6 → statikk-0.1.7}/docs/Makefile +0 -0
  17. {statikk-0.1.6 → statikk-0.1.7}/docs/_static/.gitignore +0 -0
  18. {statikk-0.1.6 → statikk-0.1.7}/docs/authors.rst +0 -0
  19. {statikk-0.1.6 → statikk-0.1.7}/docs/changelog.rst +0 -0
  20. {statikk-0.1.6 → statikk-0.1.7}/docs/conf.py +0 -0
  21. {statikk-0.1.6 → statikk-0.1.7}/docs/contributing.rst +0 -0
  22. {statikk-0.1.6 → statikk-0.1.7}/docs/index.rst +0 -0
  23. {statikk-0.1.6 → statikk-0.1.7}/docs/license.rst +0 -0
  24. {statikk-0.1.6 → statikk-0.1.7}/docs/readme.rst +0 -0
  25. {statikk-0.1.6 → statikk-0.1.7}/docs/requirements.txt +0 -0
  26. {statikk-0.1.6 → statikk-0.1.7}/docs/usage.rst +0 -0
  27. {statikk-0.1.6 → statikk-0.1.7}/pyproject.toml +0 -0
  28. {statikk-0.1.6 → statikk-0.1.7}/setup.cfg +0 -0
  29. {statikk-0.1.6 → statikk-0.1.7}/setup.py +0 -0
  30. {statikk-0.1.6 → statikk-0.1.7}/src/statikk/__init__.py +0 -0
  31. {statikk-0.1.6 → statikk-0.1.7}/src/statikk/conditions.py +0 -0
  32. {statikk-0.1.6 → statikk-0.1.7}/src/statikk/expressions.py +0 -0
  33. {statikk-0.1.6 → statikk-0.1.7}/src/statikk/fields.py +0 -0
  34. {statikk-0.1.6 → statikk-0.1.7}/src/statikk/typing.py +0 -0
  35. {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/SOURCES.txt +0 -0
  36. {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/dependency_links.txt +0 -0
  37. {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/not-zip-safe +0 -0
  38. {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/requires.txt +0 -0
  39. {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/top_level.txt +0 -0
  40. {statikk-0.1.6 → statikk-0.1.7}/tests/conftest.py +0 -0
  41. {statikk-0.1.6 → statikk-0.1.7}/tests/test_expressions.py +0 -0
  42. {statikk-0.1.6 → statikk-0.1.7}/tests/test_models.py +0 -0
  43. {statikk-0.1.6 → statikk-0.1.7}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: statikk
3
- Version: 0.1.6
3
+ Version: 0.1.7
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
@@ -232,9 +232,13 @@ class Table:
232
232
 
233
233
  Returns the enriched database model instance.
234
234
  """
235
+
235
236
  with self.batch_write() as batch:
236
237
  for item in model.split_to_simple_objects():
237
- batch.put(item)
238
+ if item._should_delete:
239
+ batch.delete(item)
240
+ else:
241
+ batch.put(item)
238
242
 
239
243
  def update_item(
240
244
  self,
@@ -162,6 +162,7 @@ class DatabaseModel(BaseModel, TrackingMixin, extra=Extra.allow):
162
162
  id: str = Field(default_factory=lambda: str(uuid4()))
163
163
  _parent: Optional[DatabaseModel] = None
164
164
  _model_types_in_hierarchy: dict[str, Type[DatabaseModel]] = {}
165
+ _should_delete: bool = False
165
166
 
166
167
  @classmethod
167
168
  def type(cls) -> str:
@@ -256,6 +257,9 @@ class DatabaseModel(BaseModel, TrackingMixin, extra=Extra.allow):
256
257
  return self._parent.should_write_to_database()
257
258
  return True
258
259
 
260
+ def mark_for_delete(self):
261
+ self._should_delete = True
262
+
259
263
  @classmethod
260
264
  def scan(
261
265
  cls,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: statikk
3
- Version: 0.1.6
3
+ Version: 0.1.7
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
@@ -788,7 +788,7 @@ def test_nested_hierarchies():
788
788
 
789
789
  class DoublyNestedModel(DatabaseModel):
790
790
  bar: str
791
- items: list[TriplyNested]
791
+ items: list[TriplyNested] = []
792
792
 
793
793
  @classmethod
794
794
  def index_definitions(cls) -> dict[str, IndexFieldConfig]:
@@ -803,7 +803,7 @@ def test_nested_hierarchies():
803
803
 
804
804
  class NestedModel(DatabaseModel):
805
805
  foo: str
806
- doubly_nested: list[DoublyNestedModel]
806
+ doubly_nested: list[DoublyNestedModel] = []
807
807
 
808
808
  @classmethod
809
809
  def index_definitions(cls) -> dict[str, IndexFieldConfig]:
@@ -836,7 +836,8 @@ def test_nested_hierarchies():
836
836
  models=[ModelHierarchy, NestedModel, DoublyNestedModel, TriplyNested],
837
837
  )
838
838
  _create_dynamodb_table(table)
839
- doubly_nested = DoublyNestedModel(bar="bar", items=[TriplyNested(faz="faz")])
839
+ triple_nested_model = TriplyNested(faz="faz")
840
+ doubly_nested = DoublyNestedModel(bar="bar", items=[triple_nested_model])
840
841
  double_nested_no_write = DoublyNestedModel(bar="far", items=[TriplyNested(faz="faz")])
841
842
  nested = NestedModel(foo="foo", doubly_nested=[doubly_nested, double_nested_no_write])
842
843
  model_hierarchy = ModelHierarchy(foo_id="foo_id", state="state", nested=nested)
@@ -850,5 +851,9 @@ def test_nested_hierarchies():
850
851
  assert hierarchy.nested.doubly_nested[0].gsi_pk == "foo_id"
851
852
  assert hierarchy.nested.doubly_nested[0].gsi_sk == "ModelHierarchy|state|NestedModel|foo|DoublyNestedModel|bar"
852
853
  assert hierarchy.nested.doubly_nested[0].items[0].gsi_pk == "foo_id"
854
+ hierarchy.nested.doubly_nested[0].items[0].mark_for_delete()
855
+ hierarchy.save()
856
+ hierarchy = ModelHierarchy.query_hierarchy(hash_key=Equals("foo_id"))
857
+ assert len(hierarchy.nested.doubly_nested[0].items) == 0
853
858
  hierarchy.delete()
854
859
  assert list(table.scan()) == []
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