Skip to content
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

Nullable single-valued navigation property or singleton: update or upsert? #2060

Open
HeikoTheissen opened this issue Mar 4, 2025 · 0 comments
Labels
Protocol Protocol, URL Conventions V4.02

Comments

@HeikoTheissen
Copy link
Contributor

OData-Protocol, section 11.4.4 allows upserts for nullable

  • single-valued navigation properties under certain conditions
  • singletons generally.

How does an upsert differ from an update in these cases? The thinking seems to be "a change from null to non-null is treated like an insert". I suggest to make this explicit:

§1. The introductory sentence says

An upsert occurs when the client sends an update request to a valid URL that identifies a single entity that does not yet exist. In this case the service MUST handle the request as a create entity request or fail the request altogether.

Translated for our case, "does not yet exist" means "is null", and (contrary to section 11.4.2) the "create entity request" does not

create an entity in a collection.

§2. The last two paragraphs explain how the If-(None-)Match header can be used to distinguish between insert and update. Translated for our case "insert" means "change from null to non-null" (or even to null?), and "update" means "change from non-null to any value".

§3. Clarify the meaning if Upsertable = true and Updatable = false in the capabilities annotation:
https://github.com/oasis-tcs/odata-vocabularies/blob/229c2cd0aca61fcfb9ca66f437ad144ad227a766/vocabularies/Org.OData.Capabilities.V1.xml#L712-L717

This combination makes no sense for entities in a collection. But for our single-valued case this would translate into "PATCH request allowed only if current value is null". The client could enforce this with If-None-Match: *.


Finally, a typo?

Similarly, services MUST fail an update upsert request

@HeikoTheissen HeikoTheissen moved this to Open in OData TC Mar 4, 2025
@HeikoTheissen HeikoTheissen added Protocol Protocol, URL Conventions V4.02 labels Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Protocol Protocol, URL Conventions V4.02
Projects
Status: Open
Development

No branches or pull requests

1 participant