From c7b489b25802f7a25ef78d0731411295c611cc1c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 5 Aug 2020 21:47:43 -0400 Subject: Implement relationship AND criteria; global loader criteria Added the ability to add arbitrary criteria to the ON clause generated by a relationship attribute in a query, which applies to methods such as :meth:`_query.Query.join` as well as loader options like :func:`_orm.joinedload`. Additionally, a "global" version of the option allows limiting criteria to be applied to particular entities in a query globally. Documentation is minimal at this point, new examples will be coming in a subsequent commit. Some adjustments to execution options in how they are represented in the ORMExecuteState as well as well as a few ORM tests that forgot to get merged in a preceding commit. Fixes: #4472 Change-Id: I2b8fc57092dedf35ebd16f6343ad0f0d7d332beb --- lib/sqlalchemy/sql/compiler.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index ac4055bdf..b8984316c 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -792,6 +792,10 @@ class SQLCompiler(Compiled): def prefetch(self): return list(self.insert_prefetch + self.update_prefetch) + @util.memoized_property + def _global_attributes(self): + return {} + @util.memoized_instancemethod def _init_cte_state(self): """Initialize collections related to CTEs only if -- cgit v1.2.1