Skip to content

Commit

Permalink
Fix :db.fn/call returning entity without :db/id
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGuteMoritz committed Jun 20, 2024
1 parent e20436a commit c536d5a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/datascript/db.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@
(util/cond+
(= op :db.fn/call)
(let [[_ f & args] entity]
(recur report (concat (apply f db args) entities)))
(recur report (concat (assoc-auto-tempids db (apply f db args)) entities)))

(and (keyword? op)
(not (builtin-fn? op)))
Expand Down
7 changes: 7 additions & 0 deletions test/datascript/test/transact.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,10 @@
(is (empty? (->> (d/datoms db :eavt)
(map (fn [[_ a v]] [a v]))
(remove #(d/entity db %)))))))

(deftest test-db-fn-returning-entity-without-db-id-issue-474
(let [conn (d/create-conn {})
_ (d/transact! conn [[:db.fn/call (fn [db]
[{:foo "bar"}])]])
db @conn]
(is (= #{[1 :foo "bar"]} (tdc/all-datoms db)))))

0 comments on commit c536d5a

Please sign in to comment.