Skip to content

Comments

Deprecate using keys of table-scoped object collections as names#7102

Merged
morozov merged 1 commit intodoctrine:4.4.xfrom
morozov:deprecate-index-array-keys
Aug 26, 2025
Merged

Deprecate using keys of table-scoped object collections as names#7102
morozov merged 1 commit intodoctrine:4.4.xfrom
morozov:deprecate-index-array-keys

Conversation

@morozov
Copy link
Member

@morozov morozov commented Aug 24, 2025

The array returned by Table::getColumns() doesn't contain column names as keys since #3583 (4.0.0). This PR deprecates using keys as names in other collections.

Keys as lower-case names is the source of various issues:

  1. Potential collisions (elements are keyed by lower-case name not taking if the name is quoted into account):
    1. The returned array cannot contain two elements if their names are equal but in a different case.
    2. It cannot contain two elements if their names are equal, but one is quoted while the other is not.
  2. For unnamed constraints, the DBAL will auto-generate the key but not the name, so when the object hits the database, a different name will be generated. Essentially, in this case the auto-generated name is not used anywhere and doesn't match anything.
  3. This is just redundant. Right now there is probably a bug that when a table column is renamed, it's put to the end of column list. Solving this bug while preserving its key in the array of columns would require rebuilding the array.

Besides the deprecation, this PR reworks that code that would use the keys as names such that the keys are used only as pointers to elements in the collection, but without any specific meaning.

@morozov morozov merged commit 8220641 into doctrine:4.4.x Aug 26, 2025
90 checks passed
@morozov morozov deleted the deprecate-index-array-keys branch August 26, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants