Added support for istartswith and iendswith in database API
git-svn-id: http://code.djangoproject.com/svn/django/trunk@207 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b617884ced
commit
5797066383
|
@ -99,7 +99,9 @@ OPERATOR_MAPPING = {
|
||||||
'lt': '<',
|
'lt': '<',
|
||||||
'lte': '<=',
|
'lte': '<=',
|
||||||
'startswith': 'LIKE',
|
'startswith': 'LIKE',
|
||||||
'endswith': 'LIKE'
|
'endswith': 'LIKE',
|
||||||
|
'istartswith': 'ILIKE',
|
||||||
|
'iendswith': 'ILIKE',
|
||||||
}
|
}
|
||||||
|
|
||||||
# This dictionary maps Field objects to their associated MySQL column
|
# This dictionary maps Field objects to their associated MySQL column
|
||||||
|
|
|
@ -93,7 +93,9 @@ OPERATOR_MAPPING = {
|
||||||
'lt': '<',
|
'lt': '<',
|
||||||
'lte': '<=',
|
'lte': '<=',
|
||||||
'startswith': 'LIKE',
|
'startswith': 'LIKE',
|
||||||
'endswith': 'LIKE'
|
'endswith': 'LIKE',
|
||||||
|
'istartswith': 'ILIKE',
|
||||||
|
'iendswith': 'ILIKE',
|
||||||
}
|
}
|
||||||
|
|
||||||
# This dictionary maps Field objects to their associated PostgreSQL column
|
# This dictionary maps Field objects to their associated PostgreSQL column
|
||||||
|
|
|
@ -52,21 +52,29 @@ 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 ``foo``,
|
``polls.get_list(slug__iexact="foo")`` matches a slug of ``foo``,
|
||||||
``FOO``, ``fOo``, etc.
|
``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.
|
that contain "spam" in the question. (PostgreSQL only. MySQL
|
||||||
icontains Case-insensitive containment test
|
doesn't support case-sensitive LIKE statements; ``contains``
|
||||||
gt Greater than: ``polls.get_list(id__gt=4)``
|
will act like ``icontains`` for MySQL.)
|
||||||
gte Greater than or equal to
|
icontains Case-insensitive containment test.
|
||||||
lt Less than
|
gt Greater than: ``polls.get_list(id__gt=4)``.
|
||||||
lte Less than or equal to
|
gte Greater than or equal to.
|
||||||
|
lt Less than.
|
||||||
|
lte Less than or equal to.
|
||||||
startswith Case-sensitive starts-with:
|
startswith Case-sensitive starts-with:
|
||||||
``polls.get_list(question_startswith="Would")``
|
``polls.get_list(question_startswith="Would")``. (PostgreSQL
|
||||||
endswith Case-sensitive ends-with
|
only. MySQL doesn't support case-sensitive LIKE statements;
|
||||||
|
``startswith`` will act like ``istartswith`` for MySQL.)
|
||||||
|
endswith Case-sensitive ends-with. (PostgreSQL only. MySQL doesn't
|
||||||
|
support case-sensitive LIKE statements; ``endswith`` will act
|
||||||
|
like ``iendswith`` for MySQL.)
|
||||||
|
istartswith Case-insensitive starts-with.
|
||||||
|
iendswith Case-insensitive ends-with.
|
||||||
range Range test:
|
range Range test:
|
||||||
``polls.get_list(pub_date__range=(start_date, end_date))``
|
``polls.get_list(pub_date__range=(start_date, end_date))``
|
||||||
returns all polls with a pub_date between ``start_date``
|
returns all polls with a pub_date between ``start_date``
|
||||||
|
|
Loading…
Reference in New Issue