Skip to content

Commit c536d5a

Browse files
committed
Fix :db.fn/call returning entity without :db/id
1 parent e20436a commit c536d5a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/datascript/db.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@
17661766
(util/cond+
17671767
(= op :db.fn/call)
17681768
(let [[_ f & args] entity]
1769-
(recur report (concat (apply f db args) entities)))
1769+
(recur report (concat (assoc-auto-tempids db (apply f db args)) entities)))
17701770

17711771
(and (keyword? op)
17721772
(not (builtin-fn? op)))

test/datascript/test/transact.cljc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,10 @@
474474
(is (empty? (->> (d/datoms db :eavt)
475475
(map (fn [[_ a v]] [a v]))
476476
(remove #(d/entity db %)))))))
477+
478+
(deftest test-db-fn-returning-entity-without-db-id-issue-474
479+
(let [conn (d/create-conn {})
480+
_ (d/transact! conn [[:db.fn/call (fn [db]
481+
[{:foo "bar"}])]])
482+
db @conn]
483+
(is (= #{[1 :foo "bar"]} (tdc/all-datoms db)))))

0 commit comments

Comments
 (0)