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

:temp-var leaks into query result #191

Open
lukaszkorecki opened this issue Oct 5, 2017 · 0 comments
Open

:temp-var leaks into query result #191

lukaszkorecki opened this issue Oct 5, 2017 · 0 comments

Comments

@lukaszkorecki
Copy link

We run schema validations on our inputs and outputs and we've noticed that sometimes we get a ":temp-var row" added to a result of one of our queries.

I'm still investigating this and don't have a 100% reproducible test case, but it appears that fn macro

(defmacro fn [args & [body]]
(let [new-args (into [] (clojure.core/map
#(hash-map :temp-var (keyword %)) args))
new-replacements (zipmap args new-args)
new-terms (walk/postwalk-replace new-replacements body)]
(func new-args new-terms)))

sometimes adds :temp-var <name of arg> into resulting document.

I've looked into it and we do something like this:

(-> (r/table "foo")
       (r/get-all ids)
        (r/merge (r/fn [row] 
                            { :bar (some-ns/get-some-other-data row)
                               :baz (-> (r/table "qux")
                                              (r/get-all ids {:index "parent_id"})
                                              (r/merge (r/fn [row] (some-ns/get-some-other-data row)))}))

     (r/run connection))

(it's a bit hard to come up with a reproducible test case, our data model is quite complicated)

This doesn't happen v. often, and there doesn't seem to be any pattern as to why it might be happening. Only guess I have at the moment it might have something to do with the size of documents, but it might be a red-herring.

Workaround is to dissoc :temp-var from the resulting object.


As soon as I have a reliable test case which reproduces this issue I'll post it here

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

1 participant