-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to have non-NULLable self-referencing associations when using application-provided IDs #10735
Merged
derrabus
merged 1 commit into
doctrine:2.16.x
from
mpdude:nullable-self-reference-application-provided-id
Jul 8, 2023
Merged
Make it possible to have non-NULLable self-referencing associations when using application-provided IDs #10735
derrabus
merged 1 commit into
doctrine:2.16.x
from
mpdude:nullable-self-reference-application-provided-id
Jul 8, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mpdude
force-pushed
the
nullable-self-reference-application-provided-id
branch
from
June 1, 2023 06:42
96ce115
to
b0d8fec
Compare
Closed
mpdude
force-pushed
the
nullable-self-reference-application-provided-id
branch
2 times, most recently
from
June 2, 2023 06:40
7870752
to
592fe57
Compare
We need to process the post-insert IDs earlier: Not after executeInserts() has been finished, but rather during the execution. → #10743 |
mpdude
force-pushed
the
nullable-self-reference-application-provided-id
branch
2 times, most recently
from
June 2, 2023 09:29
dc62bb6
to
520a6f4
Compare
mpdude
force-pushed
the
nullable-self-reference-application-provided-id
branch
from
June 2, 2023 12:28
520a6f4
to
82a2ed6
Compare
mpdude
added a commit
to mpdude/doctrine2
that referenced
this pull request
Jun 21, 2023
This refactoring does two things: * We can avoid collecting the post insert IDs in a cumbersome array structure that will be returned by the EntityPersisters and processed by the UoW right after. Instead, use a more expressive API: Make the EntityPersisters tell the UoW about the IDs immediately. * IDs will be available in inserted entities a tad sooner. That may help to resolve doctrine#10735, where we can use the IDs to skip extra updates.
mpdude
added a commit
to mpdude/doctrine2
that referenced
this pull request
Jun 21, 2023
This refactoring does two things: * We can avoid collecting the post insert IDs in a cumbersome array structure that will be returned by the EntityPersisters and processed by the UoW right after. Instead, use a more expressive API: Make the EntityPersisters tell the UoW about the IDs immediately. * IDs will be available in inserted entities a tad sooner. That may help to resolve doctrine#10735, where we can use the IDs to skip extra updates.
mpdude
added a commit
to mpdude/doctrine2
that referenced
this pull request
Jun 21, 2023
This refactoring does two things: * We can avoid collecting the post insert IDs in a cumbersome array structure that will be returned by the EntityPersisters and processed by the UoW right after. Instead, use a more expressive API: Make the EntityPersisters tell the UoW about the IDs immediately. * IDs will be available in inserted entities a tad sooner. That may help to resolve doctrine#10735, where we can use the IDs to skip extra updates.
mpdude
added a commit
to mpdude/doctrine2
that referenced
this pull request
Jun 21, 2023
This refactoring does two things: * We can avoid collecting the post insert IDs in a cumbersome array structure that will be returned by the EntityPersisters and processed by the UoW right after. Instead, use a more expressive API: Make the EntityPersisters tell the UoW about the IDs immediately. * IDs will be available in inserted entities a tad sooner. That may help to resolve doctrine#10735, where we can use the IDs to skip extra updates.
mpdude
added a commit
to mpdude/doctrine2
that referenced
this pull request
Jun 21, 2023
This refactoring does two things: * We can avoid collecting the post insert IDs in a cumbersome array structure that will be returned by the EntityPersisters and processed by the UoW right after. Instead, use a more expressive API: Make the EntityPersisters tell the UoW about the IDs immediately. * IDs will be available in inserted entities a tad sooner. That may help to resolve doctrine#10735, where we can use the IDs to skip extra updates.
mpdude
added a commit
to mpdude/doctrine2
that referenced
this pull request
Jun 23, 2023
This refactoring does two things: * We can avoid collecting the post insert IDs in a cumbersome array structure that will be returned by the EntityPersisters and processed by the UoW right after. Instead, use a more expressive API: Make the EntityPersisters tell the UoW about the IDs immediately. * IDs will be available in inserted entities a tad sooner. That may help to resolve doctrine#10735, where we can use the IDs to skip extra updates.
…hen using application-provided IDs This change improves scheduling of extra updates in the `BasicEntityPersister`. Extra updates can be avoided when * the referred-to entity has already been inserted during the current insert batch/transaction * we have a self-referencing entity with application-provided ID values (the `NONE` generator strategy). As a corollary, with this change applications that provide their own IDs can define self-referencing associations as not NULLable. I am considering this a bugfix since the ORM previously executed additional queries that were not strictly necessary, and that required users to work with NULLable columns where conceptually a non-NULLable column would be valid and more expressive. One caveat, though: In the absence of entity-level commit ordering (doctrine#10547), it is not guaranteed that entities with self-references (at the class level) will be inserted in a suitable order. The order depends on the sequence in which the entities were added with `persist()`. Fixes doctrine#7877, closes doctrine#7882. Co-authored-by: Sylvain Fabre <[email protected]>
mpdude
force-pushed
the
nullable-self-reference-application-provided-id
branch
from
July 7, 2023 11:41
82a2ed6
to
de85359
Compare
derrabus
approved these changes
Jul 8, 2023
Thanks a lot @mpdude 💪 |
mpdude
added a commit
to mpdude/doctrine2
that referenced
this pull request
Aug 1, 2023
…cation-provided IDs This excludes such associations from the commit order computation, since the foreign key constraint will be satisfied when inserting the row. See doctrine#10735 for more details about this edge case.
21 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This change improves scheduling of extra updates in the
BasicEntityPersister
.Extra updates can be avoided when
NONE
generator strategy).As a corollary, with this change applications that provide their own IDs can define self-referencing associations as not NULLable.
One caveat, though: In the absence of entity-level commit ordering (#10547), it is not guaranteed that entities with self-references (at the class level) will be inserted in a suitable order. The order depends on the sequence in which the entities were added with
persist()
.Fixes #7877, closes #7882.
Co-authored-by: Sylvain Fabre [email protected]