【问题标题】:Datomic: `:db.error/tempid-not-an-entity` tempid used only as value in transactionDatomic:`:db.error/tempid-not-an-entity` tempid 仅用作交易中的值
【发布时间】:2018-03-14 13:08:00
【问题描述】:

当我尝试使用字符串 tempid 针对无 datomic v0.9.5656 处理此实体时,我收到以下异常:

(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

文档显示我应该能够将字符串用作临时对象。我是否缺少一个阅读器宏来告诉它有关分区的信息?

【问题讨论】:

    标签: clojure datomic


    【解决方案1】:

    原来我指的是一个实体的tempid,而我并未包含在交易中。

    我希望错误更清楚,例如“您指的是 tempid 'user',但此 tx 中唯一的 tempid 是:#{“other”}” 然后我会立即发现错误。

    【讨论】:

    • 2018 年 12 月 22 日:又被这件事搞砸了。
    【解决方案2】:

    获取此错误消息的另一种方法是将属性设置为空向量。大概[] 被解释为临时文件,并且在事务中找不到对应的:db/id []。 空映射 {} 的类似推理 - 事务中的 tempid 值 {} 在哪里?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-21
      • 1970-01-01
      相关资源
      最近更新 更多