mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
newforms-admin: Merged from trunk up to [7478]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7479 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -14,7 +14,7 @@ class Choice(models.Model):
|
||||
return u"Choice: %s in poll %s" % (self.choice, self.poll)
|
||||
|
||||
__test__ = {'API_TESTS':"""
|
||||
# Regression test for the use of None as a query value. None is interpreted as
|
||||
# Regression test for the use of None as a query value. None is interpreted as
|
||||
# an SQL NULL, but only in __exact queries.
|
||||
# Set up some initial polls and choices
|
||||
>>> p1 = Poll(question='Why?')
|
||||
@@ -24,15 +24,20 @@ __test__ = {'API_TESTS':"""
|
||||
>>> c2 = Choice(poll=p1, choice='Why Not?')
|
||||
>>> c2.save()
|
||||
|
||||
# Exact query with value None returns nothing (=NULL in sql)
|
||||
>>> Choice.objects.filter(id__exact=None)
|
||||
# Exact query with value None returns nothing ("is NULL" in sql, but every 'id'
|
||||
# field has a value).
|
||||
>>> Choice.objects.filter(choice__exact=None)
|
||||
[]
|
||||
|
||||
Excluding the previous result returns everything.
|
||||
>>> Choice.objects.exclude(choice=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)
|
||||
>>> Choice.objects.filter(foo__exact=None)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: Cannot resolve keyword 'foo' into field. Choices are: id, poll, choice
|
||||
FieldError: Cannot resolve keyword 'foo' into field. Choices are: choice, id, poll
|
||||
|
||||
# Can't use None on anything other than __exact
|
||||
>>> Choice.objects.filter(id__gt=None)
|
||||
|
||||
Reference in New Issue
Block a user