_ORMJoin - still ambiguous

Issue #1293 resolved
Mike Bayer repo owner created an issue

_ORMJoin has many situations where it doesn't know what to join from on the left side. the two paths into this class, eager loading and query.join(), have different expectations of it. but even within query.join(), we sometimes want it to link to the left side given in any way possible, we sometimes want it to link to exactly what the attribute-based onclause says. some logic that depends on aliased=True, combined with are we joining from a single aliased root or not, might work here. i would like to make _ORMJoin explicit though about joining from "the left", so that eagerloader can say, "don't alias from the left side in any case here" without relying upon the implicit "it's an AliasedClass so don't alias from the left side" idea.

query.py TestFromSelf:

    def test_aliases(self):
        s = create_session()

        ualias = aliased(User)

        # passes.  the order_by adapts ualias.name to the 
        # selectable
        eq_(
            s.query(User, ualias).filter(User.id > ualias.id).from_self().order_by(User.name, ualias.name).all(),
            [ # ... assume correct results here
        )

        # fails.  the ualias.name is taken as "don't adapt !"
        eq_(
            s.query(User, ualias).filter(User.id > ualias.id).from_self(ualias, Address).join(ualias.addresses).all(),
            [](]) # ... assume correct results here
        )

Comments (3)

  1. Mike Bayer reporter

    the attached patch adds finer grained conditional control to the join logic. doesn't pass for all tests though.

  2. Log in to comment