-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
DDC 3863 - Invalid JsonArrayType [master] #891
Conversation
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DBAL-1276 We use Jira to track the state of pull requests and the versions they got |
175d494
to
d886fa6
Compare
This is a BC break, so merging it in 2.x branches is totally out of question (BC breaks cannot happen in minor versions). and DBAL 3.0 is not yet planned. The master branch is expected to become DBAL 2.6. So -1 on that for now. |
Thought so, but still, I think this is an erratic behavior that prevents the usage of this type in the case when the field can be referred by many columns. For now, I've got to extend this type and override this mechanism with something similar to the fix I'm proposing here... |
what do you mean by |
e.g : I have a field declared in an joined inheritance in some subentities (not all of them). Here is (a little bit stripped...) the request that is made : SELECT m0_.id AS id_0,
i1_.mimetype AS mimetype_9, i1_.thumbnails AS thumbnails_image,
d2_.mimetype AS mimetype_15, d2_.thumbnails AS thumbnails_docs
FROM Media m0_
LEFT JOIN Image i1_ ON m0_.id = i1_.id
LEFT JOIN Document d2_ ON m0_.id = d2_.id; I renamed the alias of the "thumbnail" for this to be clearer. The result is as following : As you can see, the first row is a Document and the other one is a Image. They both have common fields declared on their own, but these entities varies on some points, but this is not the subject here. They both have a json_array So basically, the Document never has the right value, it always displays and stores an empty array... which is wrong IMO. The |
@Taluu I agree this was a bad architectural choice at the beginning (and even a bad name as But changing it is not possible in 2.x for BC reasons, and the work on 3.0 is not planned yet so this cannot be merged. What you can do in the meantime is define your own DBAL type mapping values to a json field without any special case, and use that instead of the core type. |
Yes that is what I have done, which does the trick. But I still thought this could be up for debate if it is really necessary to keep the BC, as I think this is more a bug than something to break. |
@Taluu the issue with this is that it is the worse kind of BC break: the kind breaking things silently, because people won't get an obvious error if they have code relying on the current behavior of the type. and the way to fix it is to run a DB migration, not to change some code (to transform empty arrays to empty arrays in JSON). What we could do is to introduce a new json type in DBAL 2.6 and deprecate the old one. This way, switching to the better behavior would be opt-in rather than being mandatory |
Closing in favor of making a new type for 2.6 |
Master version of the DDC-3863's fix. Basically, instead of returning an empty
array()
value if the value is null (or empty), we're returning another null value instead.If you think this is a valid addition (after some corrections if needed), should I open other PRs for the other supported branches (2.3, 2.4, 2.5) ? But this looks like a BC break, even though the original behaviour is strange compared to the
ArrayType
's behavior...Thanks