address #466 by collapsing 0-arity :and/:or

This commit is contained in:
Sean Corfield 2023-02-27 20:07:24 -08:00
parent 63c7a45578
commit a610f256dd
2 changed files with 13 additions and 5 deletions

View file

@ -2,6 +2,7 @@
* 2.4.next in progress
* Fix [#467](https://github.com/seancorfield/honeysql/issues/467) by allowing single keywords (symbols) as a short hand for a single-element sequence in more constructs via PR [#470](https://github.com/seancorfield/honeysql/pull/470) [@p-himik](https://github.com/p-himik).
* Address [#466](https://github.com/seancorfield/honeysql/issues/466) by treating `[:and]` as `TRUE` and `[:or]` as `FALSE`.
* Fix [#465](https://github.com/seancorfield/honeysql/issues/465) to allow multiple columns in `:order-by` special syntax via PR [#468](https://github.com/seancorfield/honeysql/pull/468) [@p-himik](https://github.com/p-himik).
* Fix [#464](https://github.com/seancorfield/honeysql/issues/464) by adding an optional type argument to `:array` via PR [#469](https://github.com/seancorfield/honeysql/pull/469) [@p-himik](https://github.com/p-himik).

View file

@ -1590,12 +1590,19 @@
(vector)
(into p1)
(into p2)))
(let [x (if (contains? @op-ignore-nil op)
(remove nil? expr)
expr)
(let [args (cond->> (rest expr)
(contains? @op-ignore-nil op)
(remove nil?))
args (cond (seq args)
args
(= :and op)
[true]
(= :or op)
[false]
:else ; args is empty and not a special case
[])
[sqls params]
(reduce-sql (map #(format-expr % {:nested true})
(rest x)))]
(reduce-sql (map #(format-expr % {:nested true}) args))]
(when-not (pos? (count sqls))
(throw (ex-info (str "no operands found for " op')
{:expr expr})))