@seancorfield is there any way to cache the sql text part from repeated format calls?
i honestly don't understand how the params argument to format works
Does anyone have a convenient left-join-lateral snippet to hand? :D There doesn't seem to be one just floating about unfortunately.
@vale Can you shared what code you tried and what you're struggling with? There are examples in the readme: https://github.com/seancorfield/honeysql#bindable-parameters
So, technically unrelated to above. How can I get honeysql to represent "lateral" in from
? Syntax is like:
SELECT * FROM foo, LATERAL (select * from bar) b WHERE b.xyz …
So I need to prefix the table name with LATERAL.(sql/format {:select [:*]
:from [[[(sql/inline "LATERAL")
(binding [honeysql.format/*subquery?* true]
(honeysql.format/to-sql {:select [:*] :from [:baz]}))]
:s]]})
This, uh, works but feels very wrong!I use a few laterals, but until honeysql v2 comes along, with an easy way to add them, I simply use a view (in my case a materialized view)
I may stick with a materialized view even after that
the mechanics are then just hidden behind what looks like (to honeysql) a normal table
views are lovely, materialized views even better (if you can control the refresh), for you can stick indexes on materialized views and do all sorts of nice things
https://www.ibm.com/support/knowledgecenter/en/SSGU8G_11.70.0/com.ibm.sqls.doc/ids_sqs_0254.htm ansi apparently!
Unfortunately I can't use in this case, I need to lateral against a subquery
Cool. Then it can go in core. Please create an issue with that link. I may not implement it in v1, depending on how difficult it might be, but I'll certainly add it to v2.