Inherit unnamed indexes from mapped superclasses - #12633
SulimanAbdulrazzaq wants to merge 1 commit into
Conversation
Unnamed indexes and unique constraints only get a positional key, so addInheritedIndexes() dropped the first unnamed index of a mapped superclass as soon as the entity declared one of its own. Append unnamed entries of the superclass unless the entity already declares one on the same columns or fields, and keep overriding named entries by name.
|
@greg0ire this is the 3.7.x port of #12630, which I closed after your note about ORM 2. |
|
The "PHPUnit (fail on deprecations)" failure isn't caused by this change. That job installs Fixing that one call site isn't enough: with deduplication off, |
greg0ire
left a comment
There was a problem hiding this comment.
We don't know how many projects suffer from this. A patch release suddenly generating extra indices makes me uneasy, however since we are talking about new indices, I think it should be OK. It's not like we are modifying a database column. If other maintainers agree, let's merge this, if they don't, then we should retarget to 3.8.x and introduce a configuration knob just for this.
Fixes #12179
This is a port of #12630, which targeted 2.20.x, to 3.7.x. The bug is still present in 3.x:
addInheritedIndexes()is unchanged, and the attribute and XML drivers still store unnamed indexes and unique constraints under positional keys.ClassMetadataFactory::addInheritedIndexes()copies the indexes and unique constraints of a mapped superclass into the entity. It skips every key the entity already has, which lets an entity override an inherited index by reusing its name. Indexes declared without a name only get a positional key, though, so every unnamed index the entity declared shadowed the superclass's unnamed index at the same position: declaring one dropped the first inherited index, declaring two dropped the first two, and so on. The generated schema then silently lacked those indexes.This builds on the patch @speller posted in the issue:
One visible change beyond restoring the dropped indexes: an entity that declares a named index on the same columns as an unnamed superclass index now gets only its own index, instead of both.
BasicInheritanceMappingTestgets two tests (groupGH-12179). Without the change inClassMetadataFactory, both fail: the entity's unnamed index replaces the superclass's first unnamed index, and a named entity index sits next to an unnamed superclass index on the same column.