def zdb_like_op(left, right, c, compiler, tables, format_args):
r"""Implement the ``LIKE`` operator.
In a normal context, produces the expression::
column:"foo"
E.g.::
stmt = select([sometable]).\
where(sometable.c.column.like("foo"))
In a regex context, produces the expression::
column:~"foo[a-z]"
E.g.::
stmt = select([sometable]).\
where(sometable.c.column.like(re.compile("foo[a-z]")))
"""
from sqlalchemy_zdb.compiler import compile_clause
if isinstance(right.value, re._pattern_type):
_oper = ":~"
else:
_oper = ":"
return "%s%s%s" % (left.name, _oper, compile_clause(right, compiler, tables, format_args))
评论列表
文章目录