This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-26
Channels
- # beginners (91)
- # cider (34)
- # cljsrn (6)
- # clojure (95)
- # clojure-gamedev (4)
- # clojure-serbia (7)
- # clojure-spec (5)
- # clojure-uk (27)
- # clojurescript (42)
- # data-science (1)
- # datascript (2)
- # datomic (4)
- # duct (10)
- # emacs (11)
- # fulcro (21)
- # luminus (3)
- # lumo (24)
- # off-topic (2)
- # other-languages (2)
- # ring (2)
- # shadow-cljs (39)
- # spacemacs (9)
- # tools-deps (2)
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)
(:db-after)
(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},
:tx-data
[#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