honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
2021-07-02T09:27:07.098800Z

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))

seancorfield 2021-07-02T15:26:29.099700Z

@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

🙌 1
2021-07-05T04:12:13.102Z

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.

2021-07-05T04:19:45.102200Z

Nevermind, I just found out about the :inline true option in format Loving this library, thank you so much for making this possible! @seancorfield

1