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
|
||||
|
||||
* Add support for :intersect clause (@jakemcc)
|
||||
|
||||
## 0.6.2
|
||||
|
||||
Support column names in :with clauses (@emidln)
|
||||
|
|
|
|||
|
|
@ -531,6 +531,9 @@
|
|||
(defmethod format-clause :union-all [[_ 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]
|
||||
(str "CASE "
|
||||
(space-join
|
||||
|
|
|
|||
|
|
@ -236,3 +236,6 @@
|
|||
|
||||
(defmethod build-clause :union-all [_ m 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]}
|
||||
{: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