As far as I can tell that should work. I would be interested in seeing whether breaking that into two transactions works. But this should work in Datomic and I would expect it to in DataScript. I'd GH issue.
Yeah, I'm thinking it's some new VM optimisation breaking protocols. Behold the insanity...
datascript.db/maybe-wrap-multival.b not a collection at all, so definitely a single value {vs [{:sighting/id 123}], (type vs) #object[_i], (arrays/array? vs) false, (coll? vs) false, (map? vs) false}
That debugging statement confirms that vs
which is a vector is not a coll?
!
I'd had fleeting glimpses of some odd behaviour with clj->js recently which I'm starting to suspect is related to the same issue.
Here's some sample code and logged output. Note that vs
is a vector, (coll? vs)
is false but (satisfies? ICollection vs)
is true!
https://gist.github.com/olivergeorge/f4251884d74f32bba2025ebc48b626ef
Only observed using the release config on iOS simulator so I guess some VM optimisation is causing an issue.
Late follow up on this. Problem was not with datascript.
[{:sighting/id 123}] isnt a collection of lookup It should be [[:sighting/id 123]] @olivergeorge