postgresql regular expression operators
match operator not implemented
in sqlalchemy/databases/postgres.py 727 just add sql_operators.match_op: lambda x, y, escape=None: '%s ~ %s' % (x, y) + (escape and ' ESCAPE \'%s\'' % escape or ''),
and it works for me CAVEAT sql might crash if improper regexp syntax entered.
- missing imatch / notmatch ....
(these matching functions are still used with same syntax) http://www.postgresql.org/docs/7.4/interactive/functions-matching.html
Comments (10)
-
-
Account Deleted Now I see Indeed.
http://www.postgresql.org/docs/8.3/static/textsearch-features.html
You're right. It works better by using fts anyway.
Thanks.
''cherry on top out of initial topic''
-
Is it possible without calling pure sql in a close future to get the search rank / order by rank implicit (don't seem trivial too me) ?
-
is there a doc on the clean way to implement the "basic" regexp search by declaring an operator somewhere ?
-
-
repo owner - changed title to postgresql regular expression operators
- marked as major
- changed milestone to 0.8.xx
demo (using attached patch):
from sqlalchemy import * from sqlalchemy.dialects import postgresql metadata = MetaData() t = Table('t', metadata, Column('x', postgresql.VARCHAR(30)) ) print t.c.x.regexp("foo").compile(dialect=postgresql.dialect()) print (~t.c.x.regexp("foo")).compile(dialect=postgresql.dialect()) print (~t.c.x.iregexp("foo")).compile(dialect=postgresql.dialect())
-
repo owner - changed milestone to 0.9.0
-
repo owner - changed milestone to 0.9.xx
-
repo owner - changed milestone to 1.0.xx
-
repo owner - changed milestone to 1.1
- edited description
-
repo owner - changed milestone to 1.2
nobody is looking for these much, keep pushing them...
-
repo owner the current gerrit for this is at https://gerrit.sqlalchemy.org/#/c/101/ . this is largely ready-ish.
-
repo owner - edited description
- changed milestone to 1.3
1.3 for the moment, the gerrit needs some work and this is not crtiical
- Log in to comment
Except you'll have to specify something other than match_op since we're using that for the Full Text Searching.