honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
valerauko 2020-11-11T07:48:51.198100Z

@seancorfield is there any way to cache the sql text part from repeated format calls?

valerauko 2020-11-11T07:56:07.198400Z

i honestly don't understand how the params argument to format works

dominicm 2020-11-11T09:33:09.198700Z

Does anyone have a convenient left-join-lateral snippet to hand? :D There doesn't seem to be one just floating about unfortunately.

seancorfield 2020-11-11T17:00:11.199400Z

@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

dominicm 2020-11-11T18:33:57.199700Z

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.

dominicm 2020-11-11T18:40:44.199800Z

(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!

dharrigan 2020-11-11T19:03:18.200600Z

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)

dharrigan 2020-11-11T19:03:28.200900Z

I may stick with a materialized view even after that

dharrigan 2020-11-11T19:03:50.201500Z

the mechanics are then just hidden behind what looks like (to honeysql) a normal table

dharrigan 2020-11-11T19:04:23.202100Z

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

dominicm 2020-11-11T19:25:16.202700Z

Unfortunately I can't use in this case, I need to lateral against a subquery

seancorfield 2020-11-11T19:33:45.202900Z

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.