This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-30
Channels
- # asami (4)
- # babashka (3)
- # beginners (21)
- # biff (22)
- # cljs-dev (6)
- # clojure (11)
- # clojure-europe (3)
- # clojure-norway (35)
- # clojure-spain (4)
- # clojurescript (14)
- # datalevin (2)
- # emacs (12)
- # exercism (2)
- # fulcro (10)
- # honeysql (4)
- # humbleui (3)
- # hyperfiddle (49)
- # instaparse (1)
- # introduce-yourself (1)
- # missionary (1)
- # off-topic (109)
- # pathom (2)
- # practicalli (21)
- # random (2)
- # rdf (2)
- # releases (2)
- # scittle (3)
- # specter (2)
I've just noticed that :join
and :inner-join
get added to a query in a different order when combined with :left-join
. Is that deliberate?
The DSL is a hash map: it is inherently unordered.
There's a :join-by
construct in the DSL if you need JOIN
s in a specific order for your database (the behavior with multiple JOIN
s differs between databases... because of course it does).
Thanks, I switched to that already. I just wondered if I was missing a trick. I've noticed that hashmaps tend to be ordered by key alphabetically, and since inner-join
and join
are both ahead of left-join
, I was wondering if you were forcing the behaviour for some reason.
Small hash maps stay in key order because they use an array but that's a pure implementation detail and should never be relied on:
user=> {:b 2 :a 1}
{:b 2, :a 1}
What HoneySQL does is process clauses in "precedence order" and it uses a vector to determine that, so I've probably got all the JOIN-related clauses in alphabetical order just for maintenance purposes: https://github.com/seancorfield/honeysql/blob/develop/src/honey/sql.cljc#L1228-L1238 but modified by https://github.com/seancorfield/honeysql/blob/develop/src/honey/sql.cljc#L709-L717