doctrine / migrations

Doctrine Database Migrations Library
https://www.doctrine-project.org/projects/migrations.html
MIT License
4.65k stars 387 forks source link

DBAL 4.0 and ArrayParameterType #1407

Closed michalbundyra closed 4 months ago

michalbundyra commented 4 months ago

Bug Report

Q A
BC Break yes/no
Version 3.7.3

Summary

Tying to migrate to DBAL 4 (4.0.1) and in v3 we had Connection::PARAM_INT_ARRAY deprecated in favour of ArrayParameterType::INTEGER.

Then in v4 ArrayParameterType has been changed to enum, so it is a type itself.

Example query we have in the migrations:

$this->addSql('DELETE FROM books WHERE id IN (:ids)', ['ids' => $booksIds], ['ids' => ArrayParameterType::INTEGER]);

Current behavior

Exception:

Fatal error: Uncaught TypeError: Doctrine\Migrations\InlineParameterFormatter::formatParameter(): Argument #2 ($type) must be of type string|int, Doctrine\DBAL\ArrayParameterType given, called in [...]/vendor/doctrine/migrations/lib/Doctrine/Migrations/InlineParameterFormatter.php on line 46 and defined in [...]/vendor/doctrine/migrations/lib/Doctrine/Migrations/InlineParameterFormatter.php on line 56

TypeError: Doctrine\Migrations\InlineParameterFormatter::formatParameter(): Argument #2 ($type) must be of type string|int, Doctrine\DBAL\ArrayParameterType given, called in [...]/vendor/doctrine/migrations/lib/Doctrine/Migrations/InlineParameterFormatter.php on line 46 in [...]/vendor/doctrine/migrations/lib/Doctrine/Migrations/InlineParameterFormatter.php on line 56

How to reproduce

As I see the typehint here: https://github.com/doctrine/migrations/blob/3.7.x/lib/Doctrine/Migrations/InlineParameterFormatter.php#L56

is just string|int $type, so it would not work with DBAL 4.0

It is kinda similar to: https://github.com/doctrine/dbal/issues/6309

Expected behavior

No errors.