From 8bf68d1d109b5d55cbe15ee316e09b78041dc067 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Wed, 21 Aug 2019 21:59:39 -0700 Subject: [PATCH] Another run at fixing #246 --- src/honeysql/helpers.cljc | 3 ++- test/honeysql/core_test.cljc | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/honeysql/helpers.cljc b/src/honeysql/helpers.cljc index 44cf50c..6d4149c 100644 --- a/src/honeysql/helpers.cljc +++ b/src/honeysql/helpers.cljc @@ -78,9 +78,10 @@ [logic-op preds] (if (keyword? (first preds)) [(first preds) (rest preds)] [:and preds]) + preds (remove nil? preds) pred (if (>= 1 (count preds)) (first preds) - (into [logic-op] (remove nil? preds)))] + (into [logic-op] preds))] [m pred logic-op])) (defn where [& args] diff --git a/test/honeysql/core_test.cljc b/test/honeysql/core_test.cljc index 2627842..0a80c66 100644 --- a/test/honeysql/core_test.cljc +++ b/test/honeysql/core_test.cljc @@ -242,6 +242,16 @@ (-> (select :*) (from :table) (where nil [:= :foo :bar] nil [:= :quuz :xyzzy] nil) + sql/format))) + (is (= ["SELECT * FROM table"] + (-> (select :*) + (from :table) + (where) + sql/format))) + (is (= ["SELECT * FROM table"] + (-> (select :*) + (from :table) + (where nil nil nil nil) sql/format))))) #?(:cljs (cljs.test/run-all-tests))