diff --git a/CHANGELOG.md b/CHANGELOG.md index 1da06ad..8ffeb9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 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 * 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). diff --git a/deps.edn b/deps.edn index dd1348d..da6cd61 100644 --- a/deps.edn +++ b/deps.edn @@ -4,7 +4,7 @@ :aliases {;; for help: clojure -A:deps -T:build help/doc :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} ;; versions to test against: diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index fa40bc5..83b4101 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -1249,20 +1249,17 @@ [s1 & p1] (format-expr a {:nested true}) [s2 & p2] (format-expr b {:nested true}) op (get infix-aliases op op)] - (if (and (#{:= :<>} op) (or (nil? a) (nil? b))) - (-> (str (if (nil? a) - (if (nil? b) "NULL" s2) - s1) - (if (= := op) " IS NULL" " IS NOT NULL")) - (cond-> nested - (as-> s (str "(" s ")"))) - (vector)) - (-> (str s1 " " (sql-kw op) " " s2) - (cond-> nested - (as-> s (str "(" s ")"))) - (vector) - (into p1) - (into p2))))) + (-> (if (and (#{:= :<>} op) (or (nil? a) (nil? b))) + (str (if (nil? a) + (if (nil? b) "NULL" s2) + s1) + (if (= := op) " IS NULL" " IS NOT NULL")) + (str s1 " " (sql-kw op) " " s2)) + (cond-> nested + (as-> s (str "(" s ")"))) + (vector) + (into p1) + (into p2)))) (contains? #{:in :not-in} op) (let [[sql & params] (format-in op (rest expr))] (into [(if nested (str "(" sql ")") sql)] params))