Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def to_char(self, definition):
return fn.Cast(definition, enums.SqlTypes.CHAR)
def to_char(self, definition):
return fn.Cast(definition, enums.SqlTypes.VARCHAR)
def mysql_insensitive_contains(field: Term, value: str) -> Criterion:
return Like(
functions.Upper(functions.Cast(field, SqlTypes.CHAR)),
functions.Upper(StrWrapper(f"%{escape_like(value)}%")),
escape="",
)
def mysql_insensitive_starts_with(field: Term, value: str) -> Criterion:
return Like(
functions.Upper(functions.Cast(field, SqlTypes.CHAR)),
functions.Upper(StrWrapper(f"{escape_like(value)}%")),
escape="",
)
def mysql_starts_with(field: Term, value: str) -> Criterion:
return Like(
functions.Cast(field, SqlTypes.CHAR), StrWrapper(f"{escape_like(value)}%"), escape=""
)
def get_special_params_sql(self, **kwargs):
return "USING {type}".format(type=self.encoding.value)
class ToChar(Function):
def __init__(self, term, as_type, alias=None):
super(ToChar, self).__init__("TO_CHAR", term, as_type, alias=alias)
class Signed(Cast):
def __init__(self, term, alias=None):
super(Signed, self).__init__(term, SqlTypes.SIGNED, alias=alias)
class Unsigned(Cast):
def __init__(self, term, alias=None):
super(Unsigned, self).__init__(term, SqlTypes.UNSIGNED, alias=alias)
class Date(Function):
def __init__(self, term, alias=None):
super(Date, self).__init__("DATE", term, alias=alias)
class DateDiff(Function):
def __init__(self, interval, start_date, end_date, alias=None):
super(DateDiff, self).__init__(
"DATEDIFF", interval, start_date, end_date, alias=alias
)
def mysql_ends_with(field: Term, value: str) -> Criterion:
return Like(
functions.Cast(field, SqlTypes.CHAR), StrWrapper(f"%{escape_like(value)}"), escape=""
)
class Convert(Function):
def __init__(self, term, encoding, alias=None):
super(Convert, self).__init__("CONVERT", term, alias=alias)
self.encoding = encoding
def get_special_params_sql(self, **kwargs):
return "USING {type}".format(type=self.encoding.value)
class ToChar(Function):
def __init__(self, term, as_type, alias=None):
super(ToChar, self).__init__("TO_CHAR", term, as_type, alias=alias)
class Signed(Cast):
def __init__(self, term, alias=None):
super(Signed, self).__init__(term, SqlTypes.SIGNED, alias=alias)
class Unsigned(Cast):
def __init__(self, term, alias=None):
super(Unsigned, self).__init__(term, SqlTypes.UNSIGNED, alias=alias)
class Date(Function):
def __init__(self, term, alias=None):
super(Date, self).__init__("DATE", term, alias=alias)
class DateDiff(Function):
def __init__(self, interval, start_date, end_date, alias=None):
def function_cast(self, term: Term) -> Term:
return functions.Cast(term, SqlTypes.NUMERIC)
def __init__(self, term, as_type, alias=None):
super(Cast, self).__init__("CAST", term, alias=alias)
self.as_type = as_type