MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / self_group

Method self_group

lib/sqlalchemy/sql/elements.py:643–670  ·  view source on GitHub ↗

Apply a 'grouping' to this :class:`_expression.ClauseElement`. This method is overridden by subclasses to return a "grouping" construct, i.e. parenthesis. In particular it's used by "binary" expressions to provide a grouping around themselves when placed into a lar

(
        self, against: Optional[OperatorType] = None
    )

Source from the content-addressed store, hash-verified

641 return traversals.compare(self, other, **kw)
642
643 def self_group(
644 self, against: Optional[OperatorType] = None
645 ) -> ClauseElement:
646 """Apply a 'grouping' to this :class:`_expression.ClauseElement`.
647
648 This method is overridden by subclasses to return a "grouping"
649 construct, i.e. parenthesis. In particular it's used by "binary"
650 expressions to provide a grouping around themselves when placed into a
651 larger expression, as well as by :func:`_expression.select`
652 constructs when placed into the FROM clause of another
653 :func:`_expression.select`. (Note that subqueries should be
654 normally created using the :meth:`_expression.Select.alias` method,
655 as many
656 platforms require nested SELECT statements to be named).
657
658 As expressions are composed together, the application of
659 :meth:`self_group` is automatic - end-user code should never
660 need to use this method directly. Note that SQLAlchemy's
661 clause constructs take operator precedence into account -
662 so parenthesis might not be needed, for example, in
663 an expression like ``x OR (y AND z)`` - AND takes precedence
664 over OR.
665
666 The base :meth:`self_group` method of
667 :class:`_expression.ClauseElement`
668 just returns self.
669 """
670 return self
671
672 def _ungroup(self) -> ClauseElement:
673 """Return this :class:`_expression.ClauseElement`

Callers 1

_negateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected