Django

Code

Show
Ignore:
Timestamp:
07/01/07 00:55:01 (2 years ago)
Author:
mtredinnick
Message:

unicode: Merged changes from trunk up to [5579].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode

    • Property svnmerge-integrated changed from /django/trunk:1-5530 to /django/trunk:1-5579
  • django/branches/unicode/docs/db-api.txt

    r5531 r5580  
    11741174database to add the full-text index. 
    11751175 
     1176regex 
     1177~~~~~ 
     1178 
     1179**New in Django development version** 
     1180 
     1181Case-sensitive regular expression match. 
     1182 
     1183The regular expression syntax is that of the database backend in use. In the 
     1184case of SQLite, which doesn't natively support regular-expression lookups, the 
     1185syntax is that of Python's ``re`` module. 
     1186 
     1187Example:: 
     1188 
     1189    Entry.objects.get(title__regex=r'^(An?|The) +') 
     1190 
     1191SQL equivalents:: 
     1192 
     1193    SELECT ... WHERE title REGEXP BINARY '^(An?|The) +'; -- MySQL 
     1194 
     1195    SELECT ... WHERE REGEXP_LIKE(title, '^(an?|the) +', 'c'); -- Oracle 
     1196 
     1197    SELECT ... WHERE title ~ '^(An?|The) +'; -- PostgreSQL 
     1198 
     1199    SELECT ... WHERE title REGEXP '^(An?|The) +'; -- SQLite 
     1200 
     1201Using raw strings (e.g., ``r'foo'`` instead of ``'foo'``) for passing in the 
     1202regular expression syntax is recommended. 
     1203 
     1204Regular expression matching is not supported on the ``ado_mssql`` backend. 
     1205It will raise a ``NotImplementedError`` at runtime. 
     1206 
     1207iregex 
     1208~~~~~~ 
     1209 
     1210**New in Django development version** 
     1211 
     1212Case-insensitive regular expression match. 
     1213 
     1214Example:: 
     1215 
     1216    Entry.objects.get(title__iregex=r'^(an?|the) +') 
     1217 
     1218SQL equivalents:: 
     1219 
     1220    SELECT ... WHERE title REGEXP '^(an?|the) +'; -- MySQL 
     1221 
     1222    SELECT ... WHERE REGEXP_LIKE(title, '^(an?|the) +', 'i'); -- Oracle 
     1223 
     1224    SELECT ... WHERE title ~* '^(an?|the) +'; -- PostgreSQL 
     1225 
     1226    SELECT ... WHERE title REGEXP '(?i)^(an?|the) +'; -- SQLite 
     1227 
    11761228Default lookups are exact 
    11771229------------------------- 
     
    17801832For example:: 
    17811833 
    1782     # Get the author of blog instance `e` with a name of 'Fred' 
     1834    # Get the author of blog instance e with a name of 'Fred' 
    17831835    a = get_object_or_404(e.authors, name='Fred') 
    17841836