honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
Eric Casteleijn 2021-06-22T20:31:36.076800Z

Is there a way to express array_agg(distinct table.field) in honeysql, specifically the distinct there, or do I have to fall back to raw in that case?

seancorfield 2021-06-22T20:39:34.077400Z

@thisfred If you’re using 2.0.0 RC 3, you can do it like this:

dev=> (sql/format-expr [:array_agg [:distinct :table/field]])
["ARRAY_AGG(DISTINCT table.field)"]

Eric Casteleijn 2021-06-22T20:39:52.077600Z

Thank you so much!

seancorfield 2021-06-22T20:40:24.078300Z

Or like this in a select:

dev=> (sql/format {:select [ [ [:array_agg [:distinct :table/field]] :agg ] ] :from :table})
["SELECT ARRAY_AGG(DISTINCT table.field) AS agg FROM table"]

Eric Casteleijn 2021-06-22T20:40:27.078500Z

I don’t think we’re on that yet, but I’ll make a note to replace the raw with that as soon as we upgrade