operators.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:sqlalchemy_zdb 作者: skftn 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号