honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
viesti 2020-08-08T19:53:12.345100Z

Hmm, is there a way to use CTE and UNION together, so that I could refer to the CTEs from the UNION clauses?

viesti 2020-08-08T19:57:06.345400Z

something like this in sql:

WITH cte AS (
  SELECT
    *
  FROM
    shared
)
SELECT
  cte.id,
  f.x
FROM
  cte
  LEFT JOIN foo f ON f.id = c.id
UNION
SELECT
  cte.id,
  b.x
FROM
  cte
  LEFT JOIN bar b ON b.id = c.id;

viesti 2020-08-08T20:07:20.346900Z

ah, hmm, just using a map {:with ... :union [...]} and referring to the cte's in the :union by name seems to work

viesti 2020-08-08T20:07:42.347200Z

the dsl tripped me off a bit