How to use the pypika.functions function in PyPika

To help you get started, we’ve selected a few PyPika examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tortoise / tortoise-orm / tortoise / functions.py View on Github external
Provides a default value if field is null.

    :samp:`Coalesce("{FIELD_NAME}", {DEFAULT_VALUE})`
    """

    database_func = functions.Coalesce


class Lower(Function):
    """
    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
##############################################################################
github tortoise / tortoise-orm / tortoise / functions.py View on Github external
:samp:`Sum("{FIELD_NAME}")`
    """

    database_func = functions.Sum
    populate_field_object = True


class Max(Aggregate):
    """
    Returns largest value in the column.

    :samp:`Max("{FIELD_NAME}")`
    """

    database_func = functions.Max
    populate_field_object = True


class Min(Aggregate):
    """
    Returns smallest value in the column.

    :samp:`Min("{FIELD_NAME}")`
    """

    database_func = functions.Min
    populate_field_object = True


class Avg(Aggregate):
    """
github tortoise / tortoise-orm / tortoise / functions.py View on Github external
Returns lenth of text/blob.

    :samp:`Length("{FIELD_NAME}")`
    """

    database_func = functions.Length


class Coalesce(Function):
    """
    Provides a default value if field is null.

    :samp:`Coalesce("{FIELD_NAME}", {DEFAULT_VALUE})`
    """

    database_func = functions.Coalesce


class Lower(Function):
    """
    Converts text to lower case.

    :samp:`Lower("{FIELD_NAME}")`
    """

    database_func = functions.Lower


class Upper(Function):
    """
    Converts text to upper case.
github kayak / fireant / fireant / slicer / managers.py View on Github external
def _default_metric_definition(self, key):
        return fn.Sum(self.slicer.table.field(key))
github tortoise / tortoise-orm / tortoise / backends / mysql / executor.py View on Github external
def mysql_insensitive_ends_with(field: Term, value: str) -> Criterion:
    return Like(
        functions.Upper(functions.Cast(field, SqlTypes.CHAR)),
        functions.Upper(StrWrapper(f"%{escape_like(value)}")),
        escape="",
    )
github kayak / fireant / fireant / dataset / references.py View on Github external
return lambda metric: (original_field(metric) - ref_field(metric)) * (
                100 / fn.NullIf(ref_field(metric), 0)
            )
github kayak / fireant / fireant / database / vertica.py View on Github external
def date_add(self, field, date_part, interval):
        return fn.TimestampAdd(str(date_part), interval, field)
github kayak / fireant / fireant / database / postgresql.py View on Github external
def date_add(self, field, date_part, interval):
        return fn.DateAdd(str(date_part), interval, field)