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
Exception occurs at Doctrine\DBAL\Schema\Index::__addColumn while I try to make a migration with a table that has a function as index instead of column.
I believe this exception happens because I'm using a function inside the index in MySQL (8.0.35)
Current behaviour
I try to make a a migration and I an error is thrown. Here I paste the log [2024-05-08T15:30:30.136808+00:00] console.CRITICAL: Error thrown while running command "make:migration -vvv". Message: "Doctrine\DBAL\Schema\Index::_addColumn(): Argument #1 ($column) must be of type string, null given, called in /home/len/projetos/dbal-bug-reproduce/vendor/doctrine/dbal/src/Schema/Index.php on line 72" {"exception":"[object] (TypeError(code: 0): Doctrine\\DBAL\\Schema\\Index::_addColumn(): Argument #1 ($column) must be of type string, null given, called in /home/len/projetos/dbal-bug-reproduce/vendor/doctrine/dbal/src/Schema/Index.php on line 72 at /home/len/projetos/dbal-bug-reproduce/vendor/doctrine/dbal/src/Schema/Index.php:81)","command":"make:migration -vvv","message":"Doctrine\\DBAL\\Schema\\Index::_addColumn(): Argument #1 ($column) must be of type string, null given, called in /home/len/projetos/dbal-bug-reproduce/vendor/doctrine/dbal/src/Schema/Index.php on line 72"} []
How to reproduce
1 - I started with composer create-project symfony/skeleton <project_name>
2 - composer req orm
3 - composer req --dev migrations maker debug log (last 2 is to make life easier)
4 - connect to MySQL and create database and table
CREATETABLEfoo (id intnot null auto_increment, bugged_column datetime, primary key(id));
this will create an date based index, removing the time from column
6 - php bin/console make:migration
7 - Watch the crash
As far as I noticed, the error happens at Doctrine\DBAL\Schema\Index line 72, because the index created is not associated to any column directly, making the query return columns key with 1 line, but with a null value
this happens around line 1472 of Doctrine\DBAL\Schema\AbstractSchemaManager::_getPortableTableIndexesList $result[$keyName]['columns'][] = $tableIndex['column_name']; // column name is null as returned from query in mysql
When I replaced with $result[$keyName]['columns'][] = $tableIndex['column_name'] ?? ''; migration succeded, but I don't know what will happen leaving this way.
If you try to check before hand if the value is null it'll throw an error requiring columns
if ( $tableIndex['column_name'] !== null )
$result[$keyName]['columns'][] = $tableIndex['column_name'];
Expected behaviour
The expected behaviour is to execute the migration command correctly, creating a new migration.
I have a table with few hundred millions rows and I have a column datetime and few systems in php, power bi, excel querying this table making this date(column) instead of between yyyy-mm-dd 00:00:00 and yyyy-mm-dd 23:59:59, which was triggering a full table scan and this index improved performance a lot
The text was updated successfully, but these errors were encountered:
Bug Report
Summary
Exception occurs at Doctrine\DBAL\Schema\Index::__addColumn while I try to make a migration with a table that has a function as index instead of column.
I believe this exception happens because I'm using a function inside the index in MySQL (8.0.35)
Current behaviour
I try to make a a migration and I an error is thrown. Here I paste the log
[2024-05-08T15:30:30.136808+00:00] console.CRITICAL: Error thrown while running command "make:migration -vvv". Message: "Doctrine\DBAL\Schema\Index::_addColumn(): Argument #1 ($column) must be of type string, null given, called in /home/len/projetos/dbal-bug-reproduce/vendor/doctrine/dbal/src/Schema/Index.php on line 72" {"exception":"[object] (TypeError(code: 0): Doctrine\\DBAL\\Schema\\Index::_addColumn(): Argument #1 ($column) must be of type string, null given, called in /home/len/projetos/dbal-bug-reproduce/vendor/doctrine/dbal/src/Schema/Index.php on line 72 at /home/len/projetos/dbal-bug-reproduce/vendor/doctrine/dbal/src/Schema/Index.php:81)","command":"make:migration -vvv","message":"Doctrine\\DBAL\\Schema\\Index::_addColumn(): Argument #1 ($column) must be of type string, null given, called in /home/len/projetos/dbal-bug-reproduce/vendor/doctrine/dbal/src/Schema/Index.php on line 72"} []
How to reproduce
1 - I started with
composer create-project symfony/skeleton <project_name>
2 - composer req orm
3 - composer req --dev migrations maker debug log (last 2 is to make life easier)
4 - connect to MySQL and create database and table
5 - create the index on bugged_column as follow
this will create an date based index, removing the time from column
6 - php bin/console make:migration
7 - Watch the crash
As far as I noticed, the error happens at Doctrine\DBAL\Schema\Index line 72, because the index created is not associated to any column directly, making the query return columns key with 1 line, but with a null value
this happens around line 1472 of Doctrine\DBAL\Schema\AbstractSchemaManager::_getPortableTableIndexesList
$result[$keyName]['columns'][] = $tableIndex['column_name'];
// column name is null as returned from query in mysqlWhen I replaced with
$result[$keyName]['columns'][] = $tableIndex['column_name'] ?? '';
migration succeded, but I don't know what will happen leaving this way.If you try to check before hand if the value is null it'll throw an error requiring columns
Expected behaviour
The expected behaviour is to execute the migration command correctly, creating a new migration.
I have a table with few hundred millions rows and I have a column datetime and few systems in php, power bi, excel querying this table making this date(column) instead of between yyyy-mm-dd 00:00:00 and yyyy-mm-dd 23:59:59, which was triggering a full table scan and this index improved performance a lot
The text was updated successfully, but these errors were encountered: