LauJensen / clojureql

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

`rename` doesn't work as intended #102

Closed bendlas closed 12 years ago

bendlas commented 12 years ago

clojureql.core/rename renames columns by adding a table alias with columns, like:

(-> (table nil :users)
    (project [:id :name])
    (rename {:id :idx}))

"SELECT users.id,users.name FROM users AS users(idx,name)"

This is wrong in two ways:

There are two ways to mitigate that:

Is there any point in using a table alias for renaming columns, i.e. implementing the second version?

LauJensen commented 12 years ago

This is purely for use with joins, in which case it works flawlessly on MySQL. If I have misunderstood your comments, please reopen, but note that rename is not to be used in cases where you don't join.

dubiousdavid commented 11 years ago

Rename absolutely does not produce valid MySQL. Should rename table. Example:

SELECT renamedUsers.* FROM users as renamedUsers

dubiousdavid commented 11 years ago

Hint: to rename a table use:

(table {:users :user})