-
Notifications
You must be signed in to change notification settings - Fork 435
Fix get method in models.py to not throw an exception when returning an empty item. #1289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…an empty item. Fix for issue pynamodb#1287 (comment) When getting a model value with `attributes_to_get` parameter, set in a way where it could return an empty object, the get method is erronously throwing an exception even though the object exists. This fixes the issue.
pynamodb/models.py
Outdated
item_data = data.get(ITEM) | ||
if item_data: | ||
return cls.from_raw_data(item_data) | ||
if ITEM in data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably if data and ITEM in data:
Are you going to add a test? |
Hey, let me know whatt you think :) |
Hey, I updated the comments, and I removed the second test as indeed there were other places that already check if this exception is thrown when In regards to better asserts, I'm now checking if the property we are trying to get indeed does not exist, even though the object is of correct type. Is this something more in line with your thinking? |
Fix for issue #1287 (comment) When getting a model value with
attributes_to_get
parameter, set in a way where it could return an empty object, the get method is erronously throwing an exception even though the object exists. This fixes the issue.