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

[PropertyInfo][DoctrineBridge] wrong type for doctrine json column #35968

Closed
norkunas opened this issue Mar 5, 2020 · 2 comments
Closed

[PropertyInfo][DoctrineBridge] wrong type for doctrine json column #35968

norkunas opened this issue Mar 5, 2020 · 2 comments

Comments

@norkunas
Copy link
Contributor

norkunas commented Mar 5, 2020

Symfony version(s) affected: >=4.4

Description

#35851 introduced a BC break with json columns. Previously when using @var mixed and @ORM\Column(type="json") property info returned null for type so serializer accepted any value for this, but currently it always returns Type as builtin array and it doesn't accept anymore mixed values.

How to reproduce

will write if needed

Possible Solution

Return null for json type column, while leaving json_array column intact.

Additional context

@fancyweb
Copy link
Contributor

fancyweb commented Mar 5, 2020

Status: reviewed.

This is normal since now the json type is supported. json is the new name of json_array.

However I agree with you that this type can be used with mixed data, ie it doesn't have to be array. I reported it in another PR (see #35794 (comment)). But it has always been like this (on the json_array type), this is why I applied the same treatment for json. Both have to be consistent I guess. IMO, we should return null for both since we can't guess but that would break compatibility too.

@norkunas
Copy link
Contributor Author

norkunas commented Mar 5, 2020

json is the new name of json_array

I disagree. In json_array doctrine was converting null or empty value to array, but json type doesn't do that. In my opinion property info is too strict to always set this as array while doctrine can store any value for json

nicolas-grekas added a commit that referenced this issue Mar 13, 2020
… for "json" type (fancyweb)

This PR was merged into the 3.4 branch.

Discussion
----------

[DoctrineBridge][DoctrineExtractor] Fix wrong guessed type for "json" type

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #35968
| License       | MIT
| Doc PR        | -

After checking the code, it appears that `json` have a different behavior than `json_array`.

> In json_array doctrine was converting null or empty value to array, but json type doesn't do that

@norkunas is right about this. Consequently, we cannot safely guess a built in type for the `json` Doctrine type.

Commits
-------

f9f5f8d [DoctrineBridge][DoctrineExtractor] Fix wrong guessed type for "json" type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants