Return a :class:`.Query` construct which will correlate the given FROM clauses to that of an enclosing :class:`.Query` or :func:`~.expression.select`. The method here accepts mapped classes, :func:`.aliased` constructs, and :class:`_orm.Mapper` constructs as argument
(
self,
*fromclauses: Union[Literal[None, False], _FromClauseArgument],
)
| 1179 | |
| 1180 | @_generative |
| 1181 | def correlate( |
| 1182 | self, |
| 1183 | *fromclauses: Union[Literal[None, False], _FromClauseArgument], |
| 1184 | ) -> Self: |
| 1185 | """Return a :class:`.Query` construct which will correlate the given |
| 1186 | FROM clauses to that of an enclosing :class:`.Query` or |
| 1187 | :func:`~.expression.select`. |
| 1188 | |
| 1189 | The method here accepts mapped classes, :func:`.aliased` constructs, |
| 1190 | and :class:`_orm.Mapper` constructs as arguments, which are resolved |
| 1191 | into expression constructs, in addition to appropriate expression |
| 1192 | constructs. |
| 1193 | |
| 1194 | The correlation arguments are ultimately passed to |
| 1195 | :meth:`_expression.Select.correlate` |
| 1196 | after coercion to expression constructs. |
| 1197 | |
| 1198 | The correlation arguments take effect in such cases |
| 1199 | as when :meth:`_query.Query.from_self` is used, or when |
| 1200 | a subquery as returned by :meth:`_query.Query.subquery` is |
| 1201 | embedded in another :func:`_expression.select` construct. |
| 1202 | |
| 1203 | .. seealso:: |
| 1204 | |
| 1205 | :meth:`_sql.Select.correlate` - v2 equivalent method. |
| 1206 | |
| 1207 | """ |
| 1208 | |
| 1209 | self._auto_correlate = False |
| 1210 | if fromclauses and fromclauses[0] in {None, False}: |
| 1211 | self._correlate = () |
| 1212 | else: |
| 1213 | self._correlate = self._correlate + tuple( |
| 1214 | coercions.expect(roles.FromClauseRole, f) for f in fromclauses |
| 1215 | ) |
| 1216 | return self |
| 1217 | |
| 1218 | @_generative |
| 1219 | def autoflush(self, setting: bool) -> Self: |
no outgoing calls