sql

dpsutton 2024-12-17T22:15:29.604969Z

had to look up how to do something in honeysql and this https://github.com/seancorfield/honeysql/blob/develop/doc/clause-reference.md is so nice. Thank you!

seancorfield 2024-12-17T22:26:02.548379Z

Thank you. It's the result of a lot of community feedback! I find this easier to work with BTW https://cljdoc.org/d/com.github.seancorfield/honeysql/2.6.1243/doc/getting-started/sql-clause-reference since it also has the API reference etc.

👀 1
dpsutton 2024-12-17T22:30:03.123919Z

yeah that’s nice. I misread them a bit too. you use symbols with i thought were the sql helpers which i almost never use. But they are just quoted symbols example

user=> (sql/format '{with ((stuff {select (:*) from (foo)}),
                           (nonsense {select (:*) from (bar)}))
                     select (foo.id,bar.name)
                     from (stuff, nonsense)
                     where (= status 0)})
["WITH stuff AS (SELECT * FROM foo), nonsense AS (SELECT * FROM bar) SELECT foo.id, bar.name FROM stuff, nonsense WHERE status = ?" 0]
this one i missed the quote and glossed over it because i thought it was based on all of these mentioned at the top
(refer-clojure :exclude '[partition-by])
(require '[honey.sql :as sql]
         '[honey.sql.helpers :as h :refer [select from join-by left-join join
                                           where order-by over partition-by window]])

seancorfield 2024-12-17T22:32:51.125969Z

Initially, it was all keywords and values but feedback from the community was that examples with the quoted-symbolic form should also be included, so the docs are now a deliberate mix of both... I didn't want to duplicate every example to show both styles. Always open to suggestions on how to clarify things.

dpsutton 2024-12-17T22:33:52.139559Z

yeah. it’s good to have both. i thought at first they were almost all the helper version. I see it now. We use keywords which visually stand out as clearly not the helper versions. easy to miss with the symbol version, especially when the quote it further up at the top of the map

seancorfield 2024-12-17T22:35:45.376649Z

You can mix'n'match styles, and also mix'n'match with helpers too. I often write core query fragments in quoted-symbolic forms then use helpers to conditionally add more pieces.