summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/relationships.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/orm/relationships.py')
-rw-r--r--lib/sqlalchemy/orm/relationships.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py
index bedc54153..0be15260e 100644
--- a/lib/sqlalchemy/orm/relationships.py
+++ b/lib/sqlalchemy/orm/relationships.py
@@ -1352,12 +1352,18 @@ class RelationshipProperty(StrategizedProperty):
crit = j & sql.True_._ifnone(criterion)
if secondary is not None:
- ex = sql.exists(
- [1], crit, from_obj=[dest, secondary]
- ).correlate_except(dest, secondary)
+ ex = (
+ sql.exists(1)
+ .where(crit)
+ .select_from(dest, secondary)
+ .correlate_except(dest, secondary)
+ )
else:
- ex = sql.exists([1], crit, from_obj=dest).correlate_except(
- dest
+ ex = (
+ sql.exists(1)
+ .where(crit)
+ .select_from(dest)
+ .correlate_except(dest)
)
return ex