#1465 closed enhancement (fixed)
[patch] regular expression field lookups
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Other) | Version: | |
Severity: | minor | Keywords: | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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 regex
or iregex
field lookups with this backend will raise a NotImplementedError
.
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).
Attachments (6)
Change History (16)
by , 19 years ago
Attachment: | trunk-regex_field_lookup.diff added |
---|
comment:1 by , 19 years ago
priority: | normal → low |
---|---|
Severity: | normal → minor |
comment:2 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:3 by , 18 years ago
IIRC, the core developers liked the idea but disliked the admin regex searches. I'll create an updated patch against current trunk if I know what behavior to implement. :)
by , 17 years ago
Attachment: | regex-field-lookups.diff added |
---|
Patch aganst r5486 of trunk to implement regex field lookups
comment:4 by , 17 years ago
I've brought the patch for this ticket's implementation up to date; documentation is now included, as well as full support for both case sensitive and insensitive matching on the supported platforms (MySQL, PostgreSQL, and sqlite).
by , 17 years ago
Attachment: | regex-field-lookups.2.diff added |
---|
Patch aganst r5490 of trunk to implement regex field lookups, w/docs, w/tests
by , 17 years ago
Attachment: | regex-field-lookups.3.diff added |
---|
Patch aganst r5519 of trunk (post-oracle-merge) to implement regex field lookups
comment:7 by , 17 years ago
Initially I got this error:
File "/home/ikelly/projects/django.trunk/django/db/models/query.py", line 802, in get_where_clause if settings.DATABASE_ENGINE == 'oracle': NameError: global name 'settings' is not defined
After adding the appropriate import statement, the test cases passed and I didn't find any bugs.
comment:8 by , 17 years ago
I think we're all set with the latest version of the patch. Requesting final review and (hopefully) commit. ^_^
comment:9 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:10 by , 17 years ago
Reporter: | changed from | to
---|
patch against r2487 of trunk to implement regular expression field lookups