SQL Server has no TRUE / FALSE literals

Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
Sean Corfield 2024-12-14 12:35:41 -08:00
parent c98df6dd97
commit 0f26e7d060
No known key found for this signature in database
3 changed files with 10 additions and 2 deletions

View file

@ -1,5 +1,8 @@
# Changes # Changes
* 2.6.next in progress
* Make SQL Server dialect auto-lift Boolean values to parameters since SQL Server has no `TRUE` / `FALSE` literals.
* 2.6.1243 -- 2024-12-13 * 2.6.1243 -- 2024-12-13
* Address [#558](https://github.com/seancorfield/honeysql/issues/558) by adding `:patch-into` (and `patch-into` helper) for XTDB (but in core). * Address [#558](https://github.com/seancorfield/honeysql/issues/558) by adding `:patch-into` (and `patch-into` helper) for XTDB (but in core).
* Address [#556](https://github.com/seancorfield/honeysql/issues/556) by adding an XTDB section to the documentation with examples. * Address [#556](https://github.com/seancorfield/honeysql/issues/556) by adding an XTDB section to the documentation with examples.

View file

@ -112,7 +112,8 @@
(assoc m k (assoc v :dialect k))) (assoc m k (assoc v :dialect k)))
{} {}
{:ansi {:quote #(strop "\"" % "\"")} {:ansi {:quote #(strop "\"" % "\"")}
:sqlserver {:quote #(strop "[" % "]")} :sqlserver {:quote #(strop "[" % "]")
:auto-lift-boolean true}
:mysql {:quote #(strop "`" % "`") :mysql {:quote #(strop "`" % "`")
:clause-order-fn :clause-order-fn
#(add-clause-before % :set :where)} #(add-clause-before % :set :where)}
@ -2233,7 +2234,9 @@
(into [(str "(" (join ", " sqls) ")")] params)))) (into [(str "(" (join ", " sqls) ")")] params))))
(boolean? expr) (boolean? expr)
[(upper-case (str expr))] (if (:auto-lift-boolean *dialect*)
["?" expr]
[(upper-case (str expr))])
(nil? expr) (nil? expr)
["NULL"] ["NULL"]

View file

@ -22,6 +22,8 @@
(sut/format-expr [:is :id nil]))) (sut/format-expr [:is :id nil])))
(is (= ["id = TRUE"] (is (= ["id = TRUE"]
(sut/format-expr [:= :id true]))) (sut/format-expr [:= :id true])))
(is (= ["[id] = ?" true]
(sut/format [:= :id true] {:dialect :sqlserver})))
(is (= ["id IS TRUE"] (is (= ["id IS TRUE"]
(sut/format-expr [:is :id true]))) (sut/format-expr [:is :id true])))
(is (= ["id <> TRUE"] (is (= ["id <> TRUE"]