support multiple explicit FROM clauses in query, at least via join()

Issue #1337 resolved
Former user created an issue

if query.join() is called in such a way that the join() call indicates both left and right sides of the join, and the left side is not present in __currenttables, support query._from_obj as a list instead of a single selectable.

I don't think this would imply that select_from() takes a list, since keeping the functionality within join() keeps it limited as to what scenarios can occur.

if this feature is not possible, look into raising an exception for a case like the below.

    e = aliased(Employee)
    c = aliased(Company)

    session.query(Employee, Company, e, c).join((Company, Employee.company)).join((c, e.company)).count()

produces incorrect SQL:

SELECT count(1) AS count_1 
FROM employees
  JOIN companies ON companies.company_id = employees.company_id
  JOIN companies AS companies_1 ON companies_1.company_id = employees_1.company_id

Table {{{employees_1}}} is missing in {{{FROM}}} clause.

Full test case attached.

Comments (5)

  1. Mike Bayer repo owner

    a new version, more sophisticated. all tests are passing so it looks like a good candidate for a commit in 0.5.xx, once more tests are added.

  2. Log in to comment