We just discoverered that Datascript compares entities differently from Datomic. This surprised us quite a bit, is there a rationale for this difference? Example in ๐งต
(let [conn (d/create-conn {:person/id {:db/cardinality :db.cardinality/one
:db/unique :db.unique/identity}})]
(d/transact! conn [{:person/id "bob"
:person/name "Bob"
;;:person/friends ["alice" "wendy"]
}])
(let [bob (d/entity @conn [:person/id "bob"])]
(d/transact! conn [{:db/id "alice"
:person/id "alice"
:person/boss "wendy"
:person/name "Alice"}])
(let [bob2 (d/entity @conn [:person/id "bob"])]
[(:db/id bob)
(:db/id bob2)
(= bob bob2)
])
)
)
This returns [1 1 false] in Datascript and [17592186045418 17592186045418 true] in DatomicMy understanding: Datomic considers :db/id to uniquely define equality for entities, while Datascript seems to use :db/id plus database value as the basis for comparison.
It probably uses database's T value, not the entire database. I donโt remember if there was a specific reason, might be just common sense
Unfortunately that means Iโm not sure if I can safely change that behaviour
Yeah, I guessed it would be the T value. Understandable, but this is a bit of a footgun when coming from Datomic ๐
Sorry
You can always compare entity ids yourself
๐