OData / OData/AspNetCoreOData

Inconsistent handling of navigation properties between PUT and PATCH

Open
#172 1 comment 0 reactions 1 assignee View on GitHub

@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:

  1. Why the inconsistency? The workaround is to use Put or CreateRef and DeleteRef
  2. 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 Put semantics is wrong and Patch is 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.