This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-02
Channels
- # announcements (9)
- # asami (5)
- # babashka (16)
- # beginners (134)
- # chlorine-clover (3)
- # cider (15)
- # clojure (75)
- # clojure-australia (3)
- # clojure-europe (29)
- # clojure-nl (2)
- # clojure-uk (15)
- # clojured (4)
- # clojurescript (34)
- # cursive (9)
- # datomic (16)
- # duct (7)
- # events (4)
- # fulcro (2)
- # helix (5)
- # honeysql (4)
- # jobs (9)
- # lsp (55)
- # malli (31)
- # music (3)
- # re-frame (3)
- # reitit (1)
- # remote-jobs (1)
- # ring (3)
- # sci (5)
- # shadow-cljs (46)
- # specter (3)
- # tools-deps (60)
- # vim (5)
- # xtdb (15)
What would the DSL look like if my raw SQL were to look like this?
INSERT INTO profiles_to_countries (profile_id, country_id)
SELECT '04d6b414-2163-476d-8d20-91f918f63045', c.id
FROM countries c
WHERE c.region = 'Africa'
My select statement returns a list of values which are them inserted in a join table. My incomplete statement is somewhat like this. I am unsure how the c.id
bit would translate to the DSL
(->
(sqlh/insert-into :profiles_to_countries)
(sqlh/select [(:profiles_id m) ()])
(sql/format))
@krishanvj There are examples of this in the docs https://cljdoc.org/d/com.github.seancorfield/honeysql/2.0.0-rc3/doc/getting-started/sql-clause-reference#insert-into
Thanks! @U04V70XH6. Is it possible to interpolate variables directly into the SQL statement rather than using bindings with HoneySQL? e.g:
INSERT INTO profile (name, age) VALUES ("John Doe", "30")
instead of
INSERT INTO profile (name, age) VALUES (?, ?)
My intention is to generate an SQL file which I can use for an up.sql
migration script.
Nevermind, I just found out about the :inline true
option in format
Loving this library, thank you so much for making this possible! @U04V70XH6