postgresql regular expression operators

Issue #1390 new
Anonymous created an issue

match operator not implemented

in sqlalchemy/databases/ 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)

Comments (11)

  1. Michael Bayer repo owner

    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())
  2. Log in to comment