RLIKE, REGEXP

141 views
Skip to first unread message

Jim Musil

unread,
Oct 10, 2007, 7:33:55 PM10/10/07
to sqlalchemy
I don't see support for RLIKE, NOT RLIKE, or REGEXP anywhere.

Is there support for this?

Jim

jason kirtland

unread,
Oct 10, 2007, 7:41:19 PM10/10/07
to sqlal...@googlegroups.com
Jim Musil wrote:
> I don't see support for RLIKE, NOT RLIKE, or REGEXP anywhere.
>
> Is there support for this?

Yes, you can use these operators and any others via the .op() method:

table.c.col1.op('rlike')('re')
not_(table.c.col1.op('rlike')('re'))
table.c.col1.op('regexp')('re')

-j

Eric Lemoine

unread,
Oct 11, 2007, 12:30:01 AM10/11/07
to sqlal...@googlegroups.com

As a a remark, ilike also is accessed in this way.

--
Eric

Jim Musil

unread,
Oct 12, 2007, 2:09:23 PM10/12/07
to sqlalchemy
Great! Thanks for pointing it out to me.

iain duncan

unread,
Oct 21, 2007, 4:30:07 PM10/21/07
to sqlal...@googlegroups.com

Is it possible to use them with the ORM too? Or am I misunderstanding
the above? If someone has the time to post an example of how one would
do an rlike version of

Resource.select_by( foo="bar" )

I'd love to see it.
Thanks
Iain


Paul Johnston

unread,
Oct 21, 2007, 4:36:15 PM10/21/07
to sqlal...@googlegroups.com
Hi,

>Resource.select_by( foo="bar" )
>
>
Untested, but I reckon this will work:

Resource.query.filter(Resource.foo.op('rlike')('bar'))

Paul

Michael Bayer

unread,
Oct 21, 2007, 5:12:46 PM10/21/07
to sqlal...@googlegroups.com

might need to call op() off the Table instance for now, might not
have added op() to the class-based properties....

iain duncan

unread,
Oct 21, 2007, 7:20:29 PM10/21/07
to sqlal...@googlegroups.com

Excuse what may be a stupid question, but is this for both 0.3 and 0.4
or just the new stuff? ( I know, I gotta upgrade soon now! )

Thanks
Iain


Michael Bayer

unread,
Oct 21, 2007, 9:11:10 PM10/21/07
to sqlal...@googlegroups.com

you can say query.filter(sometable.c.somecolumn.op('rlike')('bar'))
in any 0.3 or 0.4 version.

Reply all
Reply to author
Forward
0 new messages