You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I create a custom attribute that contains both number and BOOL values?
NUMBER may have been mixed up with past data in the same attribute in DynamoDB.
I would like to read all the numbers and BOOL values in DynamoDB and convert them to BOOL.
However, the attr_type must be specified, and it can only be either BOOL or number.
I would appreciate it if you could tell me how to resolve this issue.
DynamoDB:
{'value': {'N': '0'}}
{'value': {'BOOL': '0'}}
CustomAttribute:
class CustomAttribute(Attribute):
def serialize(self, value):
if value is None:
return None
elif value:
return True
else:
return False
def deserialize(self, value):
if value is None:
return None
elif isinstance(value, bool):
return bool(value)
elif isinstance(value, str):
return bool(json.loads(value))
Hi,
How can I create a custom attribute that contains both number and BOOL values?
NUMBER may have been mixed up with past data in the same attribute in DynamoDB.
I would like to read all the numbers and BOOL values in DynamoDB and convert them to BOOL.
However, the
attr_type
must be specified, and it can only be either BOOL or number.I would appreciate it if you could tell me how to resolve this issue.
DynamoDB:
CustomAttribute:
PynamoDB/pynamodb/attributes.py
Line 194 in e8d3bb4
I see here that it may not be supported, but if there is another way, please let me know.
Thanks.
The text was updated successfully, but these errors were encountered: