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 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 range_key is None and FIELD_STATIKK_TYPE not in model_class.index_definitions()[index_name].pk_fields:
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-model fields.
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()))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: statikk
3
- Version: 0.1.4
3
+ Version: 0.1.6
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
@@ -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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -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,,