Inconsistent handling of navigation properties between PUT and PATCH
Open
@xuzhg is already working on this.
Since May 21, 2021.
investigating
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
AspNetCoreOData 8.0.0 latest nightly
Create an Entity that has a navigation property:
POST http://localhost:5000/odata/People
{
"ID": 999,
"Name": "Some Great Company",
"Contact@odata.bind": "/Contacts(42)",
"Certifications@odata.bind": [
"Certifications('Apprentice')",
"Certifications('Master')"
]
}
Update it using PUT:
PUT http://localhost:5000/odata/People(666)
{
"Name": "Some Other Great Company",
"Certifications@odata.bind": [
"Certifications('Junior')",
"Certifications('Senior')"
]
}
The PeopleController.Put method receives as an argument the person class that includes the navigation property.
Now using Patch:
PUT http://localhost:5000/odata/People(666)
{
"Name": "Yet Other Great Company",
"Certifications@odata.bind": [
"Certifications('Mom')",
"Certifications('Dad')"
]
}
The PeopleController.Patch method receives as an argument the person class that does NOT includes the navigation property.
This raises a couple questions:
- Why the inconsistency? The workaround is to use
PutorCreateRefandDeleteRef - In the OData 4.01 standard here it says: "Deep inserts are not allowed in update operations using PUT or PATCH requests." By my informal interpretation this would mean that the currently implemented
Putsemantics is wrong andPatchis correct.
I have not tested the 7.X behavior so I don't know if this is existing behavior.
@mikepizzo
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.