Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def mysql_insensitive_exact(field: Term, value: str) -> Criterion:
return functions.Upper(functions.Cast(field, SqlTypes.CHAR)).eq(functions.Upper(str(value)))
def insensitive_ends_with(field: Term, value: str) -> Criterion:
return Like(Upper(field), field.wrap_constant(Upper(f"%{escape_like(value)}")))
def insensitive_starts_with(field: Term, value: str) -> Criterion:
return Like(Upper(field), field.wrap_constant(Upper(f"{escape_like(value)}%")))
Converts text to lower case.
:samp:`Lower("{FIELD_NAME}")`
"""
database_func = functions.Lower
class Upper(Function):
"""
Converts text to upper case.
:samp:`Upper("{FIELD_NAME}")`
"""
database_func = functions.Upper
##############################################################################
# Aggregate functions
##############################################################################
class Count(Aggregate):
"""
Counts the no of entries for that column.
:samp:`Count("{FIELD_NAME}")`
"""
database_func = functions.Count
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 insensitive_exact(field: Term, value: str) -> Criterion:
return Upper(field).eq(Upper(str(value)))