You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "gert cuykens (JIRA)" <ji...@apache.org> on 2011/09/01 01:57:09 UTC

[jira] [Created] (COUCHDB-1268) "?rev=" URL query parameter

"?rev=" URL query parameter
---------------------------

                 Key: COUCHDB-1268
                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
             Project: CouchDB
          Issue Type: Improvement
          Components: Database Core
    Affects Versions: 1.2
         Environment: linux
            Reporter: gert cuykens
            Priority: Trivial


When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.

curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
'Content-Type: application/json' -d{
 "_id"          : "user:gert",
 "type"         : "user",
 "name"         : "gert",
 "roles"        : [],
 "password_sha" : "",
 "salt"         : ""
}'

curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
application/json' -d{
 "_id"          : "user:gert",
 "_rev":"5xxx",
 "type"         : "user",
 "name"         : "gert",
 "roles"        : [],
 "password_sha" : "",
 "salt"         : ""
}'

curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
-H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1268) "?rev=" URL query parameter

Posted by "Randall Leeds (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13099713#comment-13099713 ] 

Randall Leeds commented on COUCHDB-1268:
----------------------------------------

Patch is finished and as a side affect I think I'm enabling new_edits=false and batch=true for things like COPY and POST. Speak up if you have a reason for that not to be the case, but what I've done cleans up couch_httpd_db.erl quite a bit. Just need to separate the patches into a couple logical chunks and write a test.

> "?rev=" URL query parameter
> ---------------------------
>
>                 Key: COUCHDB-1268
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 1.2
>         Environment: linux
>            Reporter: gert cuykens
>            Assignee: Randall Leeds
>            Priority: Trivial
>              Labels: api-change
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.
> curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
> 'Content-Type: application/json' -d{
>  "_id"          : "user:gert",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
> application/json' -d{
>  "_id"          : "user:gert",
>  "_rev":"5xxx",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
> -H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (COUCHDB-1268) "?rev=" URL query parameter

Posted by "Randall Leeds (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Randall Leeds reassigned COUCHDB-1268:
--------------------------------------

    Assignee: Randall Leeds

> "?rev=" URL query parameter
> ---------------------------
>
>                 Key: COUCHDB-1268
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 1.2
>         Environment: linux
>            Reporter: gert cuykens
>            Assignee: Randall Leeds
>            Priority: Trivial
>              Labels: api-change
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.
> curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
> 'Content-Type: application/json' -d{
>  "_id"          : "user:gert",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
> application/json' -d{
>  "_id"          : "user:gert",
>  "_rev":"5xxx",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
> -H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1268) "?rev=" URL query parameter

Posted by "Adam Kocoloski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13095036#comment-13095036 ] 

Adam Kocoloski commented on COUCHDB-1268:
-----------------------------------------

I'll see your query string and raise you a request header -- set the value of the If-Match header to the document revision and you can omit both the qs parameter and the _rev in the JSON.  I definitely agree that the underscore-prefixed special document properties are a wart and one that we should have tried harder to avoid.

Regardless of the If-Match option we should be consistent in our API.  If the "rev" query-string parameter works everywhere else I see no reason why it shouldn't work for regular document PUTs as well.

> "?rev=" URL query parameter
> ---------------------------
>
>                 Key: COUCHDB-1268
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 1.2
>         Environment: linux
>            Reporter: gert cuykens
>            Priority: Trivial
>              Labels: api-change
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.
> curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
> 'Content-Type: application/json' -d{
>  "_id"          : "user:gert",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
> application/json' -d{
>  "_id"          : "user:gert",
>  "_rev":"5xxx",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
> -H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (COUCHDB-1268) "?rev=" URL query parameter

Posted by "Randall Leeds (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Randall Leeds closed COUCHDB-1268.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.2

> "?rev=" URL query parameter
> ---------------------------
>
>                 Key: COUCHDB-1268
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 1.2
>         Environment: linux
>            Reporter: gert cuykens
>            Assignee: Randall Leeds
>            Priority: Trivial
>              Labels: api-change
>             Fix For: 1.2
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.
> curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
> 'Content-Type: application/json' -d{
>  "_id"          : "user:gert",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
> application/json' -d{
>  "_id"          : "user:gert",
>  "_rev":"5xxx",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
> -H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1268) "?rev=" URL query parameter

Posted by "gert cuykens (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13095373#comment-13095373 ] 

gert cuykens commented on COUCHDB-1268:
---------------------------------------

I am not experienced enough to come up with better arguments, except for compatibility between other document based databases maybe. I trust you will have better judgment on this.

> "?rev=" URL query parameter
> ---------------------------
>
>                 Key: COUCHDB-1268
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 1.2
>         Environment: linux
>            Reporter: gert cuykens
>            Priority: Trivial
>              Labels: api-change
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.
> curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
> 'Content-Type: application/json' -d{
>  "_id"          : "user:gert",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
> application/json' -d{
>  "_id"          : "user:gert",
>  "_rev":"5xxx",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
> -H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Work stopped] (COUCHDB-1268) "?rev=" URL query parameter

Posted by "Randall Leeds (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on COUCHDB-1268 stopped by Randall Leeds.

> "?rev=" URL query parameter
> ---------------------------
>
>                 Key: COUCHDB-1268
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 1.2
>         Environment: linux
>            Reporter: gert cuykens
>            Assignee: Randall Leeds
>            Priority: Trivial
>              Labels: api-change
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.
> curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
> 'Content-Type: application/json' -d{
>  "_id"          : "user:gert",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
> application/json' -d{
>  "_id"          : "user:gert",
>  "_rev":"5xxx",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
> -H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1268) "?rev=" URL query parameter

Posted by "Jan Lehnardt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13095328#comment-13095328 ] 

Jan Lehnardt commented on COUCHDB-1268:
---------------------------------------

I agree that ?rev should be honoured, but I disagree that _id and _rev should not be part of the document itself. Other than theoretical purity I haven't seen any strong arguments against this and I've only seen good things coming out of it and I conclude that it is a very nice practical compromise. But we've had that discussion numerous times.

> "?rev=" URL query parameter
> ---------------------------
>
>                 Key: COUCHDB-1268
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 1.2
>         Environment: linux
>            Reporter: gert cuykens
>            Priority: Trivial
>              Labels: api-change
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.
> curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
> 'Content-Type: application/json' -d{
>  "_id"          : "user:gert",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
> application/json' -d{
>  "_id"          : "user:gert",
>  "_rev":"5xxx",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
> -H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1268) "?rev=" URL query parameter

Posted by "gert cuykens (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13095237#comment-13095237 ] 

gert cuykens commented on COUCHDB-1268:
---------------------------------------

Thanks, if-match works. This is by far the most logic way for me, no _id and no _rev. Pleas consider development in this direction that _id and _rev should always be header material. In futon both should also not be represented in the fields but in the bottom bar menu between previous an next version for example. Id is already represented in the top menu.

curl -X PUT http://localhost:5984/_users/user%3Agert88888 -H 'If-Match: 5xxx' -H 'Content-Type: application/json' -d '{
 "type"         : "user",
 "name"         : "gert",
 "roles"        : [],
 "password_sha" : "...",
 "salt"         : "..."
}'


> "?rev=" URL query parameter
> ---------------------------
>
>                 Key: COUCHDB-1268
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 1.2
>         Environment: linux
>            Reporter: gert cuykens
>            Priority: Trivial
>              Labels: api-change
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.
> curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
> 'Content-Type: application/json' -d{
>  "_id"          : "user:gert",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
> application/json' -d{
>  "_id"          : "user:gert",
>  "_rev":"5xxx",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
> -H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Work started] (COUCHDB-1268) "?rev=" URL query parameter

Posted by "Randall Leeds (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on COUCHDB-1268 started by Randall Leeds.

> "?rev=" URL query parameter
> ---------------------------
>
>                 Key: COUCHDB-1268
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1268
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 1.2
>         Environment: linux
>            Reporter: gert cuykens
>            Assignee: Randall Leeds
>            Priority: Trivial
>              Labels: api-change
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When PUTting a document you have to specify the current revision as a _rev key in the JSON; whereas many related requests (like DELETE, COPY and PUT of an attachment) specify the revision in a "?rev=" URL query parameter instead. The first example, will result into a document conflict because rev is not specified in the JSON and the rev from the url gets ignored. All other examples work. I strongly believe JSON bodies like this should never contain _id and _rev and will improve in much better client code.
> curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
> 'Content-Type: application/json' -d{
>  "_id"          : "user:gert",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
> application/json' -d{
>  "_id"          : "user:gert",
>  "_rev":"5xxx",
>  "type"         : "user",
>  "name"         : "gert",
>  "roles"        : [],
>  "password_sha" : "",
>  "salt"         : ""
> }'
> curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
> -H 'Content-Type: image/png' -d @picture.png

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira