Skip to content

Commit

Permalink
Fix dsl/not
Browse files Browse the repository at this point in the history
  • Loading branch information
skammer committed Jun 15, 2017
1 parent 5be8054 commit adfe9cb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/suricatta/dsl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@
(defn not
"Negate a condition."
[c]
(DSL/not c))
(defer
(DSL/not (-condition c))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Common Table Expresions
Expand Down
17 changes: 17 additions & 0 deletions test/suricatta/dsl_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ?))")))))

0 comments on commit adfe9cb

Please sign in to comment.