summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2006-07-01 03:14:33 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2006-07-01 03:14:33 +0000
commitcd7b54aab0c087ba6efd4a86ae0ecb6ed55d7e4b (patch)
treee6c05b0d83f0cd482839b381f3365783b4969087 /django
parent4a324ba7acd2660538a81b1fb423de89ff515665 (diff)
Fixes #2271 -- Added code to imply !__exact on any query argument that doesn't finish with a known query term.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3248 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/models/query.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index aa2138643e..8fbb942da2 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -10,8 +10,20 @@ import re
if not hasattr(__builtins__, 'set'):
from sets import Set as set
+# The string constant used to separate query parts
LOOKUP_SEPARATOR = '__'
+# The list of valid query types
+QUERY_TERMS=(
+ 'exact', 'iexact',
+ 'contains', 'icontains',
+ 'gt', 'gte', 'lt', 'lte',
+ 'in',
+ 'startswith', 'istartswith', 'endswith', 'iendswith',
+ 'range', 'year', 'month', 'day',
+ 'isnull'
+)
+
# Size of each "chunk" for get_iterator calls.
# Larger values are slightly faster at the expense of more storage space.
GET_ITERATOR_CHUNK_SIZE = 100
@@ -710,12 +722,13 @@ def parse_lookup(kwarg_items, opts):
# if we find "pk", make the clause "exact', and insert
# a dummy name of None, which we will replace when
# we know which table column to grab as the primary key.
- # 2) If there is only one part, assume it to be an __exact
+ # 2) If there is only one part, or the last part is not a query
+ # term, assume that the query is an __exact
clause = path.pop()
if clause == 'pk':
clause = 'exact'
path.append(None)
- elif len(path) == 0:
+ elif len(path) == 0 or clause not in QUERY_TERMS:
path.append(clause)
clause = 'exact'