From adfe9cb11b945e04ca4904b8380a37f98337f6e0 Mon Sep 17 00:00:00 2001 From: Max Vasiliev Date: Thu, 15 Jun 2017 17:58:39 +0300 Subject: [PATCH] Fix dsl/not --- src/suricatta/dsl.clj | 3 ++- test/suricatta/dsl_test.clj | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/suricatta/dsl.clj b/src/suricatta/dsl.clj index 4c352a3..6f6be39 100644 --- a/src/suricatta/dsl.clj +++ b/src/suricatta/dsl.clj @@ -583,7 +583,8 @@ (defn not "Negate a condition." [c] - (DSL/not c)) + (defer + (DSL/not (-condition c)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Common Table Expresions diff --git a/test/suricatta/dsl_test.clj b/test/suricatta/dsl_test.clj index a4a459a..7da63fb 100644 --- a/test/suricatta/dsl_test.clj +++ b/test/suricatta/dsl_test.clj @@ -468,3 +468,20 @@ (is (= (fmt/sql q) "drop table t1")))) ) + +(deftest dsl-not + (testing "boolean negation" + (let [q (-> + (dsl/select :name) + (dsl/from :book) + (dsl/where (dsl/not "new")))] + (is (= (fmt/sql q) + "select name from book where not((new))")))) + + (testing "negation of vector condition" + (let [q (-> + (dsl/select :name) + (dsl/from :book) + (dsl/where (dsl/not ["title = ?" "test"])))] + (is (= (fmt/sql q) + "select name from book where not((title = ?))")))))