tonsky/datascript — pull request #17 by bobby (2014-08-28 05:08:29+00:00)
Title: Add failing test case around entity navigation after (touch)

It looks like there is some state/cache inconsistency around (touch) for card/many reference attrs. I've added a failing test case to demonstrate the issue. The bottom line is:

``` clojure
;; Using data from test.datascript/test-entity-refs
(-> (e 1) :children first :children)
; => #{(e 100) (e 101)}
(-> (e 1) :children first touch :children)
; => #{100 101}
```

(touch) is only intended for inspecting an entity when working at the REPL. It should not be called in application code, and certainly should not be relied upon in your protocol implementations (-seq, -count, etc.). I believe that pulling touch (and touched) out of the low-level implementation and into a top-level convenience function will greatly simplify and make more consistent your implementation of Entity.