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

DBAL 4.0 and ArrayParameterType #1407

Closed
michalbundyra opened this issue Mar 6, 2024 · 0 comments · Fixed by #1408
Closed

DBAL 4.0 and ArrayParameterType #1407

michalbundyra opened this issue Mar 6, 2024 · 0 comments · Fixed by #1408

Comments

@michalbundyra
Copy link
Member

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: doctrine/dbal#6309

Expected behavior

No errors.

@michalbundyra michalbundyra changed the title DBAL 4.0.0 and ArrayParameterType DBAL 4.0 and ArrayParameterType Mar 6, 2024
michalbundyra added a commit to michalbundyra/migrations that referenced this issue Mar 6, 2024
Fixes doctrine#1407

A bit lame fix, but it looks like we did not really use other int types before anyway

With this change we can use DBAL v4 new enum types: `ArrayParameterType` and `ParameterType`.

Bumping version of DBAL to 3.6 as before that `ArrayParameterType` did not exist.
derrabus added a commit that referenced this issue Mar 6, 2024
)

Fixes #1407

A bit lame fix, but it looks like we did not really use other int types before anyway

With this change we can use DBAL v4 new enum types: `ArrayParameterType` and `ParameterType`.

Co-authored-by: Alexander M. Turek <me@derrabus.de>
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

Successfully merging a pull request may close this issue.

1 participant