diff --git a/test/honeysql/core_test.clj b/test/honeysql/core_test.clj index 0f1c9b2..c3642d6 100644 --- a/test/honeysql/core_test.clj +++ b/test/honeysql/core_test.clj @@ -48,7 +48,7 @@ m3 (sql/build m2) m4 (apply sql/build (apply concat m2))] (testing "Various construction methods are consistent" - (is (= m1 m3))) + (is (= m1 m3 m4))) (testing "SQL data formats correctly" (is (= ["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] diff --git a/test/honeysql/format_test.clj b/test/honeysql/format_test.clj new file mode 100644 index 0000000..19483ef --- /dev/null +++ b/test/honeysql/format_test.clj @@ -0,0 +1,19 @@ +(ns honeysql.format-test + (:refer-clojure :exclude [format]) + (:require [clojure.test :refer [deftest testing is are]] + [honeysql.format :refer :all])) + +(deftest test-quote + (are + [qx res] + (= (apply quote-identifier "foo.bar.baz" qx) res) + [] "foo.bar.baz" + [:style :mysql] "`foo`.`bar`.`baz`" + [:style :mysql :split false] "`foo.bar.baz`") + (are + [x res] + (= (quote-identifier x) res) + 3 "3" + 'foo "foo" + :foo-bar "foo_bar") + (is (= (quote-identifier "*" :style :ansi) "*")))