This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-20
Channels
- # announcements (2)
- # babashka (1)
- # bangalore-clj (1)
- # beginners (5)
- # cider (16)
- # clojure (125)
- # clojure-spec (3)
- # clojure-uk (5)
- # clojurescript (27)
- # cursive (46)
- # data-science (3)
- # dirac (2)
- # emacs (11)
- # fulcro (2)
- # graphql (4)
- # luminus (2)
- # nrepl (1)
- # pathom (15)
- # re-frame (1)
- # reagent (52)
- # shadow-cljs (149)
- # sql (11)
- # tools-deps (11)
- # xtdb (14)
I want to build the following sql - ["INSERT INTO sample (name) VALUES (?) RETURNING id" "Joe"]
Below is my honeysql -
(-> (helpers/insert-into :sample)
(helpers/values [{:name name}])
(sql/format))
I am not sure how to add the (sql/raw "RETURNING id)
at the end of the query.(defmethod fmt/format-clause :on-conflict-do-nothing [[_ _] _]
(str "ON CONFLICT DO NOTHING"))
(defhelper on-conflict-do-nothing [m _]
(assoc m :on-conflict-do-nothing []))
(insert-into :foo-bar)
(values (m/convert event))
(db/on-conflict-do-nothing)
sql/format))]
thanks @dharrigan this worked -
(-> (helpers/insert-into :passengers)
(helpers/values [{:name name}])
(psqlh/returning :id)
(sql/format))