InfoQ

News

Merge, Replace, or Patch: How Astoria Handles Changing Data

Posted by Jonathan Allen on Jun 20, 2008 06:11 AM

Community
.NET,
SOA
Topics
Data Portability ,
REST ,
Data Access
Tags
ADO.NET Data Services

Using REST, what should happen when you perform a PUT operation to update existing data? The Astoria Team asks that question and explains their answer.

When an Astoria-based web service receives a PUT operation, there are two possible ways to handle the update. Either it could replace the pre-existing data or it could merge the new values into the old ones. Due to their goal of maintaining compatibility with AtomPub, Microsoft decided that PUT should map to a replace.

This of course leaves the question of how to represent merging operations. Options include introducing a new verb, MERGE, or a new custom header. Pablo Castro writes,

While we’re not thrilled with the idea of introducing a new HTTP method, overloading PUT with an extra header seems to be very problematic. If anything else, a server that does not support “merge” through headers would see PUT as a regular “replace” request and perform an operation that’s not what the client expected. Also other things break. For example, if a server sees an actual MERGE request and cannot handle it then it can respond with 405 – method not supported.

Another option they considered was the PATCH operation. Unfortunately the specification wasn't finalized before Microsoft's code freeze date. This left Microsoft in the unenviable position of either using PATCH and risking the final specification was incompatible or use MERGE with the understanding that it may be deprecated. Since the first option would result in either breaking clients or being non-compliant, they decided to go with MERGE.

Since we are on the topic of clients, one should know that .NET clients default to merge semantics. This was chosen because a .NET client may not know about all the fields on the server, and the server has no way to know which fields were intentionally blank versus which were simply unknown.

AJAX clients also default to merge semantics. And like .NET clients they have an optional parameter to indicate that replace semantics are preferred.

No comments

Reply

Exclusive Content

Ruby.rewrite(Ruby)

In this RubyFringe talk, Reginald Braithwaite writes Ruby code to read, write, and rewrite Ruby. Demos include extending Ruby with conditional expressions, call-by-name and more.

Book Except and Interview : Aptana RadRails, An IDE for Rails Development

Aptana RadRails: An IDE for Rails Development by Javier Ramírez discusses the latest Aptana RadRails IDE, a development environment for creating Ruby on Rails applications.

Fast Bytecodes for Funny Languages

Cliff Click discusses how to optimize generated bytecode for running on the JVM. Click analyzes and reports on several JVM languages and shows several places where they could increase performance.

Scott Ambler On Agile’s Present and Future

Scott Ambler, Practice Lead for Agile Development at IBM, speaks on the current status of the Agile community and practices having a look at the perspective of the Agile’s future.

Manager's Introduction to Test-Driven Development

Dave Nicolette and Karl Scotland try to introduce non-technical managers to one of the most popular Agile development techniques: Test-Driven Development (TDD).

Structured Event Streaming with Smooks

Smooks is best known for its transformation capabilities, but in this article Tom Fennelly describes how you can also use it for structured event streaming.

How to Work With Business Leaders to Manage Architectural Change

Successful architectures evolve over time to meet changing business requirements. Luke Hohmann presents how to collaborate with key members of your business to manage architectural changes.

Colors and the UI

In this article, Dr. Tobias Komischke explains how colors used in a GUI can influence our interaction with a computer and offers advice on using the appropriate colors for the interface.