Skip to content

Commit

Permalink
bug #43988 [DoctrineBridge] add support for the JSON type (dunglas)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

[DoctrineBridge] add support for the JSON type

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix api-platform/core#4547, api-platform/core#4553
| License       | MIT
| Doc PR        | n/a

The `json_array` Doctrine type is deprecated since DBAL 2.6 (we require version 2.7) and has been removed in DBAL 3.0 This PR adds back support for this new type.

Commits
-------

1e218c5 [DoctrineBridge] add support for the JSON type
  • Loading branch information
fabpot committed Nov 10, 2021
2 parents 070ed42 + 1e218c5 commit 0eacfd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -189,6 +189,7 @@ public function getTypes($class, $property, array $context = [])
case self::$useDeprecatedConstants ? DBALType::TARRAY : Types::ARRAY:
// no break
case 'json_array':
case 'json':
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)];

case self::$useDeprecatedConstants ? DBALType::SIMPLE_ARRAY : Types::SIMPLE_ARRAY:
Expand Down Expand Up @@ -316,6 +317,7 @@ private function getPhpType(string $doctrineType): ?string
case self::$useDeprecatedConstants ? DBALType::SIMPLE_ARRAY : Types::SIMPLE_ARRAY:
// no break
case 'json_array':
case 'json':
return Type::BUILTIN_TYPE_ARRAY;
}

Expand Down
Expand Up @@ -254,11 +254,11 @@ public function typesProvider()
new Type(Type::BUILTIN_TYPE_INT),
new Type(Type::BUILTIN_TYPE_OBJECT, false, DoctrineRelation::class)
)]],
['json', null],
['json', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)]],
];

if (class_exists(Types::class)) {
$provider[] = ['json', null];
$provider[] = ['json', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)]];
}

return $provider;
Expand Down

0 comments on commit 0eacfd9

Please sign in to comment.