[Tree] Add support of Symfony UIDs types on Nested strategy #2869
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following the Symfony and Doctrine documentation about uids, to use them onto a nested tree entity, I fall into an edge case.
During the execution of the
updateNode
method into Nested strategy, the $newNode variable ends up to be the entity instance, instead of the primary key value (string or int).Whilst the Nested strategy does not specify data types for parameters in queries, leading to incorrect serialization toward database.
I'm still experimenting the optimal code to solve this issue, which look like more a feature in the end, because it seems that this behavior has never been anticipated.
Consequences:
The function
updateNode
couldn't execute properly the SQL "update" request, as objects where serialized using toString() method (returning the UUID at string format), instead of usingtoRfc4122
ortoBinary
.Leading to a different identifier value into the database transaction.
The behavior is vicious because it just silently fail, changing position from null to 0 to every new nodes, and was not obvious to catch.
Solution:
Add everywhere needed, the correct parameter type, letting the DBAL doing it's job.
Tests:
binary(16)
Tests added aims to not overlap with existing ones, testing only the
binary(16)
behavior