diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-11-14 11:02:40 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-11-14 17:37:02 -0500 |
| commit | fdfd1680603f6663182ba4766ae2f5abdd3ced45 (patch) | |
| tree | 5b4242a17c355d9567c937f992cefddf43ea1d79 /lib | |
| parent | fd8f0044fe42341c9b47578f44e3c9e77d2132c0 (diff) | |
| download | sqlalchemy-fdfd1680603f6663182ba4766ae2f5abdd3ced45.tar.gz | |
Add secondary selectable to FROM clauses for correlated exists
In continuing with a similar theme as that of very recent :ticket:`4349`,
repaired issue with :meth:`.RelationshipProperty.Comparator.any` and
:meth:`.RelationshipProperty.Comparator.has` where the "secondary"
selectable needs to be explicitly part of the FROM clause in the
EXISTS subquery to suit the case where this "secondary" is a :class:`.Join`
object.
Fixes: #4366
Change-Id: Icd0d0c3871bbd0059f0c9256e2b980edc2c90551
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/relationships.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index adcaa5927..e7896c423 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -1110,9 +1110,12 @@ class RelationshipProperty(StrategizedProperty): crit = j & sql.True_._ifnone(criterion) - ex = sql.exists([1], crit, from_obj=dest).correlate_except(dest) if secondary is not None: - ex = ex.correlate_except(secondary) + ex = sql.exists([1], crit, from_obj=[dest, secondary]).\ + correlate_except(dest, secondary) + else: + ex = sql.exists([1], crit, from_obj=dest).\ + correlate_except(dest) return ex def any(self, criterion=None, **kwargs): |
