Relationship to Object using Joined Table Inheritance uses an inner join
Issue #2335
resolved
On 0.7.3 using Oracle.
When creating a relationship to an object using joined table inheritance and using the lazy='joined' parameters, SQLAlchemy generates SQL using inner joins instead of outer joins.
Workaround: use 'subquery' or 'dynamic'.
Comments (3)
-
repo owner -
repo owner that should be:
A JOIN B <onclause> LEFT OUTER JOIN (SELECT * FROM C JOIN D <onclause>) AS anon_1 <onclause>".
-
repo owner - changed status to invalid
if you have a test case please feel free to reopen this ticket with an attachment, thanks !
- Log in to comment
hi there -
The inner/outer join is determined by the
innerjoin=True
flag passed to eitherrelationship()
orjoinedload()
. It's an outerjoin by default. Specifically with joined table inheritance, the target mapper's selectable is wrapped inside of a subquery, where the innerjoins are inside the subquery, the relationship from parent->child is an outerjoin by default. It's an extremely well-covered case.For example:
that's actually a joined-table subclass eager loading a joined-table subclass. The structure there is "A JOIN B <onclause> LEFT OUTER JOIN (SELECT * FROM B JOIN C) AS anon_1 <onclause>".
I'm not sure if you had an issue with uploading a test case or with the tracker, but I don't at the moment see a test script attached here. There are certainly potential configurational patterns which mis-handle this case, but without a full test case here illustrating specifically how to produce the results you consider erroneous, they can't be evaluated and this ticket will need to be closed. Guidelines for posting tickets are at http://www.sqlalchemy.org/participate.html#bugs. If you need help posting or otherwise, check in on the mailing list at http://groups.google.com/group/sqlalchemy .