Skip to content

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

@HeikoTheissen

Description

@HeikoTheissen

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 of Upsertable and Updatable in the capabilities annotation:
https://github.com/oasis-tcs/odata-vocabularies/blob/229c2cd0aca61fcfb9ca66f437ad144ad227a766/vocabularies/Org.OData.Capabilities.V1.xml#L712-L717

  • What does the combination of Upsertable = false and Updatable = true (the default values) mean in our single-valued case? Is a change from null to non-null then allowed?
  • The combination of Upsertable = true and Updatable = false 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: *. Correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions