File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 130130 (sqlf/space-join (format-upsert-clause upsert)))
131131
132132(defmethod format-clause :returning [[_ fields] _]
133- (str " RETURNING " (sqlf/comma-join (map sqlf/to-sql fields))))
133+ (->> (flatten fields)
134+ (map sqlf/to-sql)
135+ (sqlf/comma-join )
136+ (str " RETURNING " )))
134137
135138(defmethod format-clause :create-view [[_ viewname] _]
136139 (str " CREATE VIEW " (-> viewname
Original file line number Diff line number Diff line change 1111 from order-by update sset query-values
1212 modifiers]]
1313 [honeysql.core :as sql]
14- [clojure.test :as test :refer [deftest is testing]]))
14+ [clojure.test :as test :refer [deftest is testing]]
15+ [clojure.string :as str]))
1516
1617(deftest upsert-test
1718 (testing " upsert sql generation for postgresql"
6970 (testing " returning clause in sql generation for postgresql"
7071 (is (= [" DELETE FROM distributors WHERE did > 10 RETURNING *" ]
7172 (sql/format {:delete-from :distributors
72- :where [:> :did :10 ]
73- :returning [:* ]})))
74- (is (= [" UPDATE distributors SET dname = ? WHERE did = 2 RETURNING did dname" " Foo Bar Designs" ]
75- (-> (update :distributors )
76- (sset {:dname " Foo Bar Designs" })
77- (where [:= :did :2 ])
78- (returning [:did :dname ])
79- sql/format)))))
73+ :where [:> :did :10 ]
74+ :returning [:* ]})))
75+ (doseq [returning-columns (reductions conj [] [:did :dname :nos ])]
76+ (is (= [(str " UPDATE distributors SET dname = ? WHERE did = 2 RETURNING " (str/join " , " (map name returning-columns))) " Foo Bar Designs" ]
77+ (-> (update :distributors )
78+ (sset {:dname " Foo Bar Designs" })
79+ (where [:= :did :2 ])
80+ (returning returning-columns)
81+ sql/format))))))
8082
8183(deftest create-view-test
8284 (testing " creating a view from a table"
You can’t perform that action at this time.
0 commit comments