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! @seancorfield. 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! @seancorfield