summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 02deebdca..d51fd75c3 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -614,7 +614,13 @@ class Query(object):
clause = clause.join(prop.select_table, prop.get_join(mapper, primary=False))
else:
clause = clause.join(prop.select_table, prop.get_join(mapper))
+ elif prop.secondary is not None and prop.secondary not in currenttables:
+ # TODO: this check is not strong enough for different paths to the same endpoint which
+ # does not use secondary tables
+ raise exceptions.InvalidRequestError("Can't join to property '%s'; a path to this table along a different secondary table already exists. Use explicit `Alias` objects." % prop.key)
+
mapper = prop.mapper
+
return (clause, mapper)
def _join_by(self, args, params, start=None):