clojuredatomic

Datomic: `:db.error/tempid-not-an-entity` tempid used only as value in transaction


When I try to transact this entity using a string tempid against datomic-free v0.9.5656, I get the following exception:

(def tx1 {:db/id             "user"
          :contact/full-name "John Wayne"})
(def tx2 {:db/id    "other"
          :some-ref "user"
(let [!rx (d/transact conn [tx2])]
   (prn (:tempids @!rx))
=> 

datomic.impl.Exceptions$IllegalArgumentExceptionInfo: :db.error/tempid-not-an-entity tempid used only as value in transaction
    data: {#object[clojure.lang.Keyword 0x74af59e7 ":db/error"] #object[clojure.lang.Keyword 0x57972b49 ":db.error/tempid-not-an-entity"]}
             java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: :db.error/tempid-not-an-entity tempid used only as value in transaction

The documentation shows I should be able to use strings as tempids. Am I missing a reader macro to tell it about a partition?


Solution

  • Either, "tempid" is not resolved in the transaction, e.g.

    [{:db/id    "new-id"
      :some/ref "missing-tempid"}]
    

    Or the entity map for that ref has no attributes other than :db/id, e.g.

    {:db/id "tempid"}
    

    Typically because they were filtered out.

    I wish the error was clearer, e.g. "You refer to tempid 'user', but the only tempids in this tx are: #{"other"}" And then I'd spot the error immediately.