This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-30
Channels
- # admin-announcements (1)
- # adventofcode (2)
- # announcements (2)
- # babashka (60)
- # beginners (48)
- # cherry (1)
- # cider (16)
- # clj-kondo (4)
- # clojure (53)
- # clojure-belgium (3)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-poland (4)
- # clojure-uk (6)
- # clojuredesign-podcast (19)
- # clojurescript (39)
- # community-development (12)
- # cursive (4)
- # datalevin (7)
- # datomic (23)
- # honeysql (14)
- # hyperfiddle (3)
- # instaparse (3)
- # lsp (3)
- # malli (10)
- # off-topic (34)
- # overtone (8)
- # polylith (2)
- # re-frame (9)
- # reitit (3)
- # releases (1)
- # squint (16)
- # timbre (7)
- # wasm (2)
- # xtdb (8)
hey so I'm rewriting this monstrous stored procedure and I noticed that through accidental incorrect usage of :join-by
, HoneySQL throws this exception:
; Execution error (ExceptionInfo) at honey.sql/format-item-selection (sql.cljc:533).
; illegal syntax in select expression
which didn't mislead me for too long but I'm wondering if this is a SQL quirk or not.What I'm asking is why using :join-by
(albeit incorrectly) tells me that the syntax error is in the select expression.
I fixed my problem, so it's a matter of knowing whether this has something to do with how joins work internally, bc I do not know.
fast, minimal repro but the problem is clearly with that :and
{:select [:thing]
:from [[:table :t]]
:join-by [:left [[:table2 :t2]]
:join [[:table3 :t3]
[:= :t2.thing2 :t.thing]
[:and [:= :t2.more-conds :t3.more-conds]]]]}
It's really not a big deal that I understand this, but curiosity killed the cat.
hm, well let me try something closer to the actual query, sorry, business stuff I can't reveal.
If you join with any subqueries, then perhaps a :select
in one of those subqueries is malformed.
when I comment out what seems to be the offending clause in my query, it works fine. This is what that looks like:
{:join-by [:left [[:Things :ch]]
:join [[:ThingCode :cc]
[:= :ch.ThingCode :cc.ThingCode]]
:join [[:Degree :deg]
[:= :cc.Degree :deg.DegreeCode]
[:and
[:= :c.ThingCase :ch.ThingCase]
[:= :ch.Primary 1]]]
:left [[:Alias :d]
[:and
[:= :c.Customer :d.Person]
[:= :d.Primary 1]
[:= :d.Active 1]]]]}
i.e., if I get rid of that second :join
, there are no errors.it's a really huge CTE that is causing me a major headache as it is, so I am hard-pressed to create a better repro.
It's just an example of "garbage in, garbage out", nothing incredibly interesting here. If you really want to know, just print out the stacktrace and follow it.
fair enough, thanks.