Skip to content

Commit 1906d18

Browse files
rarepolzRares Polenciuc
andauthored
fix: add datetime_object_hook to SQLite store deserialization (#134)
Co-authored-by: Rares Polenciuc <rarepolz@amazon.com>
1 parent c07077c commit 1906d18

File tree

1 file changed

+12
-3
lines changed
  • src/aws_durable_execution_sdk_python_testing/stores

1 file changed

+12
-3
lines changed

src/aws_durable_execution_sdk_python_testing/stores/sqlite.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
from aws_durable_execution_sdk_python_testing.stores.base import (
1818
ExecutionStore,
1919
)
20-
from aws_durable_execution_sdk_python_testing.stores.filesystem import DateTimeEncoder
20+
from aws_durable_execution_sdk_python_testing.stores.filesystem import (
21+
DateTimeEncoder,
22+
datetime_object_hook,
23+
)
2124

2225

2326
class SQLiteExecutionStore(ExecutionStore):
@@ -122,7 +125,9 @@ def load(self, execution_arn: str) -> Execution:
122125
if not row:
123126
raise ResourceNotFoundException(f"Execution {execution_arn} not found")
124127

125-
return Execution.from_dict(json.loads(row[0]))
128+
return Execution.from_dict(
129+
json.loads(row[0], object_hook=datetime_object_hook)
130+
)
126131
except sqlite3.Error as e:
127132
raise RuntimeError(f"Failed to load execution {execution_arn}: {e}") from e
128133
except json.JSONDecodeError as e:
@@ -217,7 +222,11 @@ def query(
217222
executions: list[Execution] = []
218223
for durable_execution_arn, data in rows:
219224
try:
220-
executions.append(Execution.from_dict(json.loads(data)))
225+
executions.append(
226+
Execution.from_dict(
227+
json.loads(data, object_hook=datetime_object_hook)
228+
)
229+
)
221230
except (json.JSONDecodeError, ValueError) as e:
222231
# Log corrupted data but continue with other records
223232
print(

0 commit comments

Comments
 (0)