when joining two projected tables with no aliases, the resulting query is as expected:
(compile (-> (table db :table1)
(join
(project (table db :table2) [:id])
(where (= :table1.table2_id :table2.id)))) nil)
["SELECT table1.*,table2.id FROM table1 JOIN table2 ON (table1.table2_id = table2.id)"]
however, when aliases are introduced in the second table, a subselect is created.
(compile (-> (table db :table1)
(join
(project (table db :table2) [[:id :as :table2id]])
(where (= :table1.table2_id :table2.id)))) nil)
["SELECT table1.*,table2_subselect.table2id FROM table1 JOIN (SELECT table2.id AS table2id FROM table2) AS table2_subselect ON (table1.table2_subselect_id = table2_subselect.id)"]
I would have expected the output to be:
["SELECT table1.*,table2.id AS table2id FROM table1 JOIN table2 ON (table1.table2_id = table2.id)]
This issue was noted in the latest SNAPSHOT build.
when joining two projected tables with no aliases, the resulting query is as expected:
however, when aliases are introduced in the second table, a subselect is created.
I would have expected the output to be:
This issue was noted in the latest SNAPSHOT build.