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

Schema manager errors on custom MySQL index #6781

Open
dbu opened this issue Feb 12, 2025 · 0 comments
Open

Schema manager errors on custom MySQL index #6781

dbu opened this issue Feb 12, 2025 · 0 comments

Comments

@dbu
Copy link
Member

dbu commented Feb 12, 2025

Bug Report

Q A
Version 3.9.4

Summary

With a custom calculated index, the schema tool fails with an exception:

Argument #1 ($column) must be of type string, null given, called in /www/vendor/doctrine/dbal/src/Schema/Index.php on line 72

The index i created is CREATE INDEX json_author ON auction_json_indexed ( (JSON_VALUE(item, '$.author' RETURNING CHAR(255))) )

Current behavior

Exception trace:
  at /www/vendor/doctrine/dbal/src/Schema/Index.php:81
 Doctrine\DBAL\Schema\Index->_addColumn() at /www/vendor/doctrine/dbal/src/Schema/Index.php:72
 Doctrine\DBAL\Schema\Index->__construct() at /www/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:1500
 Doctrine\DBAL\Schema\AbstractSchemaManager->_getPortableTableIndexesList() at /www/vendor/doctrine/dbal/src/Schema/MySQLSchemaManager.php:153
 Doctrine\DBAL\Schema\MySQLSchemaManager->_getPortableTableIndexesList() at /www/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:424
 Doctrine\DBAL\Schema\AbstractSchemaManager->doListTables() at /www/vendor/doctrine/dbal/src/Schema/MySQLSchemaManager.php:66
 Doctrine\DBAL\Schema\MySQLSchemaManager->listTables() at /www/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:1651
 Doctrine\DBAL\Schema\AbstractSchemaManager->createSchema() at /www/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:1663
 Doctrine\DBAL\Schema\AbstractSchemaManager->introspectSchema() at /www/vendor/doctrine/migrations/src/Generator/DiffGenerator.php:117
 Doctrine\Migrations\Generator\DiffGenerator->createFromSchema() at /www/vendor/doctrine/migrations/src/Generator/DiffGenerator.php:63
 Doctrine\Migrations\Generator\DiffGenerator->generate() at /www/vendor/doctrine/migrations/src/Tools/Console/Command/DiffCommand.php:135
 Doctrine\Migrations\Tools\Console\Command\DiffCommand->execute() at /www/vendor/symfony/console/Command/Command.php:279
 Symfony\Component\Console\Command\Command->run() at /www/vendor/symfony/console/Application.php:1047
 Symfony\Component\Console\Application->doRunCommand() at /www/vendor/symfony/framework-bundle/Console/Application.php:123
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /www/vendor/symfony/console/Application.php:316
 Symfony\Component\Console\Application->doRun() at /www/vendor/symfony/framework-bundle/Console/Application.php:77
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /www/vendor/symfony/console/Application.php:167
 Symfony\Component\Console\Application->run() at /www/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /www/vendor/autoload_runtime.php:29

Expected behavior

I would expect the schema tool to ignore an index without column, as it was not defined by doctrine.

How to reproduce

Create the index from the description, then run the doctrine:migrations:diff command.

Workaround

I added a check in AbstractSchemaManager::_getPortableTableIndexesList right before creating the new $index instance: if (! $defaultPrevented && ! in_array(null, $data['columns'], true)) {. I am not sure if that is a reasonable fix or has other side effects. That change would hide the index from doctrine.

Of note: With postgres, I get no error and the index is not seen in the schema tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant