honeysql

Gent Krasniqi 2026-01-25T22:26:16.872989Z

Probably a long shot, but is syntax like this supported without extending honeysql?

select
    * EXCLUDE (col1, col2),
    other.col1,
    other.col2
from ...
I think the above is pretty specific to duckdb.

p-himik 2026-01-25T22:34:31.619089Z

Not specific, no.

(sql/format {:select [[:* {:exclude [:coll1 :coll2]}] :other.coll1 :other.coll2]})
=> ["SELECT * EXCLUDE (coll1, coll2), other.coll1, other.coll2"]

Gent Krasniqi 2026-01-25T22:40:39.463069Z

Great, thanks! I'm just now exploring honeysql, sorry, haven't covered all of the documentation yet.

p-himik 2026-01-25T22:41:22.797519Z

No problem. :) This is one of the things this channel is for.

seancorfield 2026-01-25T22:57:46.532329Z

That was added for XTDB -- I didn't realize it was DuckDB as well https://cljdoc.org/d/com.github.seancorfield/honeysql/2.7.1368/doc/getting-started/xtdb-support?q=%3Aexclude#select-variations

p-himik 2026-01-25T23:03:03.177099Z

ClickHouse also supports it: https://clickhouse.com/docs/sql-reference/statements/select/except

Gent Krasniqi 2026-01-25T23:03:22.011999Z

Yes, DuckDB also has https://duckdb.org/docs/stable/sql/query_syntax/select but that doesn't seem as necessary once you have EXCLUDE.

seancorfield 2026-01-25T23:21:46.247759Z

@p-himik EXCEPT is different to EXCLUDE -- HoneySQL has supported EXCEPT and REPLACE since 2022:

user=> (sql/format {:select [[:* :except [:a :b :c]]] :from [:table]})
["SELECT * EXCEPT (a, b, c) FROM table"]
user=> (sql/format {:select [[:* :replace [[[:* :a [:inline 100]] :b] [[:inline 2] :c]]]] :from [:table]})
["SELECT * REPLACE (a * 100 AS b, 2 AS c) FROM table"]
user=> (sql/format {:select [[:* :except [:a :b] :replace [[[:inline 2] :c]]]] :from [:table]})
["SELECT * EXCEPT (a, b) REPLACE (2 AS c) FROM table"]

p-himik 2026-01-25T23:22:15.615449Z

Ah, I can't read.

seancorfield 2026-01-25T23:23:02.731579Z

I probably should have made :exclude follow the same syntax but I think maybe XTDB allows more complex stuff which is why I didn't?

Gent Krasniqi 2026-01-26T16:13:12.135269Z

The programmability of the EXCLUDE implementation (e.g. with update-in) seems a bit better. In fact I can't help but think that a uniform syntax of: a vector where the second element is always an optional map (so even (h/select [:longname {:as :short}])) would make the syntax a bit more memorable.

seancorfield 2026-01-26T16:31:45.685229Z

Feel free to create a GH issue for future consideration...