- Timestamp:
- 04/26/08 21:50:16 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/tests/regressiontests/null_queries/models.py
r5876 r7477 15 15 16 16 __test__ = {'API_TESTS':""" 17 # Regression test for the use of None as a query value. None is interpreted as 17 # Regression test for the use of None as a query value. None is interpreted as 18 18 # an SQL NULL, but only in __exact queries. 19 19 # Set up some initial polls and choices … … 25 25 >>> c2.save() 26 26 27 # Exact query with value None returns nothing (=NULL in sql) 28 >>> Choice.objects.filter(id__exact=None) 27 # Exact query with value None returns nothing ("is NULL" in sql, but every 'id' 28 # field has a value). 29 >>> Choice.objects.filter(choice__exact=None) 29 30 [] 30 31 32 Excluding the previous result returns everything. 33 >>> Choice.objects.exclude(choice=None).order_by('id') 34 [<Choice: Choice: Because. in poll Q: Why? >, <Choice: Choice: Why Not? in poll Q: Why? >] 35 31 36 # Valid query, but fails because foo isn't a keyword 32 >>> Choice.objects.filter(foo__exact=None) 37 >>> Choice.objects.filter(foo__exact=None) 33 38 Traceback (most recent call last): 34 39 ... 35 TypeError: Cannot resolve keyword 'foo' into field. Choices are: id, poll, choice 40 FieldError: Cannot resolve keyword 'foo' into field. Choices are: choice, id, poll 36 41 37 42 # Can't use None on anything other than __exact
