PynamoDB
PynamoDB copied to clipboard
Bug with Model init when having a hash or range key of 0
Given a Thread Project with a numerical key:
class Project(Model):
class Meta:
table_name = DB_TABLE_PREFIX + 'Device'
project_id = NumberAttribute(hash_key=True)
In [58]: Project(0).project_id is None
Out[58]: True
In [59]: Project(project_id=0).project_id == 0
Out[59]: True
See https://github.com/jlafon/PynamoDB/blob/devel/pynamodb/models.py#L241
There seems to be the same issue on the deserialization side :
In [70]: list(Project.scan())
Out[70]: [Project<1>, Project<null>]
In [73]: Project.get(0)
Out[73]: PostalApiTest_Device<null>
In [74]: Project.get(0).project_id is None
Out[74]: True
I have the same issue for the numeric range key.