This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-24
Channels
- # announcements (3)
- # babashka (47)
- # beginners (40)
- # biff (21)
- # calva (12)
- # cider (2)
- # clj-kondo (31)
- # cljsrn (8)
- # clojure (14)
- # clojure-berlin (2)
- # clojure-conj (1)
- # clojure-dev (24)
- # clojure-europe (84)
- # clojure-italy (8)
- # clojure-nl (1)
- # clojure-spec (1)
- # clojure-sweden (2)
- # clojure-uk (2)
- # clojurescript (34)
- # clr (3)
- # community-development (1)
- # cursive (14)
- # datalevin (8)
- # datomic (5)
- # defnpodcast (2)
- # dev-tooling (1)
- # etaoin (4)
- # events (3)
- # fulcro (26)
- # graphql (3)
- # honeysql (6)
- # hyperfiddle (45)
- # lsp (40)
- # malli (1)
- # missionary (1)
- # nbb (18)
- # podcasts-discuss (1)
- # reagent (8)
- # reitit (2)
- # releases (2)
- # ring-swagger (1)
- # scittle (78)
- # shadow-cljs (96)
- # vim (7)
- # xtdb (3)
In this https://www.opensourcery.co.za/2017/05/29/two-datoms-in-the-same-transaction-conflict/, i want to be clear, the error (below) happens because the same entity, which is unique identified by the membership/set-fee=10, in the transaction (the vector passed as the value to tx-value), is given two different instructions about what to st it's other values to. e.g :being/family-name =Malich OR Galder?
user=> (def wizards [{:being/given-name "Alberto"
:being/family-name "Malich"
:membership/number 10
:membership/set-fee 10
:membership/set-fee-justification
"Wizard discount"}
{:being/given-name "Galder"
:being/family-name "Weatherwax"
:membership/number 11
:membership/set-fee 10
:membership/set-fee-justification
"Wizard discount"}])
'user/wizards
user=> (<!! (client/transact conn {:tx-data wizards}))
{:datomic.client-spi/request-id "4c69f404-07a4-4c99-bdbb-4596c97ec1f1",
:cognitect.anomalies/category :cognitect.anomalies/incorrect,
:cognitect.anomalies/message ":db.error/datoms-conflict Two datoms in the same transaction conflict\n{:d1 [17592186045418 :being/given-name \"Alberto\" 13194139534313 true],\n :d2 [17592186045418 :being/given-name \"Galder\" 13194139534313 true]}\n",
:dbs [{:database-id "59293380-3347-4675-be0a-7daa6286b41c",
:t 1006,
:next-t 1007,
:history false}]}
So then, the attribute (:being/given-name) from this error (from the blog):
db.error/datoms-conflict Two datoms in the same transaction conflict
{:d1 [17592186045418 :being/given-name \"Alberto\" 13194139534313 true],
:d2 [17592186045418 :being/given-name \"Galder\" 13194139534313 true]}
could just have easily been :membership/number right? I feel like the error is highlighting the conflict but not the reason for it. Or i'm i missing something?
Would it also be the case, that if those two hashmaps were put into two different transactions, there would be no error? I'm like 99% sure of this, i just want to confirm that's what i should expect. In that case, the name attribute Malich would be "replaced" with Galder.The map form of data in transactions is a convenience, they need to be converted to datoms. The resulting list of datoms then includes the conflicts that your error message shows but the context that those datoms were conflicting because both maps were for the same entity is lost at that point.
In different transactions you can, of course, assert different values for an entity/attribute, so transacting the 2 map forms independently would work fine.
Thanks leaf, so far that makes sense to me.
I find it helpful to think about what the map forms in transaction data will look like as lists of datoms - as that is generally what Datomic 'speaks' (in error messages, etc.)