diff options
Diffstat (limited to 'lib/sqlalchemy/orm/context.py')
-rw-r--r-- | lib/sqlalchemy/orm/context.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py index ff0cdd680..4f24103df 100644 --- a/lib/sqlalchemy/orm/context.py +++ b/lib/sqlalchemy/orm/context.py @@ -529,6 +529,7 @@ class ORMFromStatementCompileState(ORMCompileState): _has_orm_entities = False multi_row_eager_loaders = False + eager_adding_joins = False compound_eager_adapter = None extra_criteria_entities = _EMPTY_DICT @@ -794,6 +795,7 @@ class ORMSelectCompileState(ORMCompileState, SelectState): _has_orm_entities = False multi_row_eager_loaders = False + eager_adding_joins = False compound_eager_adapter = None correlate = None @@ -1106,7 +1108,11 @@ class ORMSelectCompileState(ORMCompileState, SelectState): if self.order_by is False: self.order_by = None - if self.multi_row_eager_loaders and self._should_nest_selectable: + if ( + self.multi_row_eager_loaders + and self.eager_adding_joins + and self._should_nest_selectable + ): self.statement = self._compound_eager_statement() else: self.statement = self._simple_statement() |