summaryrefslogtreecommitdiff
path: root/docs/db-api.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/db-api.txt')
-rw-r--r--docs/db-api.txt54
1 files changed, 53 insertions, 1 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt
index e7b8183f6c..a4b920fb33 100644
--- a/docs/db-api.txt
+++ b/docs/db-api.txt
@@ -1173,6 +1173,58 @@ 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
+~~~~~
+
+**New in Django development version**
+
+Case-sensitive regular expression match.
+
+The regular expression syntax is that of the database backend in use. In the
+case of SQLite, which doesn't natively support regular-expression lookups, 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 REGEXP_LIKE(title, '^(an?|the) +', 'c'); -- Oracle
+
+ SELECT ... WHERE title ~ '^(An?|The) +'; -- PostgreSQL
+
+ SELECT ... WHERE title REGEXP '^(An?|The) +'; -- SQLite
+
+Using raw strings (e.g., ``r'foo'`` instead of ``'foo'``) for passing in the
+regular expression syntax is recommended.
+
+Regular expression matching is not supported on the ``ado_mssql`` backend.
+It will raise a ``NotImplementedError`` at runtime.
+
+iregex
+~~~~~~
+
+**New in Django development version**
+
+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 REGEXP_LIKE(title, '^(an?|the) +', 'i'); -- Oracle
+
+ SELECT ... WHERE title ~* '^(an?|the) +'; -- PostgreSQL
+
+ SELECT ... WHERE title REGEXP '(?i)^(an?|the) +'; -- SQLite
+
Default lookups are exact
-------------------------
@@ -1779,7 +1831,7 @@ use the default manager, or if you want to search a list of related objects,
you can provide ``get_object_or_404()`` with a manager object instead.
For example::
- # Get the author of blog instance `e` with a name of 'Fred'
+ # Get the author of blog instance e with a name of 'Fred'
a = get_object_or_404(e.authors, name='Fred')
# Use a custom manager 'recent_entries' in the search for an