orm icon indicating copy to clipboard operation
orm copied to clipboard

Skip joined entity creation for empty relation (#10889)

Open noemi-salaun opened this issue 6 months ago • 9 comments

(The following is translated from french with Google Translate, I'm sorry :/ )

In case the root entity has its primary key as a relationship and the joined entity has a simple primary key, the RSM orders the ID of the joined entity before having the ID which defined the root entity.

The ObjectHydrator therefore first tries to hydrate the joined entity. We then fall into a special case where the parent (the root entity) has not yet been created and the hydrator tries to start by creating the child, except that in our case, the child is supposed to be null.

I therefore added the isset($nonemptyComponents[$dqlAlias]) check which we find further in the code and which is made to skip the creation of the joined entity when the parent is already hydrated. I think it makes sense to do the same check in the case where the hydrator starts with the joined entity.

noemi-salaun avatar Jan 28 '24 17:01 noemi-salaun