diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 3c86e63..f45d527 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -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})))) diff --git a/src/honey/sql/helpers.cljc b/src/honey/sql/helpers.cljc index bb30f37..f23d7e8 100644 --- a/src/honey/sql/helpers.cljc +++ b/src/honey/sql/helpers.cljc @@ -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