This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-20
Channels
- # admin-announcements (1)
- # announcements (1)
- # beginners (115)
- # calva (31)
- # cider (25)
- # clj-kondo (47)
- # cljdoc (23)
- # cljs-dev (5)
- # clojars (1)
- # clojure (60)
- # clojure-australia (1)
- # clojure-europe (23)
- # clojure-nl (3)
- # clojure-norway (2)
- # clojure-spec (3)
- # clojure-uk (18)
- # clojurescript (49)
- # community-development (1)
- # cursive (4)
- # datahike (2)
- # datascript (3)
- # datomic (36)
- # deps-new (2)
- # emacs (2)
- # events (9)
- # fulcro (6)
- # graphql (2)
- # gratitude (13)
- # holy-lambda (1)
- # introduce-yourself (10)
- # macro (2)
- # malli (5)
- # meander (9)
- # news-and-articles (5)
- # nextjournal (1)
- # off-topic (32)
- # pathom (17)
- # pedestal (13)
- # polylith (4)
- # protojure (4)
- # reagent (4)
- # sci (27)
- # shadow-cljs (2)
- # show-and-tell (2)
- # specter (3)
- # tools-deps (7)
- # xtdb (16)
I think I'm missing something about how :tupleAttrs
work:
(-> (ds/empty-db {:a+b {:db/tupleAttrs [:a :b]
:db/unique :db.unique/identity}})
(ds/with [{:a "A", :b "B"}])
:db-after
(ds/with [{:a "A", :b "B" :x 3}]))
;;ExceptionInfo Cannot add #datascript/Datom [2 :a+b ["A" "B"] 536870914 true] because of unique constraint: (#datascript/Datom [1 :a+b ["A" "B"] 536870913 true])
I want to use the tuple as a lookup ref, but this seems to prevent me from adding more facts to the entity identified by the tuple?
;;; Works with a non-tuple attribute
(-> (ds/empty-db {:a {:db/unique :db.unique/identity}})
(ds/with [{:a 1}])
:db-after
(ds/with [{:a 1 :b "B"}]))
Hmmm looks like this is discussed here: https://forum.datomic.com/t/upsert-behavior-with-composite-tuple-key/1075/3
Also further discussed here: https://clojurians-log.clojureverse.org/datomic/2019-11-26 I guess the answer is to manually add :a+b
when transacting an entity to upsert it