Added recursive queries and unions.

This commit is contained in:
Alexander K. Hudek 2015-01-20 17:23:24 -05:00
parent 7fc3b371b0
commit cbb7929c36
2 changed files with 19 additions and 1 deletions

View file

@ -156,7 +156,7 @@
(def clause-order
"Determines the order that clauses will be placed within generated SQL"
[:with :select :insert-into :update :delete-from :columns :set :from :join
[:with :with-recursive :select :insert-into :update :delete-from :columns :set :from :join
:left-join :right-join :where :group-by :having :order-by :limit :offset
:values :query-values])
@ -393,3 +393,12 @@
(defmethod format-clause :with [[_ ctes] _]
(str "WITH " (comma-join (map cte->sql ctes))))
(defmethod format-clause :with-recursive [[_ ctes] _]
(str "WITH RECURSIVE " (comma-join (map cte->sql ctes))))
(defmethod fmt/format-clause :union [[_ maps] _]
(string/join " UNION " (map fmt/to-sql maps)))
(defmethod fmt/format-clause :union-all [[_ maps] _]
(string/join " UNION ALL " (map fmt/to-sql maps)))

View file

@ -215,3 +215,12 @@
(defmethod build-clause :with [_ m ctes]
(assoc m :with ctes))
(defmethod build-clause :with-recursive [_ m ctes]
(assoc m :with-recursive ctes))
(defmethod build-clause :union [_ m maps]
(assoc m :union maps))
(defmethod build-clause :union-all [_ m maps]
(assoc m :union-all maps))