I’m trying to write a query like:
(select * from table_1 limit 10 order by x) union all (select * from table_1b limit 10 order by x) limit 10 order by x
but am not able to get honey to “group” the selects in parens so i can get limit applied before and after the union
I made it work using CTEs, but that should not really be necessary(sql/format {:union-all [{:nest {:select :*}}
{:nest {:select :*}}]
:limit [:inline 10]})
=> ["(SELECT *) UNION ALL (SELECT *) LIMIT 10"]facepalm i’ve tried nest but [:nest]
This works, thanks a lot 🙂
Yeah, I tried that at first too. :)
Happy to update the docs to make that easier to figure out, if you have suggestions. The :union-all docs mention :nest https://cljdoc.org/d/com.github.seancorfield/honeysql/2.5.1103/doc/getting-started/sql-clause-reference#intersect-union-union-all-except-except-all (but don't provide an example).