From 2123c01fb51fac54725ceabc5de92b885fd37cc0 Mon Sep 17 00:00:00 2001 From: Dave Della Costa Date: Wed, 26 Aug 2015 00:11:29 +0900 Subject: [PATCH] adds tests for :union and :union-all --- test/honeysql/format_test.clj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/honeysql/format_test.clj b/test/honeysql/format_test.clj index e0f8bca..26f90bc 100644 --- a/test/honeysql/format_test.clj +++ b/test/honeysql/format_test.clj @@ -53,3 +53,13 @@ :columns [:baz] :values [[#sql/array ["one" "two" "three"]]]}) ["INSERT INTO foo (baz) VALUES (ARRAY[?, ?, ?])" "one" "two" "three"]))) + +(deftest union-test + (is (= (format {:union [{:select [:foo] :from [:bar1]} + {:select [:foo] :from [:bar2]}]}) + ["(SELECT foo FROM bar1) UNION (SELECT foo FROM bar2)"]))) + +(deftest union-all-test + (is (= (format {:union-all [{:select [:foo] :from [:bar1]} + {:select [:foo] :from [:bar2]}]}) + ["(SELECT foo FROM bar1) UNION ALL (SELECT foo FROM bar2)"])))