Closed bendlas closed 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.
Rename absolutely does not produce valid MySQL. Should rename table. Example:
SELECT renamedUsers.* FROM users as renamedUsers
Hint: to rename a table use:
(table {:users :user})
clojureql.core/rename
renames columns by adding a table alias with columns, like:This is wrong in two ways:
users.id
isSELECT
ed after having been renamed to idx, which results in amissing column
errorSELECT idx, name FROM users AS users(idx,name)
, there would be no guarantee, thatidx
actually referred touser.id
, since the table alias binds by positionThere are two ways to mitigate that:
SELECT users.id AS idx, users.name FROM users
, as if you had renamed directly inproject
SELECT users.idx, users.name FROM (SELECT users.id, users.name FROM users) AS users(idx,name)
Is there any point in using a table alias for renaming columns, i.e. implementing the second version?