dbal icon indicating copy to clipboard operation
dbal copied to clipboard

Fix implicit/generated unique index name typo

Open mvorisek opened this issue 2 years ago • 6 comments

Q A
Type bug
Fixed issues n/a

Summary

In Table::addUniqueConstraint() it was/is correct, but in Table::_addUniqueConstraint() it was wrong.

mvorisek avatar Jul 11 '22 14:07 mvorisek

This change is barely acceptable in a patch release since it doesn't fix a bug and requires a schema migration. Depending on how the DBAL handles the rename, it may be a BC break. Please test the migration across the platforms.

morozov avatar Jul 12 '22 14:07 morozov

@morozov this is more or less typo, as addUniqueIndex method https://github.com/doctrine/dbal/blob/3.3.7/src/Schema/Table.php#L237 uses uniq, but _addUniqueConstraint does not.

mvorisek avatar Jul 12 '22 14:07 mvorisek

If it's a typo that doesn't change any behavior, why does this code exist in the first place?

morozov avatar Jul 12 '22 14:07 morozov

If it's a typo that doesn't change any behavior, why does this code exist in the first place?

it depends if the unique index is created using a constructor or not. I agree, the same should not be done on 2 places, but for now, I just correct the typo to unify the behaviour.

mvorisek avatar Jul 12 '22 14:07 mvorisek

it depends if the unique index is created using a constructor or not.

If it's created via the constructor, the resulting name will change. The migration from the old schema to the new one must be tested across platforms.

morozov avatar Jul 12 '22 15:07 morozov

I changed the target to 3.4.x. As discussed above, the code is basically on 2 places, it is a typo fix, thus no extra test added. I belive it can be merged as is, the code is welcomed to be deduplicated, but I will not pursue the refactoring.

mvorisek avatar Jul 24 '22 22:07 mvorisek

If the changes in this code do not result in any behavior changes, this code is redundant and should be removed. Changing code for the sake of changing it is not welcomed. It requires effort to review the changes and doesn't fix the actual problem (the code still doesn't do anything).

morozov avatar Aug 12 '22 01:08 morozov