Populate foreign key constraint options only with non-default values#6964
Merged
morozov merged 2 commits intodoctrine:4.3.xfrom May 20, 2025
Merged
Conversation
This change indicates the issue being tracked in XYZ. It is extracted into a separate commit to demonstrate the issue and the fact that this is a test-only change.
13501ad to
95039c4
Compare
Member
Author
|
Yes. If 95039c4 is reverted, the reworked test will fail as follows: |
This file contains hidden or 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
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.
The current implementation if
ForeignKeyConstraintEditor::create()populates thematch,onUpdateandonDeleteoptions of the foreign key constraints even if they weren't explicitly set and thus are equal to their default values.This is correct – the default options match to the corresponding defaults in SQL. The "problem" is that if a table is constructed via the editor, its
CREATE TABLESQL will explicitly contain the default clauses likeON UPDATE NO ACTION. Functionally, this is still not a problem, I just want to keep the behavior of the editor such that switching the implementation of the table construction doesn't change the generated SQL.The second problem is auto-generated index names for quoted columns. This issue is tracked in #6733 – the resulting auto-generated name depends on the quote character used to declare a quoted name. Since
TableEditorinternally usesIdentifier::toString()which in turn uses double quotes, switching fromnew Table()with backticks toTableEditorwould result in different auto-generated name. This is inevitable. I've extracted this into a separate commit to demonstrate that this is an existing issue, and the change is test-only.