Skip to content

Non-nullabe result of comparing tables #5770

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

Merged
merged 2 commits into from
Oct 18, 2022

Conversation

morozov
Copy link
Member

@morozov morozov commented Oct 17, 2022

Q A
Type improvement

Null references are often referred to as "The Billion Dollar Mistake". They require checking the type of the variable at runtime before passing it down the line or, otherwise, its usage may result in a type error.

The number of the assertions like the following in our test suite illustrates that well enough:

git grep 'assertNotFalse' -- tests | grep -i diff -c
49

The need for such assertions could be eliminated if table comparison always resulted in a non-null (currently, non-false) value (this is already the case for Comparator::compareSchemas()).

An empty diff can be safely passed down the line and will result in a no-op (see the newly added tests). If the business logic requires checking whether the diff is empty, the newly introduced isEmpty() methods could be used for that.

@morozov morozov added this to the 3.5.0 milestone Oct 17, 2022
@morozov morozov changed the title Improve Comparator API Non-nullabe result of comparing tables Oct 17, 2022
@morozov morozov force-pushed the deprecate-comparator-diff-table branch from a8d12d7 to acc2c8a Compare October 17, 2022 23:33
@morozov morozov marked this pull request as ready for review October 18, 2022 01:05
@morozov morozov requested review from greg0ire and derrabus October 18, 2022 01:05
@morozov morozov merged commit 45a2bb4 into doctrine:3.5.x Oct 18, 2022
@morozov morozov deleted the deprecate-comparator-diff-table branch October 18, 2022 14:01
@sbuerk
Copy link
Contributor

sbuerk commented Oct 23, 2022

@morozov @derrabus

The isEmpty() of TableDiff, used in SchemaDiff constructor are now filtering out just renamed tables in the table diff from the changed changed "tables" - saying renamed tables are not changes.

I got it, that this should be deprecated and so on, but however this is now a change in behaviour, and thus "breaking". This has not been communicated that way.

Before this change, renamed table stayed as changed table in the SchemaDiff. Personally I think, renamed tables are changes regarding a "SchemaDiff" - or was this not intended ?

Breakes our application and popped up in nightlies automatically checkonf for new ^3.x releases of doctrine/dbal. Breaking out database compare and migrate logic.

reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this pull request Oct 23, 2022
With doctrine/dbal v3.5.0 some changes has been introduced which
shows invalid test setup. This change use proper test setup to be
okay again, if doctrine/dbal v3.5.0 is used.

See: doctrine/dbal#5770

Used command(s):

> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #98704
Releases: main
Change-Id: I936e5cd291086020e60be418176b0f294fb43a45
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76231
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Andreas Fernandez <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Andreas Fernandez <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this pull request Oct 23, 2022
With doctrine/dbal v3.5.0 some changes has been introduced which
shows invalid test setup. This change use proper test setup to be
okay again, if doctrine/dbal v3.5.0 is used.

See: doctrine/dbal#5770

Used command(s):

> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #98704
Releases: main
Change-Id: I936e5cd291086020e60be418176b0f294fb43a45
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76231
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Andreas Fernandez <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Andreas Fernandez <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
@morozov
Copy link
Member Author

morozov commented Oct 23, 2022

@sbuerk please file a new issue and provide the steps to reproduce it via a small snippet of code.

reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this pull request Oct 24, 2022
doctrine/dbal is working on deprecating and changing code and
behaviour in 3.x as preparation for removal in 4.x. Starting
with doctrine/dbal v3.5.0, the table rename detection in the
TYPO3 database compare no longer works as expected. TableDiff
got an `isEmpty()` check, which is used in SchemaDiff and thus
filtering out "renamed" tables without further changes, leading
to a change of behavior. doctrine/dbal favors renaming table
no longer by setting a new name in the TableDiff, thus not having
the changed name in the `isEmpty()` check.

See: doctrine/dbal#5770

doctrine/dbal deprecations and changes require systematical
adoption to cover all the changes. This takes time and proper
testing, which is out of the scope for this change.

This change overrides the `TableDiff->isEmpty()` method in the
corresponding core fascade class, adding checks for $newName
and $tableOptions checks as a intermediate workaround. Thus
keep compatibillity between doctrine/dbal <3.5 and 3.5 for now.

Resolves: #98707
Releases: main
Change-Id: If305e4d809be29585e0b6a72c3215f5cff68762d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76232
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Benni Mack <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Benni Mack <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this pull request Oct 24, 2022
doctrine/dbal is working on deprecating and changing code and
behaviour in 3.x as preparation for removal in 4.x. Starting
with doctrine/dbal v3.5.0, the table rename detection in the
TYPO3 database compare no longer works as expected. TableDiff
got an `isEmpty()` check, which is used in SchemaDiff and thus
filtering out "renamed" tables without further changes, leading
to a change of behavior. doctrine/dbal favors renaming table
no longer by setting a new name in the TableDiff, thus not having
the changed name in the `isEmpty()` check.

See: doctrine/dbal#5770

doctrine/dbal deprecations and changes require systematical
adoption to cover all the changes. This takes time and proper
testing, which is out of the scope for this change.

This change overrides the `TableDiff->isEmpty()` method in the
corresponding core fascade class, adding checks for $newName
and $tableOptions checks as a intermediate workaround. Thus
keep compatibillity between doctrine/dbal <3.5 and 3.5 for now.

Resolves: #98707
Releases: main
Change-Id: If305e4d809be29585e0b6a72c3215f5cff68762d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76232
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Benni Mack <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Benni Mack <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 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.

4 participants