in modular_sdk/models/pynamodb_extension/base_model.py [0:0]
def json_to_attribute_value(value: Any) -> Dict[str, Any]:
"""
Overrides the one from "pynamodb.util" to handle MongoDB specific
attributes such as ObjectId, Date, Binary and others
:param value:
:return:
"""
if value is None:
return {NULL: True}
if value is True or value is False:
return {BOOLEAN: value}
if isinstance(value, (int, float)):
return {NUMBER: json.dumps(value)}
if isinstance(value, str):
return {STRING: value}
if isinstance(value, list):
return {LIST: [json_to_attribute_value(v) for v in value]}
if isinstance(value, dict):
return {MAP: {k: json_to_attribute_value(v) for k, v in value.items()}}
# changed part below
# In case we don't know how to convert an attribute, we just proxy it.
# STRING is used because PynamoDB does nothing to change the value
# in case it's type STRING. So, the value won't be corrupted.
# It's used only for on-prem
return {STRING: value}