How to use the pypika.terms.ArithmeticExpression 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 kayak / pypika / pypika / terms.py View on Github external
def __rtruediv__(self, other):
        return ArithmeticExpression(Arithmetic.div, self.wrap_constant(other), self)
github kayak / fireant / fireant / dataset / fields.py View on Github external
def __add__(self, other):
        return ArithmeticExpression(Arithmetic.add, self, other)
github kayak / pypika / pypika / terms.py View on Github external
def __sub__(self, other):
        return ArithmeticExpression(Arithmetic.sub, self, self.wrap_constant(other))
github kayak / fireant / fireant / dataset / fields.py View on Github external
def __sub__(self, other):
        return ArithmeticExpression(Arithmetic.sub, self, other)
github kayak / pypika / pypika / terms.py View on Github external
def __rmul__(self, other):
        return ArithmeticExpression(Arithmetic.mul, self.wrap_constant(other), self)
github kayak / pypika / pypika / terms.py View on Github external
def __mul__(self, other):
        return ArithmeticExpression(Arithmetic.mul, self, self.wrap_constant(other))
github kayak / fireant / fireant / dataset / fields.py View on Github external
def __mul__(self, other):
        return ArithmeticExpression(Arithmetic.mul, self, other)
github kayak / pypika / pypika / terms.py View on Github external
def __add__(self, other):
        return ArithmeticExpression(Arithmetic.add, self, self.wrap_constant(other))
github tortoise / tortoise-orm / tortoise / expressions.py View on Github external
name = arithmetic_expression_or_field.name
            try:
                arithmetic_expression_or_field.name = model._meta.fields_db_projection[name]

                field_object = model._meta.fields_map.get(name, None)
                if field_object:
                    func = field_object.get_for_dialect(
                        model._meta.db.capabilities.dialect, "function_cast"
                    )
                    if func:
                        arithmetic_expression_or_field = func(
                            field_object, arithmetic_expression_or_field
                        )
            except KeyError:
                raise FieldError(f"There is no non-virtual field {name} on Model {model.__name__}")
        elif isinstance(arithmetic_expression_or_field, ArithmeticExpression):
            left = arithmetic_expression_or_field.left
            right = arithmetic_expression_or_field.right
            (
                arithmetic_expression_or_field.left,
                left_field_object,
            ) = cls.resolver_arithmetic_expression(model, left)
            if left_field_object:
                if field_object and type(field_object) != type(left_field_object):
                    raise FieldError(
                        "Cannot use arithmetic expression between different field type"
                    )
                field_object = left_field_object

            (
                arithmetic_expression_or_field.right,
                right_field_object,