-
-
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
Empty hasMany relationship not sent to server by model.save() #5539
Comments
@ryanto did your work land prior to 3.2 or is this related to it? |
@runspired @ryanto I suspect that this line is to blame. you can see it in the diff from 3.1.1 to 3.2.0.
To fix it, we could add logic for the case where the relationship is completely empty and then add an empty AsideWhile looking at the code, I also observe that |
@ryanto @runspired Let me know if you'd like me to get a PR up - I'd love to contribute. |
Edit: Opps, I think I wasn't understanding this. @les2 does this PR fix the issue? #5466 If not, do you mind adding a failing test? There's a few example has many tests you can copy from in the jsonapi serializer @runspired I think my fix was post 3.2 |
@ryanto @runspired I looked at the commits and could only find that fix in v3.4.0-beta.1 |
3.3.1 was just released but this is still not fixed, you have to use 3.4.0-beta.2 |
@urbany 3.3 was a re-release of 3.2. They are and will effectively remain the same release. (That's not to say we might not backport this, just why this was done post 3.2 and yet not in 3.3) |
seems like 3.4 is also impacted. I have the same issue, and emberdata is clearly not serializing empty hasmany. |
Hi @olivierchatry, Have you enabled serializing the hasMany relationship in your serializer? export default ApplicationSerializer.extend(, {
attrs: {
hasManyRelationshipNameHere: { serialize: true }
}
}); |
Hello @ryanto ! I think it does serialize it, but as soon as there is not more element in the relationships, it does not serialized the relationships anymore, even if there was one before. So the partial update, on the server side, does not remove the last element. edit: removed last comment, was looking as the wrong pane of the network debugger :) |
Haaa wait, my fault, I override a function in my app that was producing the bug. Sorry ! |
Thanks @runspired ! Looks like the fix was released in |
@ryanto 3.1.2 seems to work, but I still have the same issue in 3.3.2. @runspired can you confirm what the situation is with back-porting a fix to 3.3.x ? If it helps, I can confirm that the issue is fixed in v3.4.2 |
Seems like I am having this issue in v3.4.4 (but not systematically on all models)... |
Also having the issue on 3.25 |
@acdn-tsmith its (more than) likely a different issue. A test PR or demo app/twiddle replicating the issue is welcome. If you can reproduce it please open a new issue for us! Since serializers are predominantly an app-code (vs lib-code) concept, there's a relatively good chance you're seeing this due to code added or modified in your serializer. If you can't replicate without serializer modifications then that's something to look into. |
While QAing our next release and we had to downgrade ember-data to 3.1.1 from 3.2.0 because of a weird bug.
When updating a
hasMany
relationship to an empty array and called.save()
on the owning model, the empty array is not sent to the server.example:
... later ...
In 3.1.1, this worked --- an empty relationship would be sent to the server.
After upgrading to 3.2.0, it not longer sends the empty relationship.
Unfortunately, I haven't been able to put together a simple repo recipe on github - I only have the rather complicated example that is our application (which I can't share for obvious reasons).
I have to leave the office right now but will try to get some more details in this issue when I can (probably tomorrow).
That said, please be careful upgrading to 3.2.0 :)
The text was updated successfully, but these errors were encountered: