-
-
Notifications
You must be signed in to change notification settings - Fork 309
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
Upserting with unique tuple refs fails #378
Comments
Closing this, Datomic doesn't exhibit the behaviour I was expecting either. |
Even if Datomic doesn’t support this, it seems like a reasonable thing to do? Let’s keep it open |
EDIT: I noticed that this is specific to refs. I've been playing with this issue for a while and got my wires crossed on this issue. Do you think I should open a separate issue about this? I don't have access to Datomic so I can't test over there. I don't know if this is the same issue but I'm getting a different error message when trying to upsert with a unique composite tuple: ;;
;; Upsert by Unique Composite Tuple
;;
(let [schema {:one+two {:db/tupleAttrs [:one :two]
:db/unique :db.unique/identity}}
conn (ds/create-conn schema)]
(ds/transact! conn [{:db/id "tmpid"
:some-field "first upsert"
:one "one"
:two "two"}
{:db/id "tmpid"
:other-field "first upsert"
:one "one"
:two "two"}])
(ds/transact! conn [{:db/id "tmpid"
:some-field "second upsert"
:one "one"
:two "two"}
{:db/id "tmpid"
:other-field "second upsert"
:one "one"
:two "two"}])
(ds/q '[:find [(pull ?e [*]) ...]
:where
[?e :one _]]
@conn)) I get this error:
Of course, when I try the same type of upsert with a non-tuple unique attribute everything works ;;
;; Upsert by non-tuple unique attribute
;;
(let [schema {:email {:db/unique :db.unique/identity}}
conn (ds/create-conn schema)]
(ds/transact! conn [{:db/id "tmpid"
:some-field "first upsert"
:email "[email protected]"}
{:db/id "tmpid"
:other-field "first upsert"
:email "[email protected]"}])
(ds/transact! conn [{:db/id "tmpid"
:some-field "second upsert"
:email "[email protected]"}
{:db/id "tmpid"
:other-field "second upsert"
:email "[email protected]"}])
(ds/q '[:find [(pull ?e [*]) ...]
:where
[?e :email _]]
@conn)) Result: [{:db/id 1,
:email "[email protected]",
:other-field "second upsert",
:some-field "second upsert"}] |
Attempting an upsert to an entity using its unique tuple attribute does not work as expected.
Hope this example is clear:
Expecting a result like
(= 3 (:game (d/entity @conn 3)))
I don't think this is related to #364?
Thanks. I'll try to open a PR for this if it's straightforward enough.
Edit: for what it's worth, here's the same example on Datomic 1.0.6202
The text was updated successfully, but these errors were encountered: