Skip to content

:temp-var leaks into query result #191

@lukaszkorecki

Description

@lukaszkorecki

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions