This sort of crosses over between REST module and Serialization.module. I forget where we decided to put it, so refile if needed. :-)
Problem/Motivation
PATCH support is tricky for many reasons. In particular, if the patch doesn't say what the language of the entity is we may not know what to do with it. Which language do we set? How can we deal with missing fields that are required for the entity to be valid but not for the patch command since it may still be valid when combined with an existing entity?
Proposed resolution
The solution is to create a new EntityNG type, EntityDiff. EntityDiff contains no fields of its own, but can have its schema defined on the fly.
When processing a PATCH request for a node, for example, the REST module will take the incoming data and pass it to the serializer, asking for it to be turned into not a node but an EntityDiff entity. The serializer will then dutifully return an EntityDiff entity containing just the fields represented in the incoming payload.
REST module will then take the EntityDiff and map its fields onto the corresponding fields on the node that is being updated. After it's updated, we can then validate it to ensure that it's valid per the various required fields rules and so forth and then save it.
Remaining tasks
This needs to get written. :-) We also need to verify that the Entity API is capable of supporting an entity type whose field definitions are defined on the fly at runtime. If it's not, then Entity API is not sufficiently abstracted and should be fixed.
User interface changes
None.
API changes
Makes PATCH work nicely.