功能相同,结果不同

时间:2013-02-19 06:28:56

标签: clojure datomic

我有一个Clojure ns,它定义了一个内存数据库:1个分区,1个属性和2个实体。我从Eclipse(逆时针)运行它,结果(异常)如下:

;; Clojure 1.4.0
;; Switching to ww.billing namespace
#'ww.billing/cardinality
#<Namespace ww.billing>
=> (setup-db)
#<HashSet [[:billing]]>
#<HashSet [[:db/code], [:customer/taxid], [:fressian/tag], [:db/unique], [:db/fn],
[:customer/role], [:db/noHistory], [:db/fulltext], [:db/lang], [:db/valueType], 
[:db/doc], [:db/isComponent], [:db.install/function], [:db/cardinality], 
[:db/txInstant], [:db/index], [:customer/taxname]]>
#<HashSet [["BBB010101BB1"], ["AAA010101AAA"]]>
#<HashSet [[272678883689455], [272678883689454]]>
nil
=> (cardinality mdb :customer/taxid)
IllegalArgumentException Cannot resolve key: :customer/taxid  
datomic.datalog/resolve-id (    datalog.clj:144)

然而,从LightTable,相同的代码,当然,结果是不同的(正确):

(ns ww.billing) => nil
(setup-db) => nil
(cardinality mdb :customer/taxid) => :db.cardinality/one

Output: 
#<HashSet [[:billing]]>
#<HashSet [[:db/code], [:customer/taxid], [:fressian/tag], [:db/unique], [:db/fn],
[:customer/role], [:db/noHistory], [:db/fulltext], [:db/lang], [:db/valueType],
[:db/doc], [:db/isComponent], [:db.install/function], [:db/cardinality],
[:db/txInstant], [:db/index], [:customer/taxname]]>
#<HashSet [["BBB010101BB1"], ["AAA010101AAA"]]>
#<HashSet [[272678883689455], [272678883689454]]>

根据环境,可能导致不同结果的原因是什么?注意:IntelliJ的行为与Eclipse类似。基数函数取自西雅图演示。

1 个答案:

答案 0 :(得分:1)

谷歌小组已经完全回答了这个问题:https://groups.google.com/d/msg/datomic/CwCJXLeUsPQ/Y-mNvFF5lksJ