apa512 / clj-rethinkdb

Eclipse Public License 1.0
204 stars 42 forks source link

`:temp-var` leaks into query result #191

Open lukaszkorecki opened 7 years ago

lukaszkorecki commented 7 years ago

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 https://github.com/apa512/clj-rethinkdb/blob/b8c9635dffa039d8701cd1278b6102220ffb2f28/src/rethinkdb/query.cljc#L43-L48 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