address #504 by adding ignore/respect null support
This commit is contained in:
parent
654a1cb67a
commit
75830df509
3 changed files with 21 additions and 0 deletions
|
|
@ -1,5 +1,8 @@
|
|||
# Changes
|
||||
|
||||
* 2.4.next in progress
|
||||
* Address [#504](https://github.com/seancorfield/honeysql/issues/504) by adding special syntax for ignore/respect nulls. More work will be needed to support distinct/order by/limit in BigQuery array aggregation.
|
||||
|
||||
* 2.4.1066 -- 2023-08-27
|
||||
* Add `:select` with function call and alias example to README (PR [#502](https://github.com/seancorfield/honeysql/pull/502) [@markbastian](https://github.com/markbastian)).
|
||||
* Address [#501](https://github.com/seancorfield/honeysql/issues/501) by making `INSERT INTO` (and `REPLACE INTO`) use the `:columns` or `:values` clauses to produce column names (which are then omitted from those other clauses).
|
||||
|
|
|
|||
|
|
@ -215,6 +215,18 @@ FROM aa
|
|||
100]
|
||||
```
|
||||
|
||||
## ignore/respect nulls
|
||||
|
||||
Both of these accept a single argument -- an expression -- and
|
||||
renders that expression followed by `IGNORE NULLS` or `RESPECT NULLS`:
|
||||
|
||||
```clojure
|
||||
(sql/format-expr [:array_agg [:ignore-nulls :a]])
|
||||
;;=> ["ARRAY_AGG(a IGNORE NULLS)"]
|
||||
(sql/format-expr [:array_agg [:respect-nulls :a]])
|
||||
;;=> ["ARRAY_AGG(a RESPECT NULLS)"]
|
||||
```
|
||||
|
||||
## inline
|
||||
|
||||
Accepts a single argument and tries to render it as a
|
||||
|
|
|
|||
|
|
@ -1605,6 +1605,10 @@
|
|||
(into paramsx)
|
||||
(into params))))
|
||||
|
||||
(defn ignore-respect-nulls [k [x]]
|
||||
(let [[sql & params] (format-expr x)]
|
||||
(into [(str sql " " (sql-kw k))] params)))
|
||||
|
||||
(def ^:private special-syntax
|
||||
(atom
|
||||
{;; these "functions" are mostly used in column
|
||||
|
|
@ -1686,6 +1690,7 @@
|
|||
(into params-p)
|
||||
(into params-e))))
|
||||
:filter expr-clause-pairs
|
||||
:ignore-nulls ignore-respect-nulls
|
||||
:inline
|
||||
(fn [_ [x]]
|
||||
(binding [*inline* true]
|
||||
|
|
@ -1766,6 +1771,7 @@
|
|||
(raw-render (first xs))
|
||||
;; ...but allow for multiple arguments now:
|
||||
(raw-render xs)))
|
||||
:respect-nulls ignore-respect-nulls
|
||||
:within-group expr-clause-pairs}))
|
||||
|
||||
(defn- format-equality-expr [op' op expr nested]
|
||||
|
|
|
|||
Loading…
Reference in a new issue