dbbase.column_types.WriteOnlyColumn.op¶
-
WriteOnlyColumn.op(opstring, precedence=0, is_comparison=False, return_type=None)¶ Produce a generic operator function.
e.g.:
somecolumn.op("*")(5)
produces:
somecolumn * 5
This function can also be used to make bitwise operators explicit. For example:
somecolumn.op('&')(0xff)
is a bitwise AND of the value in
somecolumn.- Parameters
operator – a string which will be output as the infix operator between this element and the expression passed to the generated function.
precedence – precedence to apply to the operator, when parenthesizing expressions. A lower number will cause the expression to be parenthesized when applied against another operator with higher precedence. The default value of
0is lower than all operators except for the comma (,) andASoperators. A value of 100 will be higher or equal to all operators, and -100 will be lower than or equal to all operators.is_comparison –
if True, the operator will be considered as a “comparison” operator, that is which evaluates to a boolean true/false value, like
==,>, etc. This flag should be set so that ORM relationships can establish that the operator is a comparison operator when used in a custom join condition.New in version 0.9.2: - added the :paramref:`.Operators.op.is_comparison` flag.
return_type –
a
TypeEngineclass or object that will force the return type of an expression produced by this operator to be of that type. By default, operators that specify :paramref:`.Operators.op.is_comparison` will resolve toBoolean, and those that do not will be of the same type as the left-hand operand.New in version 1.2.0b3: - added the :paramref:`.Operators.op.return_type` argument.
See also
types_operators
relationship_custom_operator