(require '[datalevin.core :as d]
'[babashka.fs :as fs])
(fs/with-temp-dir [db-path]
(try
(let [schema {:person/id {:db/valueType :db.type/string
:db/unique :db.unique/identity}
:passport/person {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one
_:db/unique :db.unique/identity}}
conn (d/get-conn (str db-path "/db") schema)]
;; create a person
(d/transact! conn [{:person/id "person-123"}])
;; use lookup ref to transact a passport
;; this is what fails with: ClassCastException - class clojure.lang.PersistentVector cannot be cast to class java.lang.Number
(d/transact! conn [{:passport/person [:person/id "person-123"]}])
(d/close conn)
(println "SUCCESS: Transaction completed without error."))
(catch Exception e
(println (str "FAILURE: " (.getSimpleName (class e)) " - " (.getMessage e)))
(System/exit 1))))
This worked in 0.9.11, 0.9.12, but broke in 0.9.13. If i turn on :validate-data? I get the error Invalid data, expecting:db.type/ref got [:person/id "person-123"] What's wrong with having :db.unique/identity and :db.type/ref on the same attribute?Can you file an GitHub issue?
thx