clojureql
clojureql copied to clipboard
issues with rename - for join
Database server: MySQL There are two tables 'items' and 'users' each of them having a common column name 'id'. 'items.user' is a foreign key referring to 'users.id'
(-> items (join users (where (= :items.user :users.id))) (rename {:items.id :item_id}))
generates
SELECT items.*,users.* FROM items AS items(*) JOIN users ON (items.user = users.id)
whereas it should have been
SELECT items.id as item_id, items.*,users.* FROM items JOIN users ON (items.user = users.id)
this issue is same as #126
in fact, the same effect can be achieved without using 'rename' procedure:
(-> items (project [[:id :item_id] :user :data]) (join users (where (= :items.user :users.id))))
only disadvantage with using this approach is with listing all the columns of a schema during 'project'.
it would be nice if someone can document the details regarding the issue with 'rename' at http://clojureql.org/documentation.html