This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-03
Channels
- # adventofcode (107)
- # announcements (1)
- # asami (14)
- # babashka (67)
- # beginners (89)
- # calva (34)
- # cider (17)
- # clj-kondo (5)
- # cljs-dev (2)
- # clojure (57)
- # clojure-europe (52)
- # clojure-india (1)
- # clojure-italy (1)
- # clojure-losangeles (2)
- # clojure-nl (6)
- # clojure-uk (39)
- # clojurescript (40)
- # community-development (3)
- # conjure (3)
- # cursive (17)
- # datomic (11)
- # docker (13)
- # events (3)
- # figwheel-main (3)
- # fulcro (12)
- # graalvm (7)
- # holy-lambda (7)
- # honeysql (9)
- # introduce-yourself (5)
- # malli (9)
- # minecraft (3)
- # missionary (21)
- # nextjournal (7)
- # off-topic (52)
- # pathom (3)
- # polylith (11)
- # portal (3)
- # re-frame (21)
- # reagent (34)
- # reclojure (7)
- # reitit (1)
- # reveal (11)
- # shadow-cljs (68)
- # tools-build (12)
- # tools-deps (5)
- # vim (4)
- # xtdb (9)
I’m on a super old version of honeysql (1.0.444) and we have a bunch of places in the code that developers put in to protect ourselves before running a query with an empty collection. For a simple example, select ();
obviously returns an error (at least in postgres), so we’ve written a number of (when (seq data) (select data))
Is there something built-in to a newer version that prevents that query from being run since it’s invalid? If not, I’m pretty sure we could write some internal tooling to prevent that instead
@ajarosinski There's nothing specifically, right now, but there is now the concept of a "checking" mode (`:checking :none|:basic|:strict`) which enables certain checks and assertions in the formatted so adding logic to throw an exception if :select
has an empty?
collection argument would be pretty easy. It was originally added to check IN ()
clauses but I could extend it to SELECT
clauses to -- and anything else folks want.
Hmm, that sounds kind of interesting. I was actually thinking for the in
clause. Do you mean that you already have it for that form!?
Yes, if you say {:checking :basic}
or {:checking :strict}
in the options to sql/format
(new version) then it throws if IN
would have an empty set of values.
I'm just adding a similar check for SELECT
and similar constructs.
Just pushed that to develop. I'll cut a new release soon, I expect.
If you create an issue on the honeysql
repo, I'll add that -- and any other "lint"-like checks folks can think of.
https://github.com/seancorfield/honeysql/releases/tag/v2.1.833 -- includes a bug fix for merging select-distinct-on
and expands the "lint"-like checks to SELECT
and a bunch of other clauses that expect a non-empty list of columns (when :checking
is :basic
or :strict
-- by default, checking is :none
).