-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
Upsert of datom with composite tuple containing lookup ref fails #450
Comments
Looks to me like it should work, yes |
Awesome. I haven't poked my head into DataScript's internals before, but I'll do a bit of digging and see if I can figure out what's going on. |
Finally got around to looking into this. I believe what is happening is that My guess is that you may want to move the Does that seem right? |
After a night's rest, I came up with a different approach. Rather than using tempids as a method of resolving existing entities, leverage lookup refs. This is more idiomatic. (deftest upsert'
(let [conn (d/create-conn {:x-ref {:db/unique :db.unique/identity}
:a {:db/valueType :db.type/ref
:db/unique :db.unique/identity}
:a+b {:db/valueType :db.type/tuple
:db/tupleAttrs [:a :b]
:db/unique :db.unique/identity}})]
(d/transact!
conn
[{:x-ref 1}
{:a [:x-ref 1]
:b 2}])
(is (= #{[1 :x-ref 1]
[2 :a 1]
[2 :b 2]
[2 :a+b [1 2]]}
(tdc/all-datoms (d/db conn))))
(d/transact!
conn
[{:a [:x-ref 1]
:b 2
:foo :bar}])
(is (= #{[1 :x-ref 1]
[2 :a 1]
[2 :a+b [1 2]]
[2 :b 2]
[2 :foo :bar]}
(tdc/all-datoms (d/db conn)))))) |
Oh! I didn’t even noticed that :a was a ref. Yeah lookup refs are probably better here |
I believe this is related to #378, to possibly not the exact same issue.
In the following example, I would expect the second transaction to resolve the second entity to an existing datom via the
:a+b
tuple (resulting in an upsert, though really a noop in this case.)However, it fails with the following exception:
Are my expectations wrong here?
The text was updated successfully, but these errors were encountered: