Merge pull request #103 from jakemcc/add-intersect
add intersect support
This commit is contained in:
commit
0662a00722
4 changed files with 13 additions and 0 deletions
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
Fix bug when SqlCall/SqlRaw object is first argument to another helper (@MichaelBlume)
|
||||
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -241,3 +241,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