This commit is contained in:
Sean Corfield 2021-10-03 21:59:11 -07:00
parent 80bbf85c3a
commit 3d0a9ba79c
3 changed files with 16 additions and 15 deletions

View file

@ -1,5 +1,9 @@
# Changes # Changes
* 2.0.next in progress
* Fix #367 by supporting parameters in subexpressions around `IS NULL` / `IS NOT NULL` tests.
* Update `build-clj` to v0.5.0.
* 2.0.813 -- 2021-09-25 * 2.0.813 -- 2021-09-25
* Address #364 by recommending how to handle PostgreSQL operators that contain `@`. * Address #364 by recommending how to handle PostgreSQL operators that contain `@`.
* Fix #363 and #362 by aligning more closely the semantics of `:inline` syntax with the `:inline true` option. A side effect of this is that `[:inline [:param :foo]]` will now (correctly) inline the value of the parameter `:foo` whereas it previously produced `PARAMS SOURCE`. In addition, inlining has been extended to vector values, so `[:inline ["a" "b" "c"]]` will now produce `('a', 'b', 'c')` and `[:inline [:lift ["a" "b" "c"]]]` will now produce `['a', 'b', 'c']` which is what people seemed to expect (the behavior was previously unspecified). * Fix #363 and #362 by aligning more closely the semantics of `:inline` syntax with the `:inline true` option. A side effect of this is that `[:inline [:param :foo]]` will now (correctly) inline the value of the parameter `:foo` whereas it previously produced `PARAMS SOURCE`. In addition, inlining has been extended to vector values, so `[:inline ["a" "b" "c"]]` will now produce `('a', 'b', 'c')` and `[:inline [:lift ["a" "b" "c"]]]` will now produce `['a', 'b', 'c']` which is what people seemed to expect (the behavior was previously unspecified).

View file

@ -4,7 +4,7 @@
:aliases :aliases
{;; for help: clojure -A:deps -T:build help/doc {;; for help: clojure -A:deps -T:build help/doc
:build {:deps {io.github.seancorfield/build-clj :build {:deps {io.github.seancorfield/build-clj
{:git/tag "v0.4.0" :git/sha "54e39ae"}} {:git/tag "v0.5.0" :git/sha "2ceb95a"}}
:ns-default build} :ns-default build}
;; versions to test against: ;; versions to test against:

View file

@ -1249,20 +1249,17 @@
[s1 & p1] (format-expr a {:nested true}) [s1 & p1] (format-expr a {:nested true})
[s2 & p2] (format-expr b {:nested true}) [s2 & p2] (format-expr b {:nested true})
op (get infix-aliases op op)] op (get infix-aliases op op)]
(if (and (#{:= :<>} op) (or (nil? a) (nil? b))) (-> (if (and (#{:= :<>} op) (or (nil? a) (nil? b)))
(-> (str (if (nil? a) (str (if (nil? a)
(if (nil? b) "NULL" s2) (if (nil? b) "NULL" s2)
s1) s1)
(if (= := op) " IS NULL" " IS NOT NULL")) (if (= := op) " IS NULL" " IS NOT NULL"))
(cond-> nested (str s1 " " (sql-kw op) " " s2))
(as-> s (str "(" s ")")))
(vector))
(-> (str s1 " " (sql-kw op) " " s2)
(cond-> nested (cond-> nested
(as-> s (str "(" s ")"))) (as-> s (str "(" s ")")))
(vector) (vector)
(into p1) (into p1)
(into p2))))) (into p2))))
(contains? #{:in :not-in} op) (contains? #{:in :not-in} op)
(let [[sql & params] (format-in op (rest expr))] (let [[sql & params] (format-in op (rest expr))]
(into [(if nested (str "(" sql ")") sql)] params)) (into [(if nested (str "(" sql ")") sql)] params))