doctrine / data-fixtures

Doctrine2 ORM Data Fixtures Extensions
http://www.doctrine-project.org
MIT License
2.78k stars 224 forks source link

Fix the sorting of metadata to be purged #239

Closed stof closed 8 years ago

stof commented 8 years ago

The node for a class could have been added in the TopologicalSorter before the class is processed itself, in case it is the target of an association in a previous class. In this case, the node should not be overwritten, as this would make it forget all previous dependencies.

stof commented 8 years ago

So to be clear, the only case working properly currently when association are involved is when each class is processed before its dependencies, i.e. the input array is already sorted. An unsorted input would produce a broken output (which is quite unfortunate for a sorter)

Ocramius commented 8 years ago

@stof can you write a test for it too?

stof commented 8 years ago

Well, I don't understand how the ORMPurger is tested currently. It seems to be mocking the EM, but this bug will appear because of DB foreign keys.

Ocramius commented 8 years ago

Ah, indeed, confused this with the sorter itself. You are just using the sorter here. Wondering if this rule should be encapsulated in addNode()?

stof commented 8 years ago

yeah, the adder should probably check for it. Do you prefer for it to throw an exception if called a second time, or to silently keep the existing vertex ?

Ocramius commented 8 years ago

Would probably keep the vertex, if it's the same...

mgonyan commented 8 years ago

@stof, @Ocramius please have a look at https://github.com/doctrine/data-fixtures/pull/231

j4k4 commented 8 years ago

Is there any news on this? Would love to have this merged..

stof commented 8 years ago

Closing as #240 was merged and it also included this fix