Merge eebf9fff0c into ee2b778d52
This commit is contained in:
commit
c9d0420f53
2 changed files with 8 additions and 3 deletions
|
|
@ -507,10 +507,12 @@
|
|||
|
||||
(defmethod format-clause :delete-from [[_ table] _]
|
||||
(str "DELETE FROM " (to-sql table)))
|
||||
|
||||
|
||||
(defn cte->sql
|
||||
[[cte-name query]]
|
||||
(str (to-sql cte-name) " AS " (to-sql query)))
|
||||
(if (sequential? cte-name)
|
||||
(str (to-sql (first cte-name)) " " (to-sql (second cte-name)) " AS " (to-sql query))
|
||||
(str (to-sql cte-name) " AS " (to-sql query))))
|
||||
|
||||
(defmethod format-clause :with [[_ ctes] _]
|
||||
(str "WITH " (comma-join (map cte->sql ctes))))
|
||||
|
|
|
|||
|
|
@ -24,7 +24,10 @@
|
|||
"WITH query AS SELECT foo FROM bar"))
|
||||
(is (= (format-clause
|
||||
(first {:with-recursive [[:query {:select [:foo] :from [:bar]}]]}) nil)
|
||||
"WITH RECURSIVE query AS SELECT foo FROM bar")))
|
||||
"WITH RECURSIVE query AS SELECT foo FROM bar"))
|
||||
(is (= (format-clause
|
||||
(first {:with [[[:static {:columns [:a :b :c]}] {:values [[1 2 3] [4 5 6]]}]]}) nil)
|
||||
"WITH static (a, b, c) AS VALUES (1, 2, 3), (4, 5, 6)")))
|
||||
|
||||
(deftest insert-into
|
||||
(is (= (format-clause (first {:insert-into :foo}) nil)
|
||||
|
|
|
|||
Loading…
Reference in a new issue