reverted changes from [1534] and [1536] regarding ticket #966
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1541 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e19edfbea0
commit
c464e57da9
|
@ -132,12 +132,6 @@ OPERATOR_MAPPING = {
|
||||||
'endswith': 'LIKE %s',
|
'endswith': 'LIKE %s',
|
||||||
'istartswith': 'LIKE %s',
|
'istartswith': 'LIKE %s',
|
||||||
'iendswith': 'LIKE %s',
|
'iendswith': 'LIKE %s',
|
||||||
'notcontains': 'NOT LIKE %s',
|
|
||||||
'notstartswith': 'NOT LIKE %s',
|
|
||||||
'notendswith': 'NOT LIKE %s',
|
|
||||||
'inotcontains': 'NOT LIKE %s',
|
|
||||||
'inotstartswith': 'NOT LIKE %s',
|
|
||||||
'inotendswith': 'NOT LIKE %s',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DATA_TYPES = {
|
DATA_TYPES = {
|
||||||
|
|
|
@ -146,12 +146,6 @@ OPERATOR_MAPPING = {
|
||||||
'endswith': 'LIKE BINARY %s',
|
'endswith': 'LIKE BINARY %s',
|
||||||
'istartswith': 'LIKE %s',
|
'istartswith': 'LIKE %s',
|
||||||
'iendswith': 'LIKE %s',
|
'iendswith': 'LIKE %s',
|
||||||
'notcontains': 'NOT LIKE BINARY %s',
|
|
||||||
'notstartswith': 'NOT LIKE BINARY %s',
|
|
||||||
'notendswith': 'NOT LIKE BINARY %s',
|
|
||||||
'inotcontains': 'NOT LIKE %s',
|
|
||||||
'inotstartswith': 'NOT LIKE %s',
|
|
||||||
'inotendswith': 'NOT LIKE %s',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This dictionary maps Field objects to their associated MySQL column
|
# This dictionary maps Field objects to their associated MySQL column
|
||||||
|
|
|
@ -151,12 +151,6 @@ OPERATOR_MAPPING = {
|
||||||
'endswith': 'LIKE %s',
|
'endswith': 'LIKE %s',
|
||||||
'istartswith': 'ILIKE %s',
|
'istartswith': 'ILIKE %s',
|
||||||
'iendswith': 'ILIKE %s',
|
'iendswith': 'ILIKE %s',
|
||||||
'notcontains': 'NOT LIKE %s',
|
|
||||||
'notstartswith': 'NOT LIKE %s',
|
|
||||||
'notendswith': 'NOT LIKE %s',
|
|
||||||
'inotcontains': 'NOT ILIKE %s',
|
|
||||||
'inotstartswith': 'NOT ILIKE %s',
|
|
||||||
'inotendswith': 'NOT ILIKE %s',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This dictionary maps Field objects to their associated PostgreSQL column
|
# This dictionary maps Field objects to their associated PostgreSQL column
|
||||||
|
|
|
@ -153,12 +153,6 @@ OPERATOR_MAPPING = {
|
||||||
'endswith': "LIKE %s ESCAPE '\\'",
|
'endswith': "LIKE %s ESCAPE '\\'",
|
||||||
'istartswith': "LIKE %s ESCAPE '\\'",
|
'istartswith': "LIKE %s ESCAPE '\\'",
|
||||||
'iendswith': "LIKE %s ESCAPE '\\'",
|
'iendswith': "LIKE %s ESCAPE '\\'",
|
||||||
'notcontains': "NOT LIKE %s ESCAPE '\\'",
|
|
||||||
'notstartswith': "NOT LIKE %s ESCAPE '\\'",
|
|
||||||
'notendswith': "NOT LIKE %s ESCAPE '\\'",
|
|
||||||
'inotcontains': "NOT LIKE %s ESCAPE '\\'",
|
|
||||||
'inotstartswith': "NOT LIKE %s ESCAPE '\\'",
|
|
||||||
'inotendswith': "NOT LIKE %s ESCAPE '\\'",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# SQLite doesn't actually support most of these types, but it "does the right
|
# SQLite doesn't actually support most of these types, but it "does the right
|
||||||
|
|
|
@ -181,13 +181,13 @@ class Field(object):
|
||||||
return value
|
return value
|
||||||
elif lookup_type == 'year':
|
elif lookup_type == 'year':
|
||||||
return ['%s-01-01' % value, '%s-12-31' % value]
|
return ['%s-01-01' % value, '%s-12-31' % value]
|
||||||
elif lookup_type in ('contains', 'icontains', 'notcontains', 'inotcontains'):
|
elif lookup_type in ('contains', 'icontains'):
|
||||||
return ["%%%s%%" % prep_for_like_query(value)]
|
return ["%%%s%%" % prep_for_like_query(value)]
|
||||||
elif lookup_type == 'iexact':
|
elif lookup_type == 'iexact':
|
||||||
return [prep_for_like_query(value)]
|
return [prep_for_like_query(value)]
|
||||||
elif lookup_type in ('startswith', 'istartswith', 'notstartswith', 'inotstartswith'):
|
elif lookup_type in ('startswith', 'istartswith'):
|
||||||
return ["%s%%" % prep_for_like_query(value)]
|
return ["%s%%" % prep_for_like_query(value)]
|
||||||
elif lookup_type in ('endswith', 'iendswith', 'notendswith', 'inotendswith'):
|
elif lookup_type in ('endswith', 'iendswith'):
|
||||||
return ["%%%s" % prep_for_like_query(value)]
|
return ["%%%s" % prep_for_like_query(value)]
|
||||||
elif lookup_type == 'isnull':
|
elif lookup_type == 'isnull':
|
||||||
return []
|
return []
|
||||||
|
|
|
@ -152,51 +152,45 @@ translates (roughly) into the following SQL::
|
||||||
|
|
||||||
The DB API supports the following lookup types:
|
The DB API supports the following lookup types:
|
||||||
|
|
||||||
============= ==============================================================
|
=========== ==============================================================
|
||||||
Type Description
|
Type Description
|
||||||
============= ==============================================================
|
=========== ==============================================================
|
||||||
exact Exact match: ``polls.get_object(id__exact=14)``.
|
exact Exact match: ``polls.get_object(id__exact=14)``.
|
||||||
iexact Case-insensitive exact match:
|
iexact Case-insensitive exact match:
|
||||||
``polls.get_list(slug__iexact="foo")`` matches a slug of
|
``polls.get_list(slug__iexact="foo")`` matches a slug of
|
||||||
``foo``, ``FOO``, ``fOo``, etc.
|
``foo``, ``FOO``, ``fOo``, etc.
|
||||||
contains Case-sensitive containment test:
|
contains Case-sensitive containment test:
|
||||||
``polls.get_list(question__contains="spam")`` returns all polls
|
``polls.get_list(question__contains="spam")`` returns all polls
|
||||||
that contain "spam" in the question. (PostgreSQL and MySQL
|
that contain "spam" in the question. (PostgreSQL and MySQL
|
||||||
only. SQLite doesn't support case-sensitive LIKE statements;
|
only. SQLite doesn't support case-sensitive LIKE statements;
|
||||||
``contains`` will act like ``icontains`` for SQLite.)
|
``contains`` will act like ``icontains`` for SQLite.)
|
||||||
notcontains negated ``contains``
|
icontains Case-insensitive containment test.
|
||||||
icontains Case-insensitive containment test.
|
gt Greater than: ``polls.get_list(id__gt=4)``.
|
||||||
inotcontains negated ``icontains``
|
gte Greater than or equal to.
|
||||||
gt Greater than: ``polls.get_list(id__gt=4)``.
|
lt Less than.
|
||||||
gte Greater than or equal to.
|
lte Less than or equal to.
|
||||||
lt Less than.
|
ne Not equal to.
|
||||||
lte Less than or equal to.
|
in In a given list: ``polls.get_list(id__in=[1, 3, 4])`` returns
|
||||||
ne Not equal to.
|
a list of polls whose IDs are either 1, 3 or 4.
|
||||||
in In a given list: ``polls.get_list(id__in=[1, 3, 4])`` returns
|
startswith Case-sensitive starts-with:
|
||||||
a list of polls whose IDs are either 1, 3 or 4.
|
``polls.get_list(question_startswith="Would")``. (PostgreSQL
|
||||||
startswith Case-sensitive starts-with:
|
and MySQL only. SQLite doesn't support case-sensitive LIKE
|
||||||
``polls.get_list(question_startswith="Would")``. (PostgreSQL
|
statements; ``startswith`` will act like ``istartswith`` for
|
||||||
and MySQL only. SQLite doesn't support case-sensitive LIKE
|
SQLite.)
|
||||||
statements; ``startswith`` will act like ``istartswith`` for
|
endswith Case-sensitive ends-with. (PostgreSQL and MySQL only.)
|
||||||
SQLite.)
|
istartswith Case-insensitive starts-with.
|
||||||
notstartswith negated ``startswith``
|
iendswith Case-insensitive ends-with.
|
||||||
endswith Case-sensitive ends-with. (PostgreSQL and MySQL only.)
|
range Range test:
|
||||||
notendswith negated ``endswith``
|
``polls.get_list(pub_date__range=(start_date, end_date))``
|
||||||
istartswith Case-insensitive starts-with.
|
returns all polls with a pub_date between ``start_date``
|
||||||
inotstartswith negated ``istartswith``
|
and ``end_date`` (inclusive).
|
||||||
iendswith Case-insensitive ends-with.
|
year For date/datetime fields, exact year match:
|
||||||
inotendswith negated ``iendswith``
|
``polls.get_count(pub_date__year=2005)``.
|
||||||
range Range test:
|
month For date/datetime fields, exact month match.
|
||||||
``polls.get_list(pub_date__range=(start_date, end_date))``
|
day For date/datetime fields, exact day match.
|
||||||
returns all polls with a pub_date between ``start_date``
|
isnull True/False; does is IF NULL/IF NOT NULL lookup:
|
||||||
and ``end_date`` (inclusive).
|
``polls.get_list(expire_date__isnull=True)``.
|
||||||
year For date/datetime fields, exact year match:
|
=========== ==============================================================
|
||||||
``polls.get_count(pub_date__year=2005)``.
|
|
||||||
month For date/datetime fields, exact month match.
|
|
||||||
day For date/datetime fields, exact day match.
|
|
||||||
isnull True/False; does is IF NULL/IF NOT NULL lookup:
|
|
||||||
``polls.get_list(expire_date__isnull=True)``.
|
|
||||||
============= ==============================================================
|
|
||||||
|
|
||||||
Multiple lookups are allowed, of course, and are translated as "AND"s::
|
Multiple lookups are allowed, of course, and are translated as "AND"s::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue