Fixes #328 by adding :distinct special syntax
This commit is contained in:
parent
f508196ba3
commit
a51cfe5a2e
3 changed files with 14 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# Changes
|
||||
|
||||
* 2.0.next in progress
|
||||
* Fix #328 by adding `:distinct` as special syntax, affecting an expression.
|
||||
* Support PostgreSQL's `&&` array operator.
|
||||
* Clarify how to `SELECT` a function expression (in **Getting Started**).
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ expression (comma-separated, wrapped in parentheses):
|
|||
;;=> ["(a, b, ?, x + ?)" "red" 1]
|
||||
```
|
||||
|
||||
## distinct
|
||||
|
||||
Accepts a single expression and prefixes it with `DISTINCT `:
|
||||
|
||||
```clojure
|
||||
(sql/format {:select [ [[:count [:distinct :status]] :n] ] :from :table})
|
||||
;;=> ["SELECT COUNT(DISTINCT status) AS n FROM table"]
|
||||
```
|
||||
|
||||
## entity
|
||||
|
||||
Accepts a single keyword or symbol argument and produces a
|
||||
|
|
|
|||
|
|
@ -1074,6 +1074,10 @@
|
|||
(fn [_ [& args]]
|
||||
(let [[sqls params] (format-expr-list args)]
|
||||
(into [(str "(" (str/join ", " sqls) ")")] params)))
|
||||
:distinct
|
||||
(fn [_ [x]]
|
||||
(let [[sql & params] (format-expr x {:nested true})]
|
||||
(into [(str "DISTINCT " sql)] params)))
|
||||
:escape
|
||||
(fn [_ [pattern escape-chars]]
|
||||
(let [[sql-p & params-p] (format-expr pattern)
|
||||
|
|
|
|||
Loading…
Reference in a new issue