summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-06-07 23:04:33 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-06-07 23:04:33 -0400
commitd5363fca5400f6c4969c2756fcfcdae6b9703091 (patch)
tree2893e5faa72e8606f4664ab7efee9d346586e37f /lib/sqlalchemy/orm/util.py
parent0d9ec9fe840eb71935c2a55c3063620a028e59aa (diff)
downloadsqlalchemy-d5363fca5400f6c4969c2756fcfcdae6b9703091.tar.gz
- Fixed an obscure bug where the wrong results would be
fetched when joining/joinedloading across a many-to-many relationship to a single-table-inheriting subclass with a specific discriminator value, due to "secondary" rows that would come back. The "secondary" and right-side tables are now inner joined inside of parenthesis for all ORM joins on many-to-many relationships so that the left->right join can accurately filtered. [ticket:2369]
Diffstat (limited to 'lib/sqlalchemy/orm/util.py')
-rw-r--r--lib/sqlalchemy/orm/util.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index 7ac3ac96a..fb6471ac6 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -918,8 +918,13 @@ class _ORMJoin(expression.Join):
of_type=right_info.mapper)
if sj is not None:
- left = sql.join(left, secondary, pj, isouter)
- onclause = sj
+ if isouter:
+ # note this is an inner join from secondary->right
+ right = sql.join(secondary, right, sj)
+ onclause = pj
+ else:
+ left = sql.join(left, secondary, pj, isouter)
+ onclause = sj
else:
onclause = pj
self._target_adapter = target_adapter