Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
DynamoDB: Followup fix to issue 639: Item.__init__ now correctly allo…
Browse files Browse the repository at this point in the history
…ws False-but-not-None (e.g. 0) values for hash_key and range_key.
  • Loading branch information
Max Noel committed Mar 19, 2012
1 parent 94c7391 commit 5b05adc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions boto/dynamodb/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ def __init__(self, table, hash_key=None, range_key=None, attrs=None):
self._updates = None
self._hash_key_name = self.table.schema.hash_key_name
self._range_key_name = self.table.schema.range_key_name
hash_key = hash_key or attrs.get(self._hash_key_name, None)
if hash_key is None:
raise DynamoDBItemError('You must supply a hash_key')
if attrs.get(self._hash_key_name) is None:
raise DynamoDBItemError('You must supply a hash_key')
hash_key = attrs[self._hash_key_name]
if self._range_key_name:
range_key = range_key or attrs.get(self._range_key_name, None)
if range_key is None:
raise DynamoDBItemError('You must supply a range_key')
if attrs.get(self._range_key_name) is None:
raise DynamoDBItemError('You must supply a range_key')
range_key = attrs[self._range_key_name]
self[self._hash_key_name] = hash_key
if self._range_key_name:
self[self._range_key_name] = range_key
Expand Down

0 comments on commit 5b05adc

Please sign in to comment.