-
Notifications
You must be signed in to change notification settings - Fork 7
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
Possible bug with generating post request #1147
Comments
even when doing this orderLine.hasPallet = true;
orderLine.save().subscribe(); it doesn't generate the hasPallet value inside the request data. |
It looks like, when the order is patched, the collection is internally updated overriding the changes on the linked order-line resources. But with the JSON API SPEC it is not possible to create/update relations on the same request as the parent, which leaves us with the option to do it sequentially, running into this issue. The thing I tried is to deepcopy the list of order-lines before persisting the order and when checking this list all the attributes still have the correct value but if I check the list of referenced order-lines they are reverted to the original state. Is there an option to send with the save() method to not update the reference internally inside the collection? Which should result in the order-lines not being overridden? This is a preferred situation because we navigate back to a list afterwards and then refetch all the records, which in turn should update the persisted order record. |
There is something fundamentally not working: I have tried the following: this.orderPersistSubscription = combineLatest(this.orderLineService.currentPersistedOrderLines.map(
(orderLine: OrderLine) => {
delete orderLine['has_pallet'];
delete orderLine['bigbag_type'];
return orderLine.save();
})
).pipe(
// mergeMap(() => order.save(requestOptions)),
// mergeMap(() => combineLatest(this.orderLineService.currentNewOrderLines.map(
// (orderLine: OrderLine) => orderLine.save()))
// )
).subscribe(() => {
// this.orderLineService.hasChanges = false;
// this.router.navigate(['/orders/concept/list']);
}); when removing the leftover properties which the map generates, the request works 2 times. My thought process to handle the order overriding the references was to first patch the persisted order lines, to secondly post/patch the order and lastly to post the newly created order lines (because they need the order reference). P.S. @DarkoKukovec could you give me any feedback on whether this issue is looked into or being tested, because we currently have a dependency on this very issue. |
Used libraries
core, jsonapi, jsonapi-angular, utils
Library version(s)
Sample API response (if relevant)
Request objects
Environments with the issue
Chrome 109.0.5414.74, Ubuntu 22.04.1 LTS
Environments without the issue
No response
Current behavior
logging
I'm searching a little bit with the generation of the patch request towards the API
whereas currently it looks like the changes on the object aren't generated into the body of the request.
weirdly when editing the amount property of the orderLine model it does handle properly.
I don't know for sure if it is a bug or support question.
Expected behavior
Request objects
Reproduction steps
The text was updated successfully, but these errors were encountered: