From 6f4e933fcc78da11ec43214efd3472192030eced Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sun, 1 Jul 2007 01:17:51 +0000 Subject: newforms-admin: Merged to [5571] git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5572 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/db-api.txt | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'docs/db-api.txt') 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 -- cgit v1.3