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

fix: Allow enum param types: ArrayParameterType and ParameterType #1408

Merged
merged 6 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"require": {
"php": "^8.1",
"composer-runtime-api": "^2",
"doctrine/dbal": "^3.5.1 || ^4",
"doctrine/dbal": "^3.6 || ^4",
"doctrine/deprecations": "^0.5.3 || ^1",
"doctrine/event-manager": "^1.2 || ^2.0",
"psr/log": "^1.1.3 || ^2 || ^3",
Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/Migrations/InlineParameterFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace Doctrine\Migrations;

use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Types\Type;

use function array_map;
Expand Down Expand Up @@ -53,7 +55,7 @@ public function formatParameters(array $params, array $types): string
return sprintf('with parameters (%s)', implode(', ', $formattedParameters));
}

private function formatParameter(mixed $value, string|int $type): string|int|bool|float|null
private function formatParameter(mixed $value, string|int|ArrayParameterType|ParameterType $type): string|int|bool|float|null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should change the type to mixed. After all, the method discards any value that is not a string anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derrabus pushed - if we ok with mixed, then I can even change back the bump in composer.json, but then we would not have a test case for ArrayParameterType as it does not exist in DBAL 3.5

{
if (is_string($type) && Type::hasType($type)) {
return Type::getType($type)->convertToDatabaseValue(
Expand Down
Loading