summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2007-06-27 18:58:10 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2007-06-27 18:58:10 +0000
commit24512a74befc6282a1d299cab452ee9463cc2baa (patch)
tree7654c2ed72d28b7a0b9f47c0bfbebb9b75949ae6 /docs
parent7dc8b1a1a8a8e2771f37568a125fd51a3283b043 (diff)
Fixed #1465: added support for regex lookups. Thanks, Tom Tobin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5555 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/db-api.txt42
1 files changed, 42 insertions, 0 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt
index e7b8183f6c..9284c9994c 100644
--- a/docs/db-api.txt
+++ b/docs/db-api.txt
@@ -1173,6 +1173,48 @@ like ``contains`` but is significantly faster due to full-text indexing.
Note this is only available in MySQL and requires direct manipulation of the
database to add the full-text index.
+regex
+~~~~~
+
+Case-sensitive regular expression match.
+
+The regular expression syntax is that of the database backend in use; for the
+``sqlite`` backend, the syntax is that of Python's ``re`` module.
+
+Example::
+
+ Entry.objects.get(title__regex=r'^(An?|The) +')
+
+SQL equivalents::
+
+ SELECT ... WHERE title REGEXP BINARY '^(An?|The) +'; -- MySQL
+
+ SELECT ... WHERE title ~ '^(An?|The) +'; -- PostgreSQL
+
+ SELECT ... WHERE title REGEXP '^(An?|The) +'; -- sqlite
+
+Using raw strings for passing in the regular expression syntax is recommended.
+
+Regular expression matching is not supported on the ``ado_mssql`` and
+``oracle`` backends; these will raise a ``NotImplementedError``.
+
+iregex
+~~~~~~
+
+Case-insensitive regular expression match.
+
+Example::
+
+ Entry.objects.get(title__iregex=r'^(an?|the) +')
+
+SQL equivalents::
+
+ SELECT ... WHERE title REGEXP '^(an?|the) +'; -- MySQL
+
+ SELECT ... WHERE title ~* '^(an?|the) +'; -- PostgreSQL
+
+ SELECT ... WHERE title REGEXP '(?i)^(an?|the) +'; -- sqlite
+
Default lookups are exact
-------------------------