honeysql

Jo Øivind Gjernes 2024-09-11T08:34:02.057019Z

I’m trying to write a CTE and force it to be materialized (psql) The sql would look like: with cte as materialized (select * from stuff) Any pointers how i can get it done in honeysql?

p-himik 2024-09-11T08:39:22.492599Z

Doesn't seem to be documented, but after looking at the source it seems that this is how you do it:

(sql/format {:with [[:cte {:select :* :from :stuff} :materialized]]})
=> ["WITH cte AS MATERIALIZED (SELECT * FROM stuff)"]

2
Jo Øivind Gjernes 2024-09-11T09:00:05.957479Z

Works! Thank you 🙂

👍 1
🎉 1
seancorfield 2024-09-11T16:04:29.045589Z

It was added in this PR but never made it into the docs https://github.com/seancorfield/honeysql/pull/420/files -- if either of you feel inclined to create an issue about it, so I don't forget, or even a PR against the docs, I'd appreciate that!

Jo Øivind Gjernes 2024-09-11T16:05:24.995749Z

I’ll take a crack at the docs tomorrow 👍

1