clojureql icon indicating copy to clipboard operation
clojureql copied to clipboard

issues with rename - for join

Open gowda opened this issue 13 years ago • 3 comments

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)

gowda avatar Dec 31 '12 12:12 gowda

this issue is same as #126

gowda avatar Jan 02 '13 18:01 gowda

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'.

gowda avatar Jan 02 '13 18:01 gowda

it would be nice if someone can document the details regarding the issue with 'rename' at http://clojureql.org/documentation.html

gowda avatar Jan 02 '13 18:01 gowda