fix #478 by removing duplication in one branch
This commit is contained in:
parent
3f31e5a61f
commit
e8753efa3e
2 changed files with 9 additions and 9 deletions
|
|
@ -902,15 +902,15 @@
|
|||
[sets & set-params]
|
||||
(if (map? fields)
|
||||
(format-set-exprs k fields)
|
||||
[(str/join ", "
|
||||
(map (fn [e]
|
||||
(let [e (format-entity e {:drop-ns true})]
|
||||
(str e " = EXCLUDED." e)))
|
||||
fields))])
|
||||
[(str (sql-kw k) " "
|
||||
(str/join ", "
|
||||
(map (fn [e]
|
||||
(let [e (format-entity e {:drop-ns true})]
|
||||
(str e " = EXCLUDED." e)))
|
||||
fields)))])
|
||||
where (or (:where x) ('where x))
|
||||
[sql & params] (when where (format-dsl {:where where}))]
|
||||
(-> [(str (sql-kw k) " " sets
|
||||
(when sql (str " " sql)))]
|
||||
(-> [(str sets (when sql (str " " sql)))]
|
||||
(into set-params)
|
||||
(into params)))
|
||||
(format-set-exprs k x))
|
||||
|
|
|
|||
|
|
@ -93,14 +93,14 @@
|
|||
(upsert (-> (on-conflict (on-constraint :distributors_pkey))
|
||||
do-nothing))
|
||||
sql/format)))
|
||||
(is (= ["INSERT INTO foo (id, data) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET DO UPDATE SET into = ((STATE(?), MODIFIED(NOW()))) WHERE state = ?" 1 42 "enabled" "disabled"]
|
||||
(is (= ["INSERT INTO foo (id, data) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET into = ((STATE(?), MODIFIED(NOW()))) WHERE state = ?" 1 42 "enabled" "disabled"]
|
||||
(sql/format (-> (insert-into :foo)
|
||||
(values [{:id 1 :data 42}])
|
||||
(upsert (-> (on-conflict :id)
|
||||
(do-update-set [:state "enabled"]
|
||||
[:modified [:now]])
|
||||
(where [:= :state "disabled"])))))))
|
||||
(is (= ["INSERT INTO foo (id, data) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET DO UPDATE SET state = ?, modified = NOW() WHERE state = ?" 1 42 "enabled" "disabled"]
|
||||
(is (= ["INSERT INTO foo (id, data) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET state = ?, modified = NOW() WHERE state = ?" 1 42 "enabled" "disabled"]
|
||||
(sql/format (-> (insert-into :foo)
|
||||
(values [{:id 1 :data 42}])
|
||||
(upsert (-> (on-conflict :id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue