Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upserts containing tempids in tuples #379

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion test/datascript/test/tuples.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,28 @@
[2 :b "b"]
[2 :a+b ["a" "b"]]
[2 :c "c"]}
(tdc/all-datoms (d/db conn))))))
(tdc/all-datoms (d/db conn)))))

(testing "#378"
(let [conn (d/create-conn {:player {:db/unique :db.unique/identity}
:home {:db/valueType :db.type/ref}
:away {:db/valueType :db.type/ref}
:players {:db/unique :db.unique/identity
:db/tupleAttrs [:home :away]}})]
(d/transact! conn [[:db/add -1 :player "Nadal"]
[:db/add -2 :player "Federer"]
{:home -1
:away -2}])
(d/transact! conn [{:db/id "match"
:players ["p1" "p2"]
:game 3}
{:db/id "p1"
:player "Nadal"}
{:db/id "p2"
:player "Federer"}])

(is (= 3 (:game (d/entity @conn 3)))
"Upsert successful"))))

(deftest test-lookup-refs
(let [conn (d/create-conn {:a+b {:db/tupleAttrs [:a :b]
Expand Down