def compile_like(compile, expr, state): compile_binary(compile, expr, state) if expr.escape is not Undef: state.sql.append(' ESCAPE ') compile( Value(expr.escape) if isinstance(expr.escape, string_types) else expr.escape, state)
def compile_escapeforlike(compile, expr, state): escaped = expr.expr for k, v in expr.escape_map: escaped = func.Replace(escaped, Value(k), Value(v)) compile(escaped, state)
def riendswith(self, other): pattern = EscapeForLike(self._expr) return ILike(other, Concat(Value('%'), pattern), escape=pattern.escape)
def ricontains(self, other): pattern = EscapeForLike(self._expr) return ILike(other, Concat(Value('%'), pattern, Value('%')), escape=pattern.escape)
def ristartswith(self, other): pattern = EscapeForLike(self._expr) return ILike(other, Concat(pattern, Value('%')), escape=pattern.escape)
def contains(self, other): # TODO: ambiguous with "@>" operator of postgresql. pattern = EscapeForLike(other) return Like(self._expr, Concat(Value('%'), pattern, Value('%')), escape=pattern.escape)