Closed mgonyan closed 8 years ago
@mgonyan fix seems good, but isn't backed by test scenario...
Awesome. Was investigating in that direction but then ran out of time.
Working on it
@Ocramius I've added the two different test scenario that covers:
It seems the fix needs still some adjustments as I am now getting a CircularReferenceException
on the purge. This now happens on a simple relation.
@peterhorne could you please give me more details about or an example what's causing a CircularReferenceException
in order to add it to the test suite
I have a Customer, a ContactPerson and a User entity. The relationship is Customer -> Contactperson -> User. I get the CircularReferenceException
between Customer and User.
@peterrehm thank you for the example, but I am afraid, I could not find a way to reproduce the issue. I added a test with a similar scenario and it is not failing for me. @Ocramius what do you think?
This PR fixes most of my issues, but I also get a CircularReferenceException
for my entities. I have a fix however. I'll open a PR based on this one.
@bendavies could you please tell me how your entities look like and their relationships in order to have a solid test, adjust this PR, thank you
Sure, I won't open a PR then.
you need this:
Single table inheritance: Parent -> Child
Parent ManyToOne Parent Parent ManyToOne Organisation
That should get you the circular exception,
then to fix it, at https://github.com/mgonyan/data-fixtures/blob/63c795a2591e2f54bfaefe6ee8de5f8f85849133/lib/Doctrine/Common/DataFixtures/Purger/ORMPurger.php#L147
if (isset($association['inherited'])) {
continue;
}
which prevents duplicating the Organisation association on both Parent and Child.
Let me know if that works for you.
@mgonyan Can only look at it in detail on monday.
Thank you @peterrehm and @bendavies, i've been able to reproduce the issue adding a simple table inheritance as you pointed out, please have a look at it a tell me what you guys think.
nice one!
PR looks good. has fixed all my issues.
Looks like it does not yet fix my inheritance issue. I am having a Single-Table-Inheritance of BaseUser -> and User. And then the relation is as mentioned above. Customer -> ContactPerson -> User. I am getting CircularReference errors between Customer and User.
@peterhorne Can you make a PR with a failing test ?
@mikeSimonson I have a test that makes the PR failed, However, I am not sure how to solve that issue, EntityA -> EntityB -> EntntyC -> EntityA, I'll push it later
@mgonyan Any updates?
@mgonyan Can you push your test ?
@mikeSimonson @peterrehm sorry for the delay, can you please guys have a look at the changes. I am still not sure about the circular reference issue with single table reference.
@mgonyan The 2 tests that fail now illustrate the BC break right ? testCommitOrder and testPurgeTableCorrectOrder.
@mikeSimonson yes I do, if this is the bug which @peterrehm mentioned before I will try to fixing it asap However cycles are possible due to a bad Entity Relation design or particular business requirement. I think this PR https://github.com/doctrine/data-fixtures/pull/233 could help to give us a clue where it is the cycle and rethink the relation model.
@mgonyan Thanks for your help
thank u too. @mikeSimonson , WDYT @peterrehm ?
this PR fixes https://github.com/doctrine/data-fixtures/issues/230