Skip to content
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 internal Comparator methods protected #5652

Merged
merged 1 commit into from
Sep 5, 2022

Conversation

morozov
Copy link
Member

@morozov morozov commented Sep 4, 2022

No description provided.

@morozov morozov added this to the 3.4.4 milestone Sep 4, 2022
Comment on lines -665 to -671
public function testCompareForeignKeyRestrictNoActionAreTheSame(): void
{
$fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']);
$fk2 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'RESTRICT']);

self::assertFalse($this->comparator->diffForeignKey($fk1, $fk2));
}
Copy link
Member Author

@morozov morozov Sep 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test has been reworked into ForeignKeyConstraintTest::testCompareRestrictAndNoActionAreTheSame().

Comment on lines -673 to -679
public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvailable(): void
{
$fk1 = new ForeignKeyConstraint(['foo'], 'foo.bar', ['baz'], 'fk1');
$fk2 = new ForeignKeyConstraint(['foo'], 'baz.bar', ['baz'], 'fk1');

self::assertFalse($this->comparator->diffForeignKey($fk1, $fk2));
}
Copy link
Member Author

@morozov morozov Sep 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is supposed to cover the fix (411d38f) for #1694 (I can't really find much about the actual issue).

This is obviously a hack. From the issue description:

[...] all foreign keys in non standard schema all always different, because table1 doesn't contain a schema name in it but table2 does.

The fact that the schema name of the foreign key is unavailable during schema comparison is a flaw in the API, and doesn't mean that any two foreign with the same name from different schemas are the same key.

The fix doesn't take into account the fact that a quoted name can contain a dot.

While we're keeping the code, I'll remove this test as not worth reworking.

Comment on lines -1035 to -1043
public function testCompareQuotedAndUnquotedForeignKeyColumns(): void
{
$fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']);
$fk2 = new ForeignKeyConstraint(['`foo`'], 'bar', ['`baz`'], 'fk1', ['onDelete' => 'NO ACTION']);

$diff = $this->comparator->diffForeignKey($fk1, $fk2);

self::assertFalse($diff);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assumptions under this test are invalid. Quoted and unquoted names may not be equal depending on the platform. This test cannot be reworked with a functional one.

@morozov morozov marked this pull request as ready for review September 4, 2022 20:29
@morozov morozov requested a review from greg0ire September 4, 2022 20:32
@morozov morozov modified the milestones: 3.4.4, 4.0.0 Sep 4, 2022
@morozov morozov merged commit 075848c into doctrine:4.0.x Sep 5, 2022
@morozov morozov deleted the comparator-internal-protected branch September 5, 2022 13:32
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants