Open ralfhandl opened 4 months ago
Proposal:
Proposal:
- Support 1.
- Do not support 2.
Agree we should support 1.
If we don't support 2, then there will be a difference in behavior between a create request for a single entity versus a create request for a single entity within a bulk operation.
This becomes problematic for upsert requests, since the request is interpreted as an update if the item already exists (and thus, updating related entities is supported) and is interpreted as a create if the item doesn't already exist (in which case, do we error if the payload contained an update to a related entity, where we would have succeeded with the same payload if the entity already existed?).
I propose we split the issues -- use this issue (renamed) to track the use of key values in place of @ids, and create a new issue to propose supporting updating properties of related entities in create.
When trying to split this issue I realized that the underlying question to both parts is
Ideally the answer contains "identical for insert and update".
Splitting this up into sub-questions:
Effects
Nested entity representations
R1: Pure entity reference
{
"@context": "$metadata#$ref",
"@id": 42
}
R2: Sloppy entity reference (no @context
)
{
"@id": 42
}
{
"KeyProp": 42
}
{
"KeyProp": 42,
"NonKeyOne": "valueOne",
}
{
"NonKeyOne": "valueOne",
}
R6: Identified partial entity (entity-id, some non-key properties)
Note: this is not an entity reference because these MUST NOT contain properties.
{
"@id": 42,
"NonKeyOne": "valueOne",
}
More representations? Feel free to add them here.
In the above framework:
As described in ODATA-1450, when we create a resource we can link it to other, existing resources using @odata.id. We can also create new related resources.
This is similar to what we do with a delta patch operation and, indeed, within a delta patch operation we can create a new entity and create/update/remove related nested entities.
Should we support the same functionality when creating a single resource (i.e., using POST) that we do in a delta update?
Specifically, when we create an item using POST, should we 1) Support referencing existing items by key properties as an alternative to @odata.id? Note that, for non-contained nested resources with no navigation property binding you would have to either include the @odata.context in addition to key values or include the @odata.id. 2) Support modifying properties of related existing items?
Same question for using PUT/PATCH as an upsert – seems like at least PATCH, which already supports keyvalues and nested deltas for update, should also support the same changes as part of a create.
Imported from ODATA-1535