mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
queryset-refactor: Interpret qs.filter(foo=None) to be the same as qs.filter(foo__isnull=True). Refs #2737.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6760 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -24,10 +24,15 @@ __test__ = {'API_TESTS':"""
|
||||
>>> c2 = Choice(poll=p1, choice='Why Not?')
|
||||
>>> c2.save()
|
||||
|
||||
# Exact query with value None returns nothing (=NULL in sql)
|
||||
# Exact query with value None returns nothing ("is NULL" in sql, but every 'id'
|
||||
# field has a value).
|
||||
>>> Choice.objects.filter(id__exact=None)
|
||||
[]
|
||||
|
||||
Excluding the previous result returns everything.
|
||||
>>> Choice.objects.exclude(id=None).order_by('id')
|
||||
[<Choice: Choice: Because. in poll Q: Why? >, <Choice: Choice: Why Not? in poll Q: Why? >]
|
||||
|
||||
# Valid query, but fails because foo isn't a keyword
|
||||
>>> Choice.objects.filter(foo__exact=None)
|
||||
Traceback (most recent call last):
|
||||
|
||||
Reference in New Issue
Block a user