[patch] regular expression field lookups
|Reported by:||Owned by:||Adrian Holovaty|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The attached patch implements regular expression field lookups against r2487 of trunk.
The lookups are performed via "
fieldname__regex" or "
fieldname__iregex" for case-sensitive and -insensitive matching, respectively.
Only PostgreSQL implements case-sensitive matching; for all other databases, case-insensitive matching is performed regardless of which type is specified.
Only PostgreSQL (assuming system defaults) and sqlite implement PCRE-ish "advanced" regular expressions; the other databases only support POSIX "extended" regular expressions.
MSSQL/Transact-SQL does not implement regular expressions (as far as I can tell from the documentation available at MSDN); attempting to use
iregex field lookups with this backend will raise a
Regular expression searches can be performed through the admin interface by prepending and appending a slash ("
/") character to the search term (e.g.,
/like this/). This is backwards-incompatible, but with a low chance of collision with existing usage (i.e., it's unlikely that a user is going to input a search phrase both beginning and ending with a slash; I considered adding a toggle for this behavior in
settings.py, but decided against it for the time being).