This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-06
Channels
- # announcements (3)
- # architecture (16)
- # beginners (5)
- # cherry (1)
- # cider (3)
- # cljsrn (2)
- # clojure (54)
- # clojure-dev (11)
- # clojure-europe (14)
- # datalevin (26)
- # emacs (8)
- # helix (5)
- # honeysql (5)
- # hyperfiddle (40)
- # lsp (12)
- # malli (23)
- # missionary (7)
- # nrepl (2)
- # off-topic (18)
- # releases (2)
- # yamlscript (1)
Morning 🙂 Is it possible to write the values + as clause in this pg query?
update users as u set -- postgres FTW
email = u2.email,
first_name = u2.first_name,
last_name = u2.last_name
from (values
(1, '', 'Hollis', 'Connell'),
(2, '', 'Robert', 'Duncan')
) as u2(id, email, first_name, last_name)
where u2.id = u.id;
e.g.,
(defn update-many-sql
[ms]
(let [ks (reduce (fn [acc m] (apply conj acc (keys m))) #{} ms)]
{:from [[[{:values (map (fn [m] (map (fn [k] (m k)) ks)) ms)}] [:v [:raw "(" (str/join ", " (map name ks)) ")"]]]]}))
Create a GitHub issue and I'll have a think about this.