couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: Support _id and _rev being null on a POST
Date Fri, 08 Oct 2010 22:50:47 GMT
On Fri, Oct 8, 2010 at 6:43 PM, John Logsdon <john.logsdon@netdev.co.uk> wrote:
> Hi
>
> I'd like to be able to support the following scenario:
>
> curl -XPOST -H"Content-Type: application/json" http://localhost:5984/uta -d
> '{"_id": null, "_rev":null,"x":"y"}'
>
> Which returns:
>
> {"error":"bad_request","reason":"Document id must be a string"}
>
> I'd like the above to work the same as this command:
>
> curl -XPOST -H"Content-Type: application/json" http://localhost:5984/uta -d
> '{"x":"y"}'
>
> which returns:
>
> {"ok":true,"id":"c9fd97f3eb58fdb62ef7a80440001662","rev":"1-935564bc7ec7e86aa82ecec3face18f6"}
>
>
> Is there a reason why couchdb doesn't do the same action on a null _id/_rev
> as it does when the fields aren't present?
>
> Regards
>
> John
>

A value of null is not equivalent to no value. Null is a value and its
not a valid document id. Hence, the error.

I don't like the idea of silently discarding it and creating a new
document with a random doc id. I can see this causing lots of
headaches when someone has a bug and doesn't realize their code is
just creating random documents.

Paul Davis

Mime
View raw message