Skip to content

Conversation

wsot
Copy link
Contributor

@wsot wsot commented Aug 17, 2016

Problem case:
model.objects.filter(<field>__in=[]) produces a 'NoneType' object is not iterable exception.

Cause:
get_prep_lookup in _NetAddressField returns None if value is falsy.

Change:
Remove early return in get_prep_lookup. Superclass's get_prep_lookup will be called with the value instead.

Added unit test for __in empty list case.
An alternative (neater?) unit test would be simply performing a self.qs.filter(field__in=[]) and checking it returns an empty query set.

…list.

Add unit test for `__in` empty list case.
@jimfunk
Copy link
Owner

jimfunk commented Aug 19, 2016

Thanks, but the unit tests are failing on Django 1.9.

@jimfunk
Copy link
Owner

jimfunk commented Aug 19, 2016

Seems that a broken Travis config kept me from seeing that these tests also fail in master. I will have to check into that

@jimfunk jimfunk merged commit 375a406 into jimfunk:master Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants