dbal icon indicating copy to clipboard operation
dbal copied to clipboard

PostgreSQL indexes not detected correctly on existing table, if table name is protected keyword.

Open acirulis opened this issue 2 years ago • 1 comments

Bug Report

Q A
Version 3.4.0

Summary

When table name is protected keyword, e.g. "user", Doctrine diff won't detect indexes and subsequently will try to add them with migration.

Because of https://github.com/doctrine/dbal/pull/5268/files#diff-bd15f9cca82bf2dcf0b0bb88cb4354ae7b277b7cf8443354534d509ac9f2b945R46

method listTables() were added to PostgreSQLSchemaManager.php , and in AbstractSchemaManager.php doListTables() is executed instead of listTables().

doListTables() returns incorrect index data (array key for user table indexes ($indexColumnsByTable) is "user", so it does not get merged with user table key (without quotes) in array $tableColumnsByTable.

acirulis avatar Aug 08 '22 15:08 acirulis

The ::REGCLASS type casting adds quotes around reserved names. We need to replace it with a JOIN of the actual relation (pg_class) that contains the table name like it's done to retrieve the index name.

morozov avatar Aug 08 '22 20:08 morozov

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Sep 16 '22 00:09 github-actions[bot]