Problem with Bulk Inserts And Unique Constraint Violations #3839
-
I am having some issues trying to do a bulk insert of my data using the built in for loop as shown here. In my schema I have an exclusivity constraint on one of the properties of my types. If I try to bulk insert any data into my DB, I get a constraint violation error thrown even though i am very clearly not violating the constraints. I am wondering if I am doing something wrong on my insert? Here is my schema:
And here is my insert query:
From an empty database, I insert one account, elonmusk. Then trying to insert tweet data I get the error. Here is what my data looks like (just 2 entries but enough to recreate the error):
I insert them using the python client library like this after connecting where query is the above query and tweets is the json. I have found if I run this query with only 1 entry it works. But 2 or more fails. If i do it with 2 but 1 was already in the DB, then it succeeds. It fails with this error:
Sorry for all of the code snippets, but any help in solving this would be much appreciated. Not sure if this is a bug or just user error on my part? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
As a follow up, removing the unique constraint allows for inserts, but then introduces a different problem. The data is then inserted twice. |
Beta Was this translation helpful? Give feedback.
-
OK, I can reproduce the first issue, which is a bug. I can't reproduce the second issue, except to note that without the constraint, running it multiple times will duplicate the data? Is that what happened? |
Beta Was this translation helpful? Give feedback.
-
Hi, I think I am having exactly the same issue but with EdgeDB 3.1+a33a828 (repl 3.4.0+4d95a2c). I am using the Rust official library and the query looks like this:
The
If I am not badly mistaken, the only relevant difference that I noticed wrt the original issue (apart from the different client library used) is the presence of a second |
Beta Was this translation helpful? Give feedback.
OK, I can reproduce the first issue, which is a bug.
I can't reproduce the second issue, except to note that without the constraint, running it multiple times will duplicate the data? Is that what happened?