From 4a7c3631a6608436533506f629eafecfe00a16ee Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sat, 14 Jan 2023 15:35:03 -0800 Subject: [PATCH] fix #454 by allowing - to be variadic --- CHANGELOG.md | 1 + src/honey/sql.cljc | 2 +- test/honey/ops_test.cljc | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/honey/ops_test.cljc diff --git a/CHANGELOG.md b/CHANGELOG.md index 650a38a..953e519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changes * 2.4.next in progress + * Fix [#454](https://github.com/seancorfield/honeysql/issues/454) by allowing `-` to be variadic. * Address [#452](https://github.com/seancorfield/honeysql/pull/452) by adding `:replace-into` to the core SQL supported, instead of just for the MySQL and SQLite dialects (so the latter is not needed yet). * Address [#451](https://github.com/seancorfield/honeysql/issues/451) by adding a test for it, showing how `:nest` produces the desired result. * Address [#447](https://github.com/seancorfield/honeysql/issues/447) by updating GitHub Actions and dependencies. diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 200aaad..c522c13 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -1279,7 +1279,7 @@ (atom))) (def ^:private op-ignore-nil (atom #{:and :or})) -(def ^:private op-variadic (atom #{:and :or :+ :* :|| :&&})) +(def ^:private op-variadic (atom #{:and :or :+ :* :- :|| :&&})) (defn- unwrap [x opts] (if-let [m (meta x)] diff --git a/test/honey/ops_test.cljc b/test/honey/ops_test.cljc new file mode 100644 index 0000000..870b473 --- /dev/null +++ b/test/honey/ops_test.cljc @@ -0,0 +1,12 @@ +;; copyright (c) 2023 sean corfield, all rights reserved + +(ns honey.ops-test + (:refer-clojure :exclude [format]) + (:require [clojure.test :refer [deftest is]] + [honey.sql :as sut] + [honey.sql :as sql])) + +(deftest issue-454 + (is (= ["SELECT a - b - c AS x"] + (-> {:select [[[:- :a :b :c] :x]]} + (sql/format)))))