Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __ne__(self, other):
return BasicCriterion(Equality.ne, self, self.wrap_constant(other))
def __le__(self, other):
return BasicCriterion(Equality.lte, self, self.wrap_constant(other))
def __lt__(self, other):
return BasicCriterion(Equality.lt, self, self.wrap_constant(other))
def has_any_keys(self, other: Iterable):
return BasicCriterion(JSONOperators.HAS_ANY_KEYS, self, Array(*other))
def __gt__(self, other):
return BasicCriterion(Equality.gt, self, self.wrap_constant(other))
def not_ilike(self, expr):
return BasicCriterion(Matching.not_ilike, self, self.wrap_constant(expr))
def __ge__(self, other):
return BasicCriterion(Equality.gte, self, self.wrap_constant(other))
value = self.value.replace(quote_char, quote_char * 2)
if dialect == "mysql":
value = value.replace("\\", "\\\\")
return format_quotes(value, quote_char)
if isinstance(self.value, bool):
return str.lower(str(self.value))
if self.value is None:
return "null"
return str(self.value)
ValueWrapper.get_value_sql = get_value_sql
##############################################################################
class Like(BasicCriterion): # type: ignore
def __init__(self, left, right, alias=None, escape=" ESCAPE '\\'") -> None:
"""
A Like that supports an ESCAPE clause
"""
super().__init__(" LIKE ", left, right, alias=alias)
self.escape = escape
def get_sql(self, quote_char='"', with_alias=False, **kwargs):
sql = "{left}{comparator}{right}{escape}".format(
comparator=self.comparator,
left=self.left.get_sql(quote_char=quote_char, **kwargs),
right=self.right.get_sql(quote_char=quote_char, **kwargs),
escape=self.escape,
)
if with_alias and self.alias: # pragma: nocoverage
return '{sql} "{alias}"'.format(sql=sql, alias=self.alias)
def has_keys(self, other: Iterable):
return BasicCriterion(JSONOperators.HAS_KEYS, self, Array(*other))
def __eq__(self, other):
return BasicCriterion(Equality.eq, self, self.wrap_constant(other))