Fork me on GitHub

Anybody knows why this doesn't work?

(let [conn    (d/create-conn
               {:user/name {:db/unique :db.unique/identity}})
      tempid  (d/tempid :db.part/user)
      tx-data [[:db/add tempid :user/name "foobar"]
               [:db.fn/cas tempid :foo/bar nil true]]]
  (-> @conn
      (d/with tx-data)
      (d/pull ['*] [:user/name "foobar"])))
Pulled data doesn't have :foo/bar key: {:db/id 1, :user/name "foobar"} Inspecting the tx-report yields:
{:db-before {},
 :db-after {-1000064 :foo/bar, 1 :user/name},
 [#datascript/Datom [1 :user/name "foobar" 536870913 true]
  #datascript/Datom [-1000064 :foo/bar true 536870913 true]],
 :tempids {-1000064 1, :db/current-tx 536870913}, 
 :tx-meta nil}
The datom has different eid. If I replace tempid with hard-coded positive integer e.g 1, it yields the correct result: {:db/id 1, :foo/bar true, :user/name "foobar"}


@funyako.funyao156 please create an issue. I’ll take a look when I have time