Merge pull request #196 from emidln/emidln/insert-into-drop-parens
Avoid wrapping QUERY with parens while formatting INSERT INTO ... QUERY
This commit is contained in:
commit
8ad38d28af
2 changed files with 5 additions and 2 deletions
|
|
@ -540,7 +540,8 @@
|
||||||
(str "INSERT INTO "
|
(str "INSERT INTO "
|
||||||
(to-sql (ffirst table))
|
(to-sql (ffirst table))
|
||||||
" (" (comma-join (map to-sql (second (first table)))) ") "
|
" (" (comma-join (map to-sql (second (first table)))) ") "
|
||||||
(to-sql (second table)))
|
(binding [*subquery?* false]
|
||||||
|
(to-sql (second table))))
|
||||||
(str "INSERT INTO " (to-sql table))))
|
(str "INSERT INTO " (to-sql table))))
|
||||||
|
|
||||||
(defmethod format-clause :columns [[_ fields] _]
|
(defmethod format-clause :columns [[_ fields] _]
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,9 @@
|
||||||
(is (= (format-clause (first {:insert-into [:foo {:select [:bar] :from [:baz]}]}) nil)
|
(is (= (format-clause (first {:insert-into [:foo {:select [:bar] :from [:baz]}]}) nil)
|
||||||
"INSERT INTO foo SELECT bar FROM baz"))
|
"INSERT INTO foo SELECT bar FROM baz"))
|
||||||
(is (= (format-clause (first {:insert-into [[:foo [:a :b :c]] {:select [:d :e :f] :from [:baz]}]}) nil)
|
(is (= (format-clause (first {:insert-into [[:foo [:a :b :c]] {:select [:d :e :f] :from [:baz]}]}) nil)
|
||||||
"INSERT INTO foo (a, b, c) SELECT d, e, f FROM baz")))
|
"INSERT INTO foo (a, b, c) SELECT d, e, f FROM baz"))
|
||||||
|
(is (= (format {:insert-into [[:foo [:a :b :c]] {:select [:d :e :f] :from [:baz]}]})
|
||||||
|
["INSERT INTO foo (a, b, c) SELECT d, e, f FROM baz"])))
|
||||||
|
|
||||||
(deftest exists-test
|
(deftest exists-test
|
||||||
(is (= (format {:exists {:select [:a] :from [:foo]}})
|
(is (= (format {:exists {:select [:a] :from [:foo]}})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue