This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-16
Channels
- # announcements (33)
- # atom-editor (1)
- # aws (21)
- # babashka (174)
- # babashka-sci-dev (2)
- # beginners (59)
- # calva (4)
- # chlorine-clover (9)
- # clj-kondo (51)
- # clojars (7)
- # clojure (86)
- # clojure-czech (4)
- # clojure-europe (21)
- # clojure-france (6)
- # clojure-nl (1)
- # clojure-uk (2)
- # conjure (7)
- # core-async (3)
- # core-logic (3)
- # cursive (10)
- # data-science (8)
- # datalevin (14)
- # datomic (12)
- # events (1)
- # fulcro (5)
- # graalvm (10)
- # gratitude (3)
- # honeysql (3)
- # hyperfiddle (3)
- # introduce-yourself (4)
- # joyride (3)
- # leiningen (3)
- # malli (13)
- # minecraft (15)
- # music (1)
- # off-topic (40)
- # pathom (16)
- # polylith (28)
- # portal (25)
- # rdf (15)
- # remote-jobs (3)
- # shadow-cljs (23)
- # specter (1)
- # sql (5)
- # tools-deps (25)
- # xtdb (31)
Hi. Sounds like honeysql can be used in clojurescript. Anyone has used honeysql with an in-browser database like sql.js, how do you feel?
I'd like to extend HoneySQL (1) to support H2's MERGE INTO
syntax (`MERGE INTO mytable (x, y, x) KEY(x) VALUES('foo', 'bar', 'baz')`). How would I go about this?
Nevermind! Turns out it was way easier than I'd thought it'd be:
(defmethod honeysql.format/format-clause :merge-into [[_ table] _]
(str "MERGE INTO " (honeysql.format/to-sql table)))
(defmethod honeysql.format/format-clause :key [[_ ks] _]
(str "KEY (" (clojure.string/join ", " (map name ks)) \)))
(honeysql.format/register-clause! :merge-into 61)
(honeysql.format/register-clause! :key 91)
(hh/format {:merge-into :foo, :key [:foo :bar], :columns [:foo :bar :baz], :values [[1 2 3]]})
; => ["MERGE INTO foo (foo, bar, baz) KEY (foo, bar) VALUES (?, ?, ?)" 1 2 3]