Fork me on GitHub
#datascript
<
2021-08-20
>
jjttjj19:08:58

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"}]))

jjttjj19:08:23

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