dbal icon indicating copy to clipboard operation
dbal copied to clipboard

Index with length equal to column length keeps generating diff

Open derrabus opened this issue 2 years ago • 1 comments

Bug Report

Q A
Version 3.6.1

Summary

Reported by @janedbal in #5976.

When specifying a prefix index in MySQL with a prefix length matching the actual VARCHAR column length, DBAL's comparator will keep detecting changes to the deployed table.

Current behaviour

See the analysis in https://github.com/doctrine/dbal/pull/5976#issuecomment-1493374208.

Summary: MySQL silently drops the prefix from such an index definition.

How to reproduce

See #5976 for a failing test.

Create this table, deploy it to MySQL or MariaDB, intropect the newly created table and have the comparator compare it to your initial definition.

$table = new Table('my_table');
$table->addColumn('my_col', 'string', ['length' => 20]);
$table->addIndex(['my_col'], 'idx_col', [], ['lengths' => [20]]);

Expected behaviour

The table declared above should be considered equal to its deployed version.

Workaround

The issue can be worked around by not specifying a prefix length for the affected column.

derrabus avatar Apr 03 '23 09:04 derrabus