add INTERSECT support
This commit is contained in:
parent
93e66c90c4
commit
8fa44d22b3
4 changed files with 13 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
## 0.6.3 In development
|
## 0.6.3 In development
|
||||||
|
|
||||||
|
* Add support for :intersect clause (@jakemcc)
|
||||||
|
|
||||||
## 0.6.2
|
## 0.6.2
|
||||||
|
|
||||||
Support column names in :with clauses (@emidln)
|
Support column names in :with clauses (@emidln)
|
||||||
|
|
|
||||||
|
|
@ -531,6 +531,9 @@
|
||||||
(defmethod format-clause :union-all [[_ maps] _]
|
(defmethod format-clause :union-all [[_ maps] _]
|
||||||
(string/join " UNION ALL " (map to-sql maps)))
|
(string/join " UNION ALL " (map to-sql maps)))
|
||||||
|
|
||||||
|
(defmethod format-clause :intersect [[_ maps] _]
|
||||||
|
(string/join " INTERSECT " (map to-sql maps)))
|
||||||
|
|
||||||
(defmethod fn-handler "case" [_ & clauses]
|
(defmethod fn-handler "case" [_ & clauses]
|
||||||
(str "CASE "
|
(str "CASE "
|
||||||
(space-join
|
(space-join
|
||||||
|
|
|
||||||
|
|
@ -236,3 +236,6 @@
|
||||||
|
|
||||||
(defmethod build-clause :union-all [_ m maps]
|
(defmethod build-clause :union-all [_ m maps]
|
||||||
(assoc m :union-all maps))
|
(assoc m :union-all maps))
|
||||||
|
|
||||||
|
(defmethod build-clause :intersect [_ m maps]
|
||||||
|
(assoc m :intersect maps))
|
||||||
|
|
|
||||||
|
|
@ -79,3 +79,8 @@
|
||||||
(is (= (format {:union-all [{:select [:foo] :from [:bar1]}
|
(is (= (format {:union-all [{:select [:foo] :from [:bar1]}
|
||||||
{:select [:foo] :from [:bar2]}]})
|
{:select [:foo] :from [:bar2]}]})
|
||||||
["(SELECT foo FROM bar1) UNION ALL (SELECT foo FROM bar2)"])))
|
["(SELECT foo FROM bar1) UNION ALL (SELECT foo FROM bar2)"])))
|
||||||
|
|
||||||
|
(deftest intersect-test
|
||||||
|
(is (= (format {:intersect [{:select [:foo] :from [:bar1]}
|
||||||
|
{:select [:foo] :from [:bar2]}]})
|
||||||
|
["(SELECT foo FROM bar1) INTERSECT (SELECT foo FROM bar2)"])))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue