MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / self_group

Method self_group

lib/sqlalchemy/sql/elements.py:658–685  ·  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

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

Callers 1

_negateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected