statikk 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl
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/engine.py +3 -1
- statikk/models.py +19 -3
- {statikk-0.1.4.dist-info → statikk-0.1.6.dist-info}/METADATA +1 -1
- statikk-0.1.6.dist-info/RECORD +12 -0
- {statikk-0.1.4.dist-info → statikk-0.1.6.dist-info}/WHEEL +1 -1
- statikk-0.1.4.dist-info/RECORD +0 -12
- {statikk-0.1.4.dist-info → statikk-0.1.6.dist-info}/LICENSE.txt +0 -0
- {statikk-0.1.4.dist-info → statikk-0.1.6.dist-info}/top_level.txt +0 -0
statikk/engine.py
CHANGED
@@ -313,7 +313,9 @@ class Table:
|
|
313
313
|
raise InvalidIndexNameError(f"The provided index name '{index_name}' is not configured on the table.")
|
314
314
|
index = index_filter[0]
|
315
315
|
key_condition = hash_key.evaluate(index.hash_key.name)
|
316
|
-
if
|
316
|
+
if (
|
317
|
+
not range_key or (range_key and range_key.value != model_class.type())
|
318
|
+
) and FIELD_STATIKK_TYPE not in model_class.index_definitions()[index_name].pk_fields:
|
317
319
|
range_key = BeginsWith(model_class.type())
|
318
320
|
if range_key:
|
319
321
|
if not model_class.is_nested():
|
statikk/models.py
CHANGED
@@ -67,16 +67,18 @@ class TrackingMixin:
|
|
67
67
|
|
68
68
|
def _recursive_hash(self) -> int:
|
69
69
|
"""
|
70
|
-
Compute a hash value for the model, ignoring nested DatabaseModel instances.
|
70
|
+
Compute a hash value for the model, ignoring specified fields and nested DatabaseModel instances.
|
71
71
|
|
72
|
-
This ensures that changes to child models don't affect the parent's hash.
|
72
|
+
This ensures that changes to ignored fields or child models don't affect the parent's hash.
|
73
73
|
|
74
74
|
Returns:
|
75
|
-
A hash value representing the model's non-
|
75
|
+
A hash value representing the model's non-ignored fields.
|
76
76
|
"""
|
77
77
|
if not self.should_track:
|
78
78
|
return 0
|
79
79
|
|
80
|
+
ignored_fields = self.ignore_tracking_fields()
|
81
|
+
|
80
82
|
values = []
|
81
83
|
for field_name in self.model_fields:
|
82
84
|
if not hasattr(self, field_name):
|
@@ -85,6 +87,9 @@ class TrackingMixin:
|
|
85
87
|
if field_name.startswith("_"):
|
86
88
|
continue
|
87
89
|
|
90
|
+
if field_name in ignored_fields:
|
91
|
+
continue
|
92
|
+
|
88
93
|
value = getattr(self, field_name)
|
89
94
|
|
90
95
|
if hasattr(value, "__class__") and issubclass(value.__class__, DatabaseModel):
|
@@ -141,6 +146,17 @@ class TrackingMixin:
|
|
141
146
|
|
142
147
|
return True
|
143
148
|
|
149
|
+
def ignore_tracking_fields(self) -> set:
|
150
|
+
"""
|
151
|
+
Override this method to specify fields to ignore when tracking changes.
|
152
|
+
|
153
|
+
Returns:
|
154
|
+
A set specifying fields to ignore.
|
155
|
+
Example:
|
156
|
+
{"field1", "field2"}
|
157
|
+
"""
|
158
|
+
return {}
|
159
|
+
|
144
160
|
|
145
161
|
class DatabaseModel(BaseModel, TrackingMixin, extra=Extra.allow):
|
146
162
|
id: str = Field(default_factory=lambda: str(uuid4()))
|
@@ -0,0 +1,12 @@
|
|
1
|
+
statikk/__init__.py,sha256=pH5i4Fj1tbXLqLtTVIdoojiplZssQn0nnud8-HXodRE,577
|
2
|
+
statikk/conditions.py,sha256=63FYMR-UUaE-ZJEb_8CU721CQTwhajq39-BbokmKeMA,2166
|
3
|
+
statikk/engine.py,sha256=U2STo-d8Rf6jiPtIdVgGdZ11G6xYjn-yehFdeCb7ZO8,30961
|
4
|
+
statikk/expressions.py,sha256=mF6Hmj3Kmj6KKXTymeTHSepVA7rhiSINpFgSAPeBTRY,12210
|
5
|
+
statikk/fields.py,sha256=LkMP5NnX7WS0HSLxI3Q-dMOrfaJ0SD7SayZxJU5Acgg,86
|
6
|
+
statikk/models.py,sha256=jc6Ta0-jSwE5mAMd2703EyKVKrG6VGqLStpYCCxYaKs,13762
|
7
|
+
statikk/typing.py,sha256=qfpegORcdODuILK3gvuD4SdcZA1a7Myn0yvscOLPHOM,68
|
8
|
+
statikk-0.1.6.dist-info/LICENSE.txt,sha256=uSH_2Hpb2Bigy5_HhBliN2fZbBU64G3ERM5zzhKPUEE,1078
|
9
|
+
statikk-0.1.6.dist-info/METADATA,sha256=K99ceCXlXRr3soKTtKxLEXUQKspay_LyNhYcgFUdJc0,3160
|
10
|
+
statikk-0.1.6.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
11
|
+
statikk-0.1.6.dist-info/top_level.txt,sha256=etKmBbjzIlLpSefXoiOfhWGEgvqUEALaFwCjFDBD9YI,8
|
12
|
+
statikk-0.1.6.dist-info/RECORD,,
|
statikk-0.1.4.dist-info/RECORD
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
statikk/__init__.py,sha256=pH5i4Fj1tbXLqLtTVIdoojiplZssQn0nnud8-HXodRE,577
|
2
|
-
statikk/conditions.py,sha256=63FYMR-UUaE-ZJEb_8CU721CQTwhajq39-BbokmKeMA,2166
|
3
|
-
statikk/engine.py,sha256=hMA6V_aneWpJlCa4mogu6rE3-T7qwFuRGAkK-0nREj8,30884
|
4
|
-
statikk/expressions.py,sha256=mF6Hmj3Kmj6KKXTymeTHSepVA7rhiSINpFgSAPeBTRY,12210
|
5
|
-
statikk/fields.py,sha256=LkMP5NnX7WS0HSLxI3Q-dMOrfaJ0SD7SayZxJU5Acgg,86
|
6
|
-
statikk/models.py,sha256=r8vjVvm1wgPTeGuuiUW0ydfppytZ3PJxYDEOZudmCTU,13307
|
7
|
-
statikk/typing.py,sha256=qfpegORcdODuILK3gvuD4SdcZA1a7Myn0yvscOLPHOM,68
|
8
|
-
statikk-0.1.4.dist-info/LICENSE.txt,sha256=uSH_2Hpb2Bigy5_HhBliN2fZbBU64G3ERM5zzhKPUEE,1078
|
9
|
-
statikk-0.1.4.dist-info/METADATA,sha256=dMTY_5ZNupxlY1GkAIfQGMZVdBsc1tvdueh0JRd64mo,3160
|
10
|
-
statikk-0.1.4.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
11
|
-
statikk-0.1.4.dist-info/top_level.txt,sha256=etKmBbjzIlLpSefXoiOfhWGEgvqUEALaFwCjFDBD9YI,8
|
12
|
-
statikk-0.1.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|