r0man/sqlingvo — pull request #17 by temochka (2014-08-09 23:08:07+00:00)
Title: Add support for aliased COUNT and CAST statements.

I noticed that if I attempt to alias a COUNT or a CAST statement, the alias doesn’t make it to the compiled SQL. Aliasing such columns simplifies results processing, i.e.

``` clojure
(apply jdbc/query
db
(sql (db-types/mysql)
(select ['(count :*) '(count :deleted_at)]
(from :records))))
;;; bad
;;; ({:count(`deleted_at`) 270, :count(*) 1054})

(apply jdbc/query
db
(sql (db-types/mysql)
(select [(as '(count :*) :total_count)
(as '(count :deleted_at) :deleted_count)]
(from :records))))
;;; good
;;; ({:deleted_count 270, :total_count 1054})
```

This is a very straightforward fix with some additional tests. Overall I feel like aliases compilation could be somehow decoupled from functions, but this would definitely require a significant amount of changes.