MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / custom_op

Class custom_op

lib/sqlalchemy/sql/operators.py:468–594  ·  view source on GitHub ↗

Represent a 'custom' operator. :class:`.custom_op` is normally instantiated when the :meth:`.Operators.op` or :meth:`.Operators.bool_op` methods are used to create a custom operator callable. The class can also be used directly when programmatically constructing expressions. E.g.

Source from the content-addressed store, hash-verified

466
467
468class custom_op(OperatorType, Generic[_T]):
469 """Represent a 'custom' operator.
470
471 :class:`.custom_op` is normally instantiated when the
472 :meth:`.Operators.op` or :meth:`.Operators.bool_op` methods
473 are used to create a custom operator callable. The class can also be
474 used directly when programmatically constructing expressions. E.g.
475 to represent the "factorial" operation::
476
477 from sqlalchemy.sql import UnaryExpression
478 from sqlalchemy.sql import operators
479 from sqlalchemy import Numeric
480
481 unary = UnaryExpression(
482 table.c.somecolumn, modifier=operators.custom_op("!"), type_=Numeric
483 )
484
485 .. seealso::
486
487 :meth:`.Operators.op`
488
489 :meth:`.Operators.bool_op`
490
491 """ # noqa: E501
492
493 __name__ = "custom_op"
494
495 __slots__ = (
496 "opstring",
497 "precedence",
498 "is_comparison",
499 "natural_self_precedent",
500 "eager_grouping",
501 "return_type",
502 "python_impl",
503 "operator_class",
504 "visit_name",
505 )
506
507 def __init__(
508 self,
509 opstring: str,
510 *,
511 precedence: int = 0,
512 is_comparison: bool = False,
513 return_type: Optional[
514 Union[Type[TypeEngine[_T]], TypeEngine[_T]]
515 ] = None,
516 natural_self_precedent: bool = False,
517 eager_grouping: bool = False,
518 python_impl: Optional[Callable[..., Any]] = None,
519 operator_class: OperatorClass = OperatorClass.BASE,
520 visit_name: Optional[str] = None,
521 ):
522 """Create a new :class:`.custom_op`.
523
524 See :meth:`.Operators.op` for parameter information.
525

Callers 1

opMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected