- changed milestone to 0.6.0
- marked as enhancement
- changed title to support multiple explicit FROM clauses in query, at least via join()
support multiple explicit FROM clauses in query, at least via join()
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)
-
repo owner -
repo owner attached is a patch that begins to address this.
-
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.
-
repo owner - changed status to resolved
k that was a minor nightmare but passes all tests plus some new ones in 53deb98918263cd0a89d1a0aeb73f7010d8907bf.
-
repo owner - removed milestone
Removing milestone: 0.5.xx (automated comment)
- Log in to comment
this operation isn't supported right now. as a workaround, join implicitly (i.e. query.filter(table1.foo==table2.bar)