Can't set lenghts property for indexes in XML orm mapping #7530

Open
opened 2026-01-22 15:53:02 +01:00 by admin · 3 comments
Owner

Originally created by @tomasvts on GitHub (Jul 4, 2025).

Bug Report

Q A
Version 2.17

Summary

MariaDB default lenght for an index is 768, and dbal gets confused when it sees that length in the diff.
It is very much related with this PR:
https://github.com/doctrine/dbal/pull/3458

So if I try to set the default lenght for the index like this:

            <index columns="folder_ids">
                <options>
                    <option name="lengths">768</option>
                </options>
            </index>

It fails with the following error:

root@da6593746f02:/var/www/html# bin/console d:m:diff -e test -n

In Index.php line 372:
                                                                            
  array_filter(): Argument doctrine/dbal#1 ($array) must be of type array, string given  
                                                                            

doctrine:migrations:diff [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--namespace NAMESPACE] [--filter-expression FILTER-EXPRESSION] [--formatted] [--line-length LINE-LENGTH] [--check-database-platform [CHECK-DATABASE-PLATFORM]] [--allow-empty-diff] [--from-empty-schema]      

because the Index method hasTheSameColumnLenghts expects an array in that option:

    /**
     * Returns whether the index has the same column lengths as the other
     */
    private function hasSameColumnLengths(self $other): bool
    {
        $filter = static function (?int $length): bool {
            return $length !== null;
        };

        return array_filter($this->options['lengths'] ?? [], $filter)
            === array_filter($other->options['lengths'] ?? [], $filter);
    }

but how can I achieve this?

Current behavior

root@da6593746f02:/var/www/html# bin/console d:m:diff -e test -n

In Index.php line 372:
                                                                            
  array_filter(): Argument doctrine/dbal#1 ($array) must be of type array, string given  
                                                                            

doctrine:migrations:diff [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--namespace NAMESPACE] [--filter-expression FILTER-EXPRESSION] [--formatted] [--line-length LINE-LENGTH] [--check-database-platform [CHECK-DATABASE-PLATFORM]] [--allow-empty-diff] [--from-empty-schema]      

Expected behavior

The lenghts option is set for the index.

Originally created by @tomasvts on GitHub (Jul 4, 2025). ### Bug Report | Q | A |-------------------------------------------- | ------ | Version | 2.17 #### Summary MariaDB default lenght for an index is 768, and dbal gets confused when it sees that length in the diff. It is very much related with this PR: https://github.com/doctrine/dbal/pull/3458 So if I try to set the default lenght for the index like this: ``` <index columns="folder_ids"> <options> <option name="lengths">768</option> </options> </index> ``` It fails with the following error: ``` root@da6593746f02:/var/www/html# bin/console d:m:diff -e test -n In Index.php line 372: array_filter(): Argument doctrine/dbal#1 ($array) must be of type array, string given doctrine:migrations:diff [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--namespace NAMESPACE] [--filter-expression FILTER-EXPRESSION] [--formatted] [--line-length LINE-LENGTH] [--check-database-platform [CHECK-DATABASE-PLATFORM]] [--allow-empty-diff] [--from-empty-schema] ``` because the Index method `hasTheSameColumnLenghts` expects an array in that option: ``` /** * Returns whether the index has the same column lengths as the other */ private function hasSameColumnLengths(self $other): bool { $filter = static function (?int $length): bool { return $length !== null; }; return array_filter($this->options['lengths'] ?? [], $filter) === array_filter($other->options['lengths'] ?? [], $filter); } ``` but how can I achieve this? #### Current behavior ``` root@da6593746f02:/var/www/html# bin/console d:m:diff -e test -n In Index.php line 372: array_filter(): Argument doctrine/dbal#1 ($array) must be of type array, string given doctrine:migrations:diff [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--namespace NAMESPACE] [--filter-expression FILTER-EXPRESSION] [--formatted] [--line-length LINE-LENGTH] [--check-database-platform [CHECK-DATABASE-PLATFORM]] [--allow-empty-diff] [--from-empty-schema] ``` #### Expected behavior The lenghts option is set for the index.
Author
Owner

@morozov commented on GitHub (Jul 4, 2025):

@tomasvts if you believe this is a DBAL issue, please try reproducing it using only the DBAL.

@morozov commented on GitHub (Jul 4, 2025): @tomasvts if you believe this is a DBAL issue, please try reproducing it using only the DBAL.
Author
Owner

@tomasvts commented on GitHub (Jul 8, 2025):

This issue is fixed by adding the lenghts property. See https://github.com/doctrine/dbal/pull/3458#issuecomment-569087641

but it can only be added as Annotation, and not as a XML property.

@tomasvts commented on GitHub (Jul 8, 2025): This issue is fixed by adding the lenghts property. See https://github.com/doctrine/dbal/pull/3458#issuecomment-569087641 but it can only be added as Annotation, and not as a XML property.
Author
Owner

@derrabus commented on GitHub (Jul 15, 2025):

Moved to ORM. This was clearly posted on the wrong issue tracker.

@derrabus commented on GitHub (Jul 15, 2025): Moved to ORM. This was clearly posted on the wrong issue tracker.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7530