Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make db->tree tolerate ParamExpr #558

Closed
olivergeorge opened this issue Dec 30, 2015 · 1 comment
Closed

Make db->tree tolerate ParamExpr #558

olivergeorge opened this issue Dec 30, 2015 · 1 comment

Comments

@olivergeorge
Copy link

Currently db->tree doesn't handle queries which include ParamExpr.

It would be useful to strip these out in the case where a remote has processed the ParamExpr and the client simply needs to access the data.

Something like the code below might be suitable.

(defn param-expr?
  "Returns true if x is param expr."
  [x]
  (and (list? x)
       (== 2 (count x))
       (map (nth x 1))))

(defn db->tree
...
       (if (= '[*] query)
         data
         (let [query (mapv #(if (param-expr? %) (first %) %) query)
               {props false joins true} (group-by #(or (join? %) (ident? %)) query)]

One thing I haven't worked out is whether it's necessary to handle QueryExpr and EdnSymbol cases separately.

ParamExpr    := EdnList2(QueryExpr | EdnSymbol, ParamMapExpr)
@swannodette
Copy link
Member

fixed c588189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants