Another run at fixing #246

This commit is contained in:
Sean Corfield 2019-08-21 21:59:39 -07:00
parent a31426da6b
commit 8bf68d1d10
2 changed files with 12 additions and 1 deletions

View file

@ -78,9 +78,10 @@
[logic-op preds] (if (keyword? (first preds)) [logic-op preds] (if (keyword? (first preds))
[(first preds) (rest preds)] [(first preds) (rest preds)]
[:and preds]) [:and preds])
preds (remove nil? preds)
pred (if (>= 1 (count preds)) pred (if (>= 1 (count preds))
(first preds) (first preds)
(into [logic-op] (remove nil? preds)))] (into [logic-op] preds))]
[m pred logic-op])) [m pred logic-op]))
(defn where [& args] (defn where [& args]

View file

@ -242,6 +242,16 @@
(-> (select :*) (-> (select :*)
(from :table) (from :table)
(where nil [:= :foo :bar] nil [:= :quuz :xyzzy] nil) (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))))) sql/format)))))
#?(:cljs (cljs.test/run-all-tests)) #?(:cljs (cljs.test/run-all-tests))