From 753cff83744c216fedbbd5079632097bac91648f Mon Sep 17 00:00:00 2001 From: Thomas Athorne Date: Mon, 4 Aug 2014 15:07:15 +0100 Subject: [PATCH 1/3] Added .nrepl-port to gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8eed858..da5e086 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ pom.xml .classpath .project bin +/.nrepl-port From 53d51851735f1c282c1e7602d88afc0c73c2b121 Mon Sep 17 00:00:00 2001 From: Thomas Athorne Date: Mon, 4 Aug 2014 15:08:16 +0100 Subject: [PATCH 2/3] Make 'format' ignore all keys in the map with 'nil' as their value. --- src/honeysql/format.clj | 2 +- test/honeysql/core_test.clj | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/honeysql/format.clj b/src/honeysql/format.clj index 004a640..9e4bf18 100644 --- a/src/honeysql/format.clj +++ b/src/honeysql/format.clj @@ -247,7 +247,7 @@ (-to-sql [x] (.s x)) clojure.lang.IPersistentMap (-to-sql [x] (let [clause-ops (concat - (filter #(contains? x %) clause-order) + (filter #(and (contains? x %) (get x %)) clause-order) (remove known-clauses (keys x))) sql-str (binding [*subquery?* true *fn-context?* false] diff --git a/test/honeysql/core_test.clj b/test/honeysql/core_test.clj index 161b52f..4dc0108 100644 --- a/test/honeysql/core_test.clj +++ b/test/honeysql/core_test.clj @@ -54,4 +54,7 @@ ["SELECT DISTINCT f.*, b.baz, c.quux, b.bla AS bla_bla, now(), @x := 10 FROM foo f, baz b INNER JOIN draq ON f.b = draq.x LEFT JOIN clod c ON f.a = c.d RIGHT JOIN bock ON bock.z = c.e WHERE ((f.a = ? AND b.baz <> ?) OR (1 < 2 AND 2 < 3) OR (f.e in (1, ?, 3)) OR f.e BETWEEN 10 AND 20) GROUP BY f.a HAVING 0 < f.e ORDER BY b.baz DESC, c.quux LIMIT 50 OFFSET 10 " "bort" "gabba" 2]))) (testing "SQL data prints and reads correctly" - (is (= m1 (read-string (pr-str m1))))))) + (is (= m1 (read-string (pr-str m1))))) + (testing "Keys with value 'nil' are ignored" + (is (= (sql/format {:select '(:a.id) :from '([:foo :a]) :group-by nil :order-by nil}) + ["SELECT a.id FROM foo a"]))))) From 084183ea940918a9ede120dbe902dfc716a8ab05 Mon Sep 17 00:00:00 2001 From: Thomas Athorne Date: Mon, 4 Aug 2014 15:25:44 +0100 Subject: [PATCH 3/3] So that I can use this version. --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 00f2721..f7b0f76 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject honeysql "0.4.3" +(defproject honeysql "0.4.4-SNAPSHOT" :description "SQL as Clojure data structures" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"}