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

Declare internal properties of TableDiff as private #5753

Merged

Conversation

morozov
Copy link
Member

@morozov morozov commented Oct 12, 2022

Change summary:

  1. TableDiff constructor parameters reordered by asset type: columns, indexes, foreign keys.
  2. The return types of all methods except for getRenamed*() have been relaxed from list<T> to array<T>. The former implies that the elements of the list can be accessed by index and their order matters while this is not intended (those are just sets).
  3. Instead of being reworked, some of the tests have been removed as they cover very basic use cases which are most likely still covered by integration tests.

@morozov morozov added this to the 4.0.0 milestone Oct 12, 2022
@morozov morozov requested review from greg0ire and derrabus October 12, 2022 04:55
@@ -309,17 +307,17 @@ public function diffTable(Table $fromTable, Table $toTable): ?TableDiff

return new TableDiff(
$fromTable,
$addedColumns,
array_values($addedColumns),
Copy link
Member

@greg0ire greg0ire Oct 12, 2022

Choose a reason for hiding this comment

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

Why is this call to array_values needed now that this type has been relaxed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I still didn't want the keys of the associative arrays to leak into the diff, and some tests relied on the numeric keys for assertions. But this can be fixed.

* @param array<Index> $modifiedIndexes
* @param array<Index> $droppedIndexes
* @param array<string, Index> $renamedIndexes
* @param array<ForeignKeyConstraint> $addedForeignKeys
Copy link
Member

Choose a reason for hiding this comment

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

I wish there was a way to express that this is a set explicitely (list is great at that but does have an extra constraint we don't need). Now it looks like we forgot to document the keys.

Copy link
Member Author

Choose a reason for hiding this comment

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

We will likely introduce a dedicated data structure for these collections to address #4772. Currently, table constraints and indexes are indexed by the lower-case name but this doesn't work for case-sensitive platforms.

@morozov morozov force-pushed the table-diff-internal-properties-private branch from a433d60 to 26ece99 Compare October 12, 2022 13:42
@morozov morozov marked this pull request as ready for review October 12, 2022 13:42
@morozov morozov merged commit d2c74da into doctrine:4.0.x Oct 12, 2022
@morozov morozov deleted the table-diff-internal-properties-private branch October 12, 2022 18:55
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 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