Proposal: Regular Expression Field Lookups

6 views
Skip to first unread message

Tom Tobin

unread,
Mar 4, 2006, 4:36:13 PM3/4/06
to django-d...@googlegroups.com
Having found myself fiending for regular expression lookups in Django,
I implemented the behavior in ticket #1465. It has a few caveats:
case-sensitive regexes only work in PostgreSQL, PCRE-ish regexes only
work in PostgreSQL and sqlite (the other backends use POSIX "extended"
regexes), and regular expressions aren't available at all in the
ADO/MSSQL backend. Furthermore, it implements a slightly
backwards-incompatible change with regards to the admin interface:
regular expression searches can be performed by placing the search
phrase between slashes (e.g., /like this/).

Thoughts, criticism, etc?

Ian Holsman

unread,
Mar 4, 2006, 5:11:26 PM3/4/06
to django-d...@googlegroups.com
I think regex searching is a great idea, and actually was about to do
the same thing for mysql a while back.

I would love to see this go into the mainstream, as most of my users
are more familiar with Perl RegEx's than SQL like syntax.

so +1 from me.


--
I...@Holsman.net -- blog: http://feh.holsman.net/ -- PH: ++61-3-9877-0909

If everything seems under control, you're not going fast enough. -
Mario Andretti

Eugene Lazutkin

unread,
Mar 4, 2006, 7:19:19 PM3/4/06
to django-d...@googlegroups.com

+1.

Obviously RegEx search doesn't depend on indexes. It means it is quite
possible to implement it in MSSQL server-side, or client-side. Of course
we have bigger problems than that with MSSQL in Django, e.g.,
offset-limit select. ;-)

Thanks,

Eugene

Jacob Kaplan-Moss

unread,
Mar 6, 2006, 7:30:52 PM3/6/06
to django-d...@googlegroups.com
On Mar 4, 2006, at 3:36 PM, Tom Tobin wrote:
> Furthermore, it implements a slightly
> backwards-incompatible change with regards to the admin interface:
> regular expression searches can be performed by placing the search
> phrase between slashes (e.g., /like this/).

I'm -1 on this; the admin interface isn't designed for people who
know what regexes are, and exposing the inconsistencies of different
db engines to those types of people is double-bad.

Other than that, your patch looks really good. It needs
documentation updates and tests before it can be checked in. I'll
write 'em when I get a chance, but if you're anxious you can always
write 'em yourself.

That's actually a good point for anyone with patches who's still
paying attention: if you include docs and tests with your patches,
you'll decrease your wait time hugely.

Jacob

Ian Holsman

unread,
Mar 6, 2006, 7:40:55 PM3/6/06
to django-d...@googlegroups.com
On 3/7/06, Jacob Kaplan-Moss <ja...@jacobian.org> wrote:
>
> On Mar 4, 2006, at 3:36 PM, Tom Tobin wrote:
> > Furthermore, it implements a slightly
> > backwards-incompatible change with regards to the admin interface:
> > regular expression searches can be performed by placing the search
> > phrase between slashes (e.g., /like this/).
>
> I'm -1 on this; the admin interface isn't designed for people who
> know what regexes are, and exposing the inconsistencies of different
> db engines to those types of people is double-bad.
>
but this patch isn't just for the admin interface, it would allow any
application to use a regex easily.
as for the inconsistencies..

I put it to you (and others) that most developers work with only one
database, and that most apps are written for personal use and not to
distribute to the hungry masses.

so having it behave differently is OK, as long as the differences are
documented.

personally I'd like to have django support things like mysql full text
search, or the new scheduler function... even if there is no direct
equivalent in postgres for example. It might make porting applications
across DB's harder.. but my position is that most people don't do
that.

but that's just me.

> Other than that, your patch looks really good. It needs
> documentation updates and tests before it can be checked in. I'll
> write 'em when I get a chance, but if you're anxious you can always
> write 'em yourself.
>
> That's actually a good point for anyone with patches who's still
> paying attention: if you include docs and tests with your patches,
> you'll decrease your wait time hugely.
>
> Jacob
>
>
>

Jacob Kaplan-Moss

unread,
Mar 6, 2006, 7:43:51 PM3/6/06
to django-d...@googlegroups.com

On Mar 6, 2006, at 6:40 PM, Ian Holsman wrote:
> but this patch isn't just for the admin interface, it would allow any
> application to use a regex easily.
> as for the inconsistencies..

Ah, look like I wasn't clear enough:

I'm -1 to allowing regex access *in the admin interface*; the rest of
it looks like a great idea to me.

Jacob

Tom Tobin

unread,
Mar 6, 2006, 8:04:53 PM3/6/06
to django-d...@googlegroups.com
On 3/6/06, Jacob Kaplan-Moss <ja...@jacobian.org> wrote:
>
> On Mar 4, 2006, at 3:36 PM, Tom Tobin wrote:
> > Furthermore, it implements a slightly
> > backwards-incompatible change with regards to the admin interface:
> > regular expression searches can be performed by placing the search
> > phrase between slashes (e.g., /like this/).
>
> I'm -1 on this; the admin interface isn't designed for people who
> know what regexes are, and exposing the inconsistencies of different
> db engines to those types of people is double-bad.

Point taken; there's nothing stopping someone from plugging the
functionality into the admin on a given install if they want it for
development purposes, but having it there by default for 99% of users
would add little in return for the mental overhead.

> Other than that, your patch looks really good. It needs
> documentation updates and tests before it can be checked in. I'll
> write 'em when I get a chance, but if you're anxious you can always
> write 'em yourself.
>
> That's actually a good point for anyone with patches who's still
> paying attention: if you include docs and tests with your patches,
> you'll decrease your wait time hugely.

Yeah, I really ought to comb back over my submissions and address that. :-)

Reply all
Reply to author
Forward
0 new messages