You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a table has a UniqueConstraint attribute where there's no name neing explicitly set (e.g. #[Mapping\UniqueConstraint(fields: ['email'])]), several included CLI tools produce an error:
TypeError: Doctrine\DBAL\Schema\Index::__construct(): Argument #1 ($name) must be of type ?string, int given, called in /app/vendor/doctrine/orm/src/Tools/SchemaTool.php on line 341 and defined in /app/vendor/doctrine/dbal/src/Schema/Index.php:42
Stack trace:
#0 /app/vendor/doctrine/orm/src/Tools/SchemaTool.php(341): Doctrine\DBAL\Schema\Index->__construct(0, Array, true, false, Array, Array)
#1 /app/vendor/doctrine/orm/src/Tools/SchemaTool.php(896): Doctrine\ORM\Tools\SchemaTool->getSchemaFromMetadata(Array)
#2 /app/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/UpdateCommand.php(78): Doctrine\ORM\Tools\SchemaTool->getUpdateSchemaSql(Array)
#3 /app/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/AbstractCommand.php(37): Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand->executeSchemaCommand(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), Object(Doctrine\ORM\Tools\SchemaTool), Array, Object(Symfony\Component\Console\Style\SymfonyStyle))
#4 /app/vendor/symfony/console/Command/Command.php(279): Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/vendor/symfony/console/Application.php(1031): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /app/vendor/symfony/console/Application.php(318): Symfony\Component\Console\Application->doRunCommand(Object(Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /app/vendor/symfony/console/Application.php(169): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /app/vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php(30): Symfony\Component\Console\Application->run()
#9 /app/cli(24): Doctrine\ORM\Tools\Console\ConsoleRunner::run(Object(Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider), Array)
#10 {main}
I also tested by replacing the UniqueConstraint with an Index and that has the correct behavior. It appears isolated to unique indexes.
Current behavior
Instead of a deterministic index name being generated from the referenced values, the above error is produced.
How to reproduce
Define an entity with a UniqueConstraint attribute. Both fields and columns definitions reproduce this. Do not explicitly set a name.
Configure Doctrine otherwise per normal.
Run one of the following packaged CLI commands:
orm:info
orm:validate
orm:schema-tool:update --dump-sql
Expected behavior
If name is specified in the attribute, it's used (this IS the current behavior). If not, one is generated based on the columns as occurred in ORM 2.x.
The text was updated successfully, but these errors were encountered:
Bug Report
Summary
If a table has a UniqueConstraint attribute where there's no name neing explicitly set (e.g.
#[Mapping\UniqueConstraint(fields: ['email'])]
), several included CLI tools produce an error:I also tested by replacing the
UniqueConstraint
with anIndex
and that has the correct behavior. It appears isolated to unique indexes.Current behavior
Instead of a deterministic index name being generated from the referenced values, the above error is produced.
How to reproduce
UniqueConstraint
attribute. Bothfields
andcolumns
definitions reproduce this. Do not explicitly set aname
.orm:info
orm:validate
orm:schema-tool:update --dump-sql
Expected behavior
If
name
is specified in the attribute, it's used (this IS the current behavior). If not, one is generated based on the columns as occurred in ORM 2.x.The text was updated successfully, but these errors were encountered: