MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / correlate

Method correlate

lib/sqlalchemy/sql/selectable.py:6630–6700  ·  view source on GitHub ↗

r"""Return a new :class:`_expression.Select` which will correlate the given FROM clauses to that of an enclosing :class:`_expression.Select`. Calling this method turns off the :class:`_expression.Select` object's default behavior of "auto-correlation". Normally, FRO

(
        self,
        *fromclauses: Union[Literal[None, False], _FromClauseArgument],
    )

Source from the content-addressed store, hash-verified

6628
6629 @_generative
6630 def correlate(
6631 self,
6632 *fromclauses: Union[Literal[None, False], _FromClauseArgument],
6633 ) -> Self:
6634 r"""Return a new :class:`_expression.Select`
6635 which will correlate the given FROM
6636 clauses to that of an enclosing :class:`_expression.Select`.
6637
6638 Calling this method turns off the :class:`_expression.Select` object's
6639 default behavior of "auto-correlation". Normally, FROM elements
6640 which appear in a :class:`_expression.Select`
6641 that encloses this one via
6642 its :term:`WHERE clause`, ORDER BY, HAVING or
6643 :term:`columns clause` will be omitted from this
6644 :class:`_expression.Select`
6645 object's :term:`FROM clause`.
6646 Setting an explicit correlation collection using the
6647 :meth:`_expression.Select.correlate`
6648 method provides a fixed list of FROM objects
6649 that can potentially take place in this process.
6650
6651 When :meth:`_expression.Select.correlate`
6652 is used to apply specific FROM clauses
6653 for correlation, the FROM elements become candidates for
6654 correlation regardless of how deeply nested this
6655 :class:`_expression.Select`
6656 object is, relative to an enclosing :class:`_expression.Select`
6657 which refers to
6658 the same FROM object. This is in contrast to the behavior of
6659 "auto-correlation" which only correlates to an immediate enclosing
6660 :class:`_expression.Select`.
6661 Multi-level correlation ensures that the link
6662 between enclosed and enclosing :class:`_expression.Select`
6663 is always via
6664 at least one WHERE/ORDER BY/HAVING/columns clause in order for
6665 correlation to take place.
6666
6667 If ``None`` is passed, the :class:`_expression.Select`
6668 object will correlate
6669 none of its FROM entries, and all will render unconditionally
6670 in the local FROM clause.
6671
6672 :param \*fromclauses: one or more :class:`.FromClause` or other
6673 FROM-compatible construct such as an ORM mapped entity to become part
6674 of the correlate collection; alternatively pass a single value
6675 ``None`` to remove all existing correlations.
6676
6677 .. seealso::
6678
6679 :meth:`_expression.Select.correlate_except`
6680
6681 :ref:`tutorial_scalar_subquery`
6682
6683 """
6684
6685 # tests failing when we try to change how these
6686 # arguments are passed
6687

Callers 3

_anonymous_fromclauseMethod · 0.45
correlateMethod · 0.45
correlateMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected