This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-09
Channels
- # announcements (26)
- # babashka (4)
- # beginners (17)
- # calva (21)
- # cider (13)
- # clerk (17)
- # clj-commons (23)
- # clj-kondo (3)
- # cljdoc (47)
- # cljsrn (10)
- # clojure (123)
- # clojure-belgium (2)
- # clojure-dev (25)
- # clojure-europe (34)
- # clojure-gamedev (2)
- # clojure-italy (1)
- # clojure-nl (3)
- # clojure-norway (4)
- # clojure-uk (4)
- # clojurescript (86)
- # cursive (12)
- # datahike (2)
- # datomic (2)
- # emacs (4)
- # fulcro (6)
- # funcool (15)
- # instaparse (1)
- # integrant (11)
- # jobs (1)
- # joyride (9)
- # kaocha (3)
- # membrane (8)
- # off-topic (1)
- # pathom (4)
- # practicalli (2)
- # quil (1)
- # rdf (1)
- # reagent (9)
- # remote-jobs (1)
- # shadow-cljs (27)
- # spacemacs (4)
- # specter (1)
- # sql (11)
- # tools-deps (55)
- # vim (1)
@seancorfield another difference I noticed between HoneySQL 1 and Honey SQL 2 is that the format accepts > 2 args for predicates like :/
, while the latter explicitly disallows it...
(honeysql.core/format {:select [[(honeysql.core/call :/ 1 2 3) :x]]})
;; => ["SELECT (1 / 2 / 3) AS x"]
(honey.sql/format {:select [[[:/ 1 2 3] :x]]})
;; => only binary :/ is supported
Would you accept a PR to add this to the "Differences from 1.x" dox?
Or should Honey SQL 2 support this? After all, it works in Clojure:
(/ 1 2 3) => 1/6 ; the same as (/ (/ 1 2) 3)
I guess there's no real reason to restrict a lot of operators to pure binary. I did it initially because I thought it might catch possible bugs in code and would force people to be more explicit...
...I recently made :-
variadic I think?
There's some special-case code for :=
and :<>
in the binary case https://github.com/seancorfield/honeysql/blob/develop/src/honey/sql.cljc#L1564 but that could be lifted into the variadic case and all operators could be allowed to be variadic, not just these: https://github.com/seancorfield/honeysql/blob/develop/src/honey/sql.cljc#L1282
Although, being variadic or not is exposed in the API for register-op!
...
I'm happy to open an issue or submit a PR to either add it to the dox or support it
RE exposing things in the API: this is a little bit tangential, but I would love a way to be able to check whether a function is registered or not.
In some validation code I'm working on I'm basically doing (contains? @@#'sql/special-syntax f)
to verify that methods are emitting valid Honey SQL clauses.
(defn- registered-honey-sql-2-clause?
[x]
(and (vector? x)
(let [f (first x)]
(and (keyword? f)
;; this is a bit hacky but there's no other way AFAIK to tell whether a function is registered in Honey
;; SQL 2.
(contains? @@#'sql/special-syntax f)))))
It's icky and if there was an official function to do that I would definitely prefer to use it. Happy to open an issue or a PR for that as wellHaha... you crazy Metabase peeps! 🙂 Sure, open an issue to add a way to test for that, and for a registered operator. Also, open an issue about variadic operators -- I'll need to give that one a bit more thought.
opened https://github.com/seancorfield/honeysql/issues/458 and https://github.com/seancorfield/honeysql/issues/459, let me know if I can help with anything else. Happy to submit PRs or add more context to the issues
For anyone following this thread but not #C66EM8D5H both of these issues were addressed today in the 2.4.979 release.