This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-16
Channels
- # announcements (1)
- # babashka (13)
- # beginners (33)
- # calva (26)
- # cherry (33)
- # clerk (5)
- # clj-kondo (3)
- # clojure (40)
- # clojure-europe (24)
- # clojure-finland (2)
- # clojure-norway (29)
- # clojurescript (18)
- # cursive (2)
- # datomic (6)
- # docker (11)
- # emacs (12)
- # events (1)
- # fulcro (71)
- # graalvm (8)
- # hyperfiddle (2)
- # lsp (23)
- # meander (5)
- # off-topic (36)
- # polylith (4)
- # re-frame (6)
- # reitit (13)
- # shadow-cljs (87)
- # spacemacs (1)
- # tools-deps (19)
- # vim (5)
- # xtdb (57)
The docs give this example of using a composite tuple attribute with :db.unique/identity
to get upsert behavior:
> A given course/semester/student combination is unique in the database. To model this, you can create a composite tuple whose :db/tupleAttrs
are
>
{:db/ident :reg/semester+course+student
> :db/valueType :db.type/tuple
> :db/tupleAttrs [:reg/course :reg/semester :reg/student]
> :db/cardinality :db.cardinality/one
> :db/unique :db.unique/identity}
> With this composite installed, Datomic’s unique identity will ensure that all assertions about a semester/course/student combination resolve to the same entity.
But when I try to transact an entity to get an upsert based on tuple uniqueness, I get a conflict instead of the expected upsert behavior:
:db.error/unique-conflict Unique conflict: :notion-issued-token/user+notion-workspace, value: [334251539360417 "8e3f6da9-296a-403a-9364-6317fa204d1c"] already held by: 338649628381186 asserted for: 338649628381535
Am I misunderstanding how this is supposed to work, or is this a bug?
If it’s relevant, this attribute was previously :db.unique/value
before being changed to :db.unique/identity
.I see two related Datomic forum links but they leave me only more confused. This one says that you must explicitly assert the composite tuple attribute (not just its constituent attributes) to get the upsert behavior: https://forum.datomic.com/t/db-unique-identity-does-not-work-for-tuple-attributes/1072. This one says that you cannot explicitly assert the composite tuple attribute: https://forum.datomic.com/t/troubles-with-upsert-on-composite-tuples/1355. Both are several years old so I don’t know if they are still applicable.
There's this from more recently: https://clojurians.slack.com/archives/C03RZMDSH/p1676433358382929