LauJensen / clojureql

ClojureQL is superior SQL integration for Clojure
https://clojureql.sabrecms.com
Eclipse Public License 1.0
285 stars 39 forks source link

issues with rename - for join #132

Open gowda opened 11 years ago

gowda commented 11 years ago

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 commented 11 years ago

this issue is same as #126

gowda commented 11 years ago

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 commented 11 years ago

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