diff options
Diffstat (limited to 'lib/sqlalchemy')
| -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): |
