Fork me on GitHub
#datomic
<
2022-08-09
>
pppaul17:08:59

i'm trying to use [:db/cas on a attr that is a db/ident val but i can't use the ident val as a placeholder for the db/id, and cas fails saying it compared my ident keyword with the db/id and they weren't the same. anyone else run into this issue? do i have to do id lookups when using cas like this?

pppaul17:08:32

(db/transact db/conn [[:db/cas
                       17592186048479
                       :registration.stub/state
                       :registration.state/pending-principal-acceptance
                       :registration.state/membership-accepted
                       ]])

pppaul17:08:38

{:a :registration.stub/state,
    :e 17592186048479,
    :v 17592186046002,
    :v-old :registration.state/pending-principal-acceptance,
    :cognitect.anomalies/category :cognitect.anomalies/conflict,
    :cognitect.anomalies/message "Compare failed: :registration.state/pending-principal-acceptance 17592186046002",
    :db/error :db.error/cas-failed}

ghadi18:08:52

gotta (d/entid ) them

pppaul18:08:17

that's what i ended up doing to get cas working, though through pull. i'll use entid instead. i thought i may just be doing something wrong in that case.

Ivar Refsdal18:08:18

Any reason why Datomic does not try to (d/entid) them itself?

souenzzo08:08:21

many years ago, when datomic had a "suggest a feature" portal, I suggested the feature "support eid/refs in db/cas" and it had some "upvotes".

👍 1
ghadi19:08:38

@ivar.refsdal @pppaul my guess is either performance, or that the ident is a reference (not a value), and refs can change

pppaul19:08:57

i feel like this is just an oversight in the cas function

joshkh21:08:00

small typo on thew dev-local maven configuration page 😇

picard-facepalm 1
gratitude-thank-you 1