Skip to content

Loading…

DDC-1113: getCommitOrder misses some relations when used with Inheritance and self-referencing field #1710

Closed
doctrinebot opened this Issue · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user xanf:

Let's assume we have an Entity class "ParentClass", which uses a single table inheritance with child classes "ChildOne" and "ChildTwo".
"ParentClass" also have one-to-one unidirectional association with "FooBar" class named "foobar", and a self-referencing association called "parent"

We construct entity of "ChildOne" type, filling "foobar" link with new FooBar object. The same action is made for entity of "ChildTwo" type.
Entity of "ChildOne" type is persisted and flushed.

At this point getCommitOrder builds a commit order. ChildOne <---> FooBar link appears in dependency graph because of "foobar" association.
While processing assocs it reveals "parent" assoc in parent class and builds following links in dependency graph:
ChildOne <---> ChildOne
ChildOne <---> ChildTwo

After that "ChildTwo" entity is persisted and flushed. At this point commit calculator thinks it already have "ChildTwo" in it's storage so no assoc calculation are made for "childTwo" class

If we attemp to delete "ChildTwo" class flush() will fail because of missing link "ChildTwo <-----> Foobar" assoc

@doctrinebot

Comment created by xanf:

I've opened pull request #47 with my fix to this issue. I'm new to doctrine development so feel free to make any suggestions how to improve it

@doctrinebot

Comment created by @beberlei:

Increased priority, i should really look at this one soon!

@doctrinebot

Comment created by @beberlei:

The test with this pull request does not fail even without the applied patch.

@doctrinebot

Comment created by @beberlei:

sorry my bad, ran this with SQLite (Which has no FKs)

@doctrinebot

Comment created by @beberlei:

Fixed, simplifed a bit since one part was not necessary and this hits performance quite significantly

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.1.2 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.