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

Deprecate Table methods #5731

Merged
merged 1 commit into from
Oct 8, 2022
Merged

Conversation

morozov
Copy link
Member

@morozov morozov commented Oct 8, 2022

Q A
Type deprecation
  1. Table::getForeignKeyColumns() was removed from 4.0.x around 36522aa without having been deprecated first.

  2. The logic of Table::getPrimaryKeyColumns() is non-obvious and not documented. If the primary key declares a column but it doesn't exist in the table, the column will be silently skipped. This may lead to a situation where a table has the primary key with no columns, which is not valid.

    This behavior is relied upon by AbstractMySQLPlatform::getPreAlterTableAlterIndexForeignKeySQL() and may make sense but then it should be implemented there.

    Additionally, using this method requires checking whether the primary key exists first which makes it not as convenient as it may look.

  3. The implementation of Table::hasPrimaryKey() is almost identical toTable::getPrimaryKey(). Normally, the consumer of the Table API will need not only to know whether the primary key exists but get its columns, so they will end up calling Table::getPrimaryKey() anyways.

    From the static analysis point of view, a call to getPrimaryKey() will return a nullable value even if a prior call to hasPrimaryKey() returned true. Making them work together would require additional annotations. See Enable PHPStan strict rules #3932 and Bump Psalm level to 3 #4348 for example.

@morozov morozov marked this pull request as ready for review October 8, 2022 15:22
@morozov morozov requested a review from greg0ire October 8, 2022 15:22
@morozov morozov force-pushed the deprecate-table-methods branch from a67384f to 50415ff Compare October 8, 2022 15:31
@morozov morozov merged commit 00f2f7a into doctrine:3.5.x Oct 8, 2022
@morozov morozov deleted the deprecate-table-methods branch October 8, 2022 16:45
@morozov morozov mentioned this pull request Oct 9, 2022
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Oct 9, 2022
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Oct 10, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 9, 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