Jira issue originally created by user drauschenbach:
Steps to reproduce:
Expected result:
A DELETE followed by an INSERT
Actual result:
An INSERT with a new assigned primary key, but a failure on some other unique index
Comment created by romanb:
This is not a bug. See DDC-601.
Issue was closed with resolution "Won't Fix"
Should it even possible to "solve" a bug with "Won't Fix"?
N.B.: DDC-601 is now here: https://github.com/doctrine/doctrine2/issues/5109
@ureimers that's the wording from the JIRA import that we did last year.
I see. So it's no bug at all?
Intended behavior: lemme re-label.
It's just that this issue seems like a Hydra: You close one and two new pop up. So not fixing it doesn't seem to be the right solution.
Or let me rephrase that: There should at least be a workaround like the often mentioned setShouldPerformDeletesFirst or something similar.
Btw.: Did I just see the labels change while being on the page? Phew... technology today...
@ureimers if you did find new issues related to this one, please link them and I'll close them too, and create a cross-reference, so that people know what's going on. That's "issue trackers 101" btw...
And that's rude btw...
It was already referenced by MacDada on 26 Mar. And I also updated the broken DDC-601 link from the doctrinebot above to point to #5109 which is where another discussion regarding this topic started. Interestingly #5109 (aka DDC-601) was flagged "Improvement" instead of "Won't fix" or "Can't fix" which I think is the right thing.
And that's rude btw...
Really didn't mean to be rude, sorry!
I'm changing statuses there - most probably was already labeled incorrectly before importing from Jira.
Really didn't mean to be rude, sorry!
No problem. The meaning of a text message can be way more misleading than actually hearing someone saying it.
And thanks for all the re-labeling.
I'm getting error in Symfony 3.3
I'm simply trying to call $this->om->remove($entry); and getting an SQL error for INSERT despite the fact that I'm not trying to insert anything, just remove.
It looks like it's trying to set a field to null and then failing on an integrity constraint. The field in question is not null when the entity entry is loaded using find, but when remove is called somehow that field in question is set to null.
EDIT:
Ended up doing this as a workaround
$queryBuilder = $this->repository->getQueryBuilder();
$queryBuilder
->delete()
->where('qb.id = :id')
->setParameter('id', $id)
->getQuery()
->getResult();
I had the same issue. I solved the problem by calling flush() later.
In my case there were entries that depend on each other. So if I deleted a depending entry doctrine wants to update the other entry which has a "foreign key not null" constraint (which of course fails).
So if I first detached both depending entries and then flush afterwards everything was fine:
$em->remove($child);
$em->remove($parent);
$em->flush();
Most helpful comment
I had the same issue. I solved the problem by calling
flush()later.In my case there were entries that depend on each other. So if I deleted a depending entry doctrine wants to update the other entry which has a "foreign key not null" constraint (which of course fails).
So if I first detached both depending entries and then flush afterwards everything was fine: