Empty item is not "falsey"? #2127

Closed
arlofaria opened this Issue Feb 27, 2014 · 4 comments

3 participants

@arlofaria

On the Web documentation, I read:

Empty items, or items that have no data, are considered falsey.

However, I don't seem to be seeing that behavior... For example:

>>> bool(boto.dynamodb2.items.Item('MyTable'))
True
>>> bool(boto.dynamodb2.table.Table('MyTable').get_item(myKey='missing_value'))
True

I can work around this easily, but wonder if this is a bug...

@toastdriven

I'm afraid I don't quite follow. When a key isn't found, DDB returns an empty response ({}). Boto's Table sees this & should raise an exception - https://github.com/boto/boto/blob/develop/boto/dynamodb2/table.py#L485-L492

What does boto.dynamodb2.table.Table('MyTable').get_item(myKey='missing_value') return? If it's an Item instance, what's in item._data?

Also, what version of Boto are you using? Thanks.

@arlofaria

Yes the return value of that command is an Item instance, and item._data is {}. My question is whether bool(item) should evaluate to False, as seems to be suggested by the documentation.

I'm using version 2.9.6. Thanks.

@arlofaria arlofaria closed this Mar 15, 2014
@arlofaria arlofaria reopened this Mar 15, 2014
@toastdriven

The current version of Boto is 2.27.0. The "false-y" behavior was added in 2.20.0 (808e550), so I'd recommend upgrading if possible.

@arlofaria

Ah, right, I should have checked the versions. Sorry!

I had installed it on my system using apt-get install python-boto, rather than pip install boto.

@toastdriven toastdriven removed their assignment Mar 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment