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 empty index name #6671

Merged
merged 2 commits into from
Dec 26, 2024
Merged

Conversation

morozov
Copy link
Member

@morozov morozov commented Dec 26, 2024

Q A
Type deprecation

Of all supported platforms, only PostgreSQL allows to omit the name in the CREATE INDEX statement (it will generate it internally). The rest of the platform require the index name to be defined as part of their syntax.

Handling of the null value of the $name name parameter of the Index constructor was added in #2854. Quite likely, it was done in order to satisfy a test for the code that would use an index to create a primary key constraint. Thus, there was a false assumption that given that constraints can be unnamed, indexes should be as well (see #2854 (comment)).

Unlike foreign key and unique constraints, for which DBAL generates the name, if it's omitted in the definition, it doesn't do that for indexes, so two indexes with empty name cannot even co-exist in a table definition:

new Table('t', [
    new Column('c1', Type::getType('integer')),
    new Column('c2', Type::getType('integer')),
], [
    new Index(null, ['c1']),
    new Index(null, ['c2']),
]);

// Doctrine\DBAL\Schema\Exception\IndexAlreadyExists:
//   An index with name "" was already defined on table "t".

@morozov morozov added this to the 4.3.0 milestone Dec 26, 2024
@morozov morozov requested a review from greg0ire December 26, 2024 01:21
@morozov morozov marked this pull request as ready for review December 26, 2024 01:21
@morozov morozov merged commit 85765ed into doctrine:4.3.x Dec 26, 2024
67 checks passed
@morozov morozov deleted the deprecate-empty-index-name branch December 26, 2024 16:31
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