This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-04
Channels
- # babashka (3)
- # beginners (103)
- # calva (2)
- # cljs-dev (4)
- # clojure (23)
- # clojure-europe (16)
- # clojure-germany (1)
- # clojuredesign-podcast (2)
- # clojurescript (5)
- # cursive (4)
- # datahike (1)
- # datascript (1)
- # depstar (13)
- # fulcro (5)
- # inf-clojure (18)
- # lsp (37)
- # meander (2)
- # nrepl (2)
- # off-topic (12)
- # releases (2)
- # rewrite-clj (2)
- # shadow-cljs (9)
- # tools-deps (26)
I have a meander puzzler: Use rewrite
to efficiently fully qualify column references in a honeysql data structure. For example:
{:select [:a] :from [:t]}
should be converted into
{:select [:t.a] :from [:t]}
There are many complicating factors including identifying column references. In my case, all column references are a special type so, the above example is more properly:
{:select [#ColRef[:a]] :from [#TableRef[:t]]}
converted to
{:select [#ColRef[:t :a]] :from [#TableRef[:t]]}
There are additional complications that are not as easy to handle including subqueries. For example:
{:select [#ColRef[:a] {:select #call["MAX" :a] :from [#TableRef[:s]]}] :from [#TableRef[:t]]}
Another complication is that some column references are already fully qualified and, thus, should not be rewritten:
{:select [#colRef[:a]] :from [#TableRef[:t]] :where #call["IN" #ColRef[:b] {:select [#ColRef[:b]] :from [#TableRef[:s]] :where #Call["=" #ColRef[:t :a] #ColRef[:s :a]]}}
I have a meander program that performs the correct rewriting but pretty slow on large honeysql data structures because (I believe) an overuse of m/$
to search for queries and column references. I don't know how to convert it to a more efficient meander program and would love some ideas