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.
- {statikk-0.1.6 → statikk-0.1.7}/PKG-INFO +1 -1
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk/engine.py +5 -1
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk/models.py +4 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/PKG-INFO +1 -1
- {statikk-0.1.6 → statikk-0.1.7}/tests/test_engine.py +8 -3
- {statikk-0.1.6 → statikk-0.1.7}/.coveragerc +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/.gitignore +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/.readthedocs.yml +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/AUTHORS.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/CHANGELOG.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/CONTRIBUTING.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/LICENSE.txt +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/README.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/assets/favicon.png +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/assets/logo.png +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/Makefile +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/_static/.gitignore +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/authors.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/changelog.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/conf.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/contributing.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/index.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/license.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/readme.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/requirements.txt +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/docs/usage.rst +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/pyproject.toml +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/setup.cfg +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/setup.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk/__init__.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk/conditions.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk/expressions.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk/fields.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk/typing.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/SOURCES.txt +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/dependency_links.txt +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/not-zip-safe +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/requires.txt +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/src/statikk.egg-info/top_level.txt +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/tests/conftest.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/tests/test_expressions.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/tests/test_models.py +0 -0
- {statikk-0.1.6 → statikk-0.1.7}/tox.ini +0 -0
@@ -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
|
-
|
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,
|
@@ -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
|
-
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|