Improve on conflict on constraint syntax
This commit is contained in:
parent
155ae25ad0
commit
331597b22b
2 changed files with 8 additions and 2 deletions
|
|
@ -503,6 +503,10 @@
|
|||
" (" (format-entity (first x)) ") "
|
||||
sql)]
|
||||
params))
|
||||
(and (sequential? x) (= 1 (count x)))
|
||||
(format-on-conflict k (first x))
|
||||
(and (sequential? x) (= 0 (count x)))
|
||||
[(sql-kw k)]
|
||||
:else
|
||||
(throw (ex-info "unsupported :on-conflict format"
|
||||
{:clause x}))))
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@
|
|||
|
||||
(defn on-conflict
|
||||
[& args]
|
||||
(generic-1 :on-conflict args))
|
||||
(generic :on-conflict args))
|
||||
|
||||
(defn on-constraint
|
||||
"Accepts a single constraint name."
|
||||
|
|
@ -570,10 +570,12 @@
|
|||
(do-update-set :x {:where [:<> :x nil]}))"
|
||||
([clause] (upsert {} clause))
|
||||
([data clause]
|
||||
(let [{:keys [on-conflict do-nothing do-update-set where]} clause]
|
||||
(let [{:keys [on-conflict on-constraint do-nothing do-update-set where]} clause]
|
||||
(cond-> data
|
||||
on-conflict
|
||||
(assoc :on-conflict on-conflict)
|
||||
on-constraint
|
||||
(assoc :on-constraint on-constraint)
|
||||
do-nothing
|
||||
(assoc :do-nothing do-nothing)
|
||||
do-update-set
|
||||
|
|
|
|||
Loading…
Reference in a new issue