diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-03-17 08:59:09 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-03-17 09:00:30 -0400 |
| commit | 484910a25bdc4ad4bb9d96ee68981a6fb631e1a8 (patch) | |
| tree | b32ed882ed991608c1e993e72c8d50c12278d05e /lib/sqlalchemy/orm/query.py | |
| parent | ecb392c5f927ab117f9704ce373bf2af1dbe5b69 (diff) | |
| download | sqlalchemy-484910a25bdc4ad4bb9d96ee68981a6fb631e1a8.tar.gz | |
Ensure entity or None returned from _entity_from_pre_ent_zero()
Fixed regression where the :meth:`_orm.Query.exists` method would fail to
create an expression if the entity list of the :class:`_orm.Query` were
an arbitrary SQL column expression.
Fixes: #6076
Change-Id: I292dd5f527b2cbc1b76ca765b4ea321ef8535709
Diffstat (limited to 'lib/sqlalchemy/orm/query.py')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 4e2b4cdeb..8ad4092e6 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -22,6 +22,7 @@ import itertools import operator import types +from sqlalchemy.sql import visitors from . import exc as orm_exc from . import interfaces from . import loading @@ -197,7 +198,12 @@ class Query( elif "bundle" in ent._annotations: return ent._annotations["bundle"] else: - return ent + # label, other SQL expression + for element in visitors.iterate(ent): + if "parententity" in element._annotations: + return element._annotations["parententity"] + else: + return None def _only_full_mapper_zero(self, methname): if ( |
