parent
9b611bb7ff
commit
2149a80852
4 changed files with 21 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
* 2.5.next in progress
|
* 2.5.next in progress
|
||||||
|
* Address [#523](https://github.com/seancorfield/honeysql/issues/523) by expanding examples in README **Functions** to show aliases.
|
||||||
* Address [#522](https://github.com/seancorfield/honeysql/issues/522) by supporting metadata on table specifications in `:from` and `:join` clauses to provide index hints (SQL Server).
|
* Address [#522](https://github.com/seancorfield/honeysql/issues/522) by supporting metadata on table specifications in `:from` and `:join` clauses to provide index hints (SQL Server).
|
||||||
* Address [#520](https://github.com/seancorfield/honeysql/issues/520) by expanding how `:inline` works, to support a sequence of arguments.
|
* Address [#520](https://github.com/seancorfield/honeysql/issues/520) by expanding how `:inline` works, to support a sequence of arguments.
|
||||||
* Fix [#518](https://github.com/seancorfield/honeysql/issues/518) by moving temporal clause before alias.
|
* Fix [#518](https://github.com/seancorfield/honeysql/issues/518) by moving temporal clause before alias.
|
||||||
|
|
|
||||||
19
README.md
19
README.md
|
|
@ -565,6 +565,11 @@ keywords that begin with `%` are interpreted as SQL function calls:
|
||||||
=> ["SELECT COUNT(*) FROM foo"]
|
=> ["SELECT COUNT(*) FROM foo"]
|
||||||
```
|
```
|
||||||
```clojure
|
```clojure
|
||||||
|
;; with an alias:
|
||||||
|
(-> (select [:%count.* :total]) (from :foo) sql/format)
|
||||||
|
=> ["SELECT COUNT(*) AS total FROM foo"]
|
||||||
|
```
|
||||||
|
```clojure
|
||||||
(-> (select :%max.id) (from :foo) sql/format)
|
(-> (select :%max.id) (from :foo) sql/format)
|
||||||
=> ["SELECT MAX(id) FROM foo"]
|
=> ["SELECT MAX(id) FROM foo"]
|
||||||
```
|
```
|
||||||
|
|
@ -578,6 +583,10 @@ regular function calls in a select:
|
||||||
=> ["SELECT COUNT(*) FROM foo"]
|
=> ["SELECT COUNT(*) FROM foo"]
|
||||||
```
|
```
|
||||||
```clojure
|
```clojure
|
||||||
|
(-> (select [[:count :*] :total]) (from :foo) sql/format)
|
||||||
|
=> ["SELECT COUNT(*) AS total FROM foo"]
|
||||||
|
```
|
||||||
|
```clojure
|
||||||
(-> (select [:%count.*]) (from :foo) sql/format)
|
(-> (select [:%count.*]) (from :foo) sql/format)
|
||||||
=> ["SELECT COUNT(*) FROM foo"]
|
=> ["SELECT COUNT(*) FROM foo"]
|
||||||
;; or even:
|
;; or even:
|
||||||
|
|
@ -587,16 +596,22 @@ regular function calls in a select:
|
||||||
```clojure
|
```clojure
|
||||||
(-> (select [[:max :id]]) (from :foo) sql/format)
|
(-> (select [[:max :id]]) (from :foo) sql/format)
|
||||||
=> ["SELECT MAX(id) FROM foo"]
|
=> ["SELECT MAX(id) FROM foo"]
|
||||||
|
(-> (select [[:max :id] :highest]) (from :foo) sql/format)
|
||||||
|
=> ["SELECT MAX(id) AS highest FROM foo"]
|
||||||
;; the pure data DSL requires an extra level of brackets:
|
;; the pure data DSL requires an extra level of brackets:
|
||||||
(-> {:select [[[:max :id]]], :from [:foo]} sql/format)
|
(-> {:select [[[:max :id]]], :from [:foo]} sql/format)
|
||||||
=> ["SELECT MAX(id) FROM foo"]
|
=> ["SELECT MAX(id) FROM foo"]
|
||||||
|
(-> {:select [[[:max :id] :highest]], :from [:foo]} sql/format)
|
||||||
|
=> ["SELECT MAX(id) AS highest FROM foo"]
|
||||||
;; the shorthand makes this simpler:
|
;; the shorthand makes this simpler:
|
||||||
(-> {:select [[:%max.id]], :from [:foo]} sql/format)
|
(-> {:select [[:%max.id]], :from [:foo]} sql/format)
|
||||||
=> ["SELECT MAX(id) FROM foo"]
|
=> ["SELECT MAX(id) FROM foo"]
|
||||||
;; or even:
|
(-> {:select [[:%max.id :highest]], :from [:foo]} sql/format)
|
||||||
|
=> ["SELECT MAX(id) AS highest FROM foo"]
|
||||||
|
;; or even (no alias):
|
||||||
(-> {:select [:%max.id], :from [:foo]} sql/format)
|
(-> {:select [:%max.id], :from [:foo]} sql/format)
|
||||||
=> ["SELECT MAX(id) FROM foo"]
|
=> ["SELECT MAX(id) FROM foo"]
|
||||||
;; or even:
|
;; or even (no alias, no other columns):
|
||||||
(-> {:select :%max.id, :from :foo} sql/format)
|
(-> {:select :%max.id, :from :foo} sql/format)
|
||||||
=> ["SELECT MAX(id) FROM foo"]
|
=> ["SELECT MAX(id) FROM foo"]
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@
|
||||||
(defn upper-case
|
(defn upper-case
|
||||||
"Upper-case a string in Locale/US to avoid locale-specific capitalization."
|
"Upper-case a string in Locale/US to avoid locale-specific capitalization."
|
||||||
[^String s]
|
[^String s]
|
||||||
(.. s toString (toUpperCase (java.util.Locale/US))))
|
(.. s toString (toUpperCase java.util.Locale/US)))
|
||||||
:cljr
|
:cljr
|
||||||
(defn upper-case
|
(defn upper-case
|
||||||
"Upper-case a string in Locale/US to avoid locale-specific capitalization."
|
"Upper-case a string in Locale/US to avoid locale-specific capitalization."
|
||||||
|
|
|
||||||
|
|
@ -1185,4 +1185,6 @@
|
||||||
(where [:in (composite :first :second)
|
(where [:in (composite :first :second)
|
||||||
[(composite 1 2) (composite 2 1)]])
|
[(composite 1 2) (composite 2 1)]])
|
||||||
(h/format))
|
(h/format))
|
||||||
|
(-> (select [:%count.* :total]) (from :foo) h/format)
|
||||||
|
(-> (select [[:count :*] :total]) (from :foo) h/format)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue