Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-3264

POST to _all_docs does not respect conflicts=true

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.1.0
    • Component/s: Database Core
    • Labels:
      None

      Description

      In CouchDB 2.0, POST to _all_docs with ids specified in the keys field does not respect the conflicts=true parameter.

      In CouchDB 1.6.1:

      $ curl -X PUT http://127.0.0.1:5984/test
      {"ok":true}
      
      $ curl -X POST http://127.0.0.1:5984/test/_bulk_docs -H 'Content-type:application/json' -d '{ "docs":[{"_id":"foo","_rev": "1-a1"},{"_id":"foo","_rev": "1-a2"}], "new_edits":false}'
      []
      
      $ curl -X GET 'http://127.0.0.1:5984/test/_all_docs?include_docs=true&conflicts=true'
      {"total_rows":1,"offset":0,"rows":[
      {"id":"foo","key":"foo","value":{"rev":"1-a2"},"doc":{"_id":"foo","_rev":"1-a2","_conflicts":["1-a1"]}}
      ]}
      
      $ curl -X POST 'http://127.0.0.1:5984/test/_all_docs?include_docs=true&conflicts=true' -H 'Content-type:application/json' -d '{"keys":["foo"]}'
      {"total_rows":1,"offset":0,"rows":[
      {"id":"foo","key":"foo","value":{"rev":"1-a2"},"doc":{"_id":"foo","_rev":"1-a2","_conflicts":["1-a1"]}}
      ]}
      

      In CouchDB 2.0:

      $ curl -X PUT http://127.0.0.1:15984/test
      {"ok":true}
      
      $ curl -X POST http://127.0.0.1:15984/test/_bulk_docs -H 'Content-type:application/json' -d '{ "docs":[{"_id":"foo","_rev": "1-a1"},{"_id":"foo","_rev": "1-a2"}], "new_edits":false}'
      []
      
      $ curl -X GET 'http://127.0.0.1:15984/test/_all_docs?include_docs=true&conflicts=true'
      {"total_rows":1,"offset":0,"rows":[
      {"id":"foo","key":"foo","value":{"rev":"1-a2"},"doc":{"_id":"foo","_rev":"1-a2","_conflicts":["1-a1"]}}
      ]}
      
      $ curl -X POST 'http://127.0.0.1:15984/test/_all_docs?include_docs=true&conflicts=true' -H 'Content-type:application/json' -d '{"keys":["foo"]}'
      {"total_rows":1,"rows":[
      {"id":"foo","key":"foo","value":{"rev":"1-a2"},"doc":{"_id":"foo","_rev":"1-a2"}}
      ]}
      

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user willholley opened a pull request:

          https://github.com/apache/couchdb-fabric/pull/81

          Include conflicts parameter in doc_options

          When a keys array is passed to _all_docs, fabric translates this
          to individual open_doc calls. The conflicts=true query parameter is
          specified as a view-level option and is not, by default, parsed as
          an option that should be passed to open_doc.

          As a workaround, explicitly copy the view-level conflict parameter into
          the document options before open_doc is called.

          An alternative approach would be to address this when the query
          parameters are parsed, setting conflicts=true in both #mrargs and
          detail of fabric, I elected to make the change here instead.

          Fixes #COUCHDB-3264

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/willholley/couchdb-fabric 3264-alldocs-keys-conflicts

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/couchdb-fabric/pull/81.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #81


          commit 22f6a3e7d58548b156a01f7321a41ae8aea739ec
          Author: Will Holley <willholley@gmail.com>
          Date: 2017-01-03T09:54:30Z

          Include conflicts parameter in doc_options

          When a keys array is passed to _all_docs, fabric translates this
          to individual open_doc calls. The conflicts=true query parameter is
          specified as a view-level option and is not, by default, parsed as
          an option that should be passed to open_doc.

          As a workaround, explicitly copy the view-level conflict parameter into
          the document options before open_doc is called.

          An alternative approach would be to address this when the query
          parameters are parsed, setting conflicts=true in both #mrargs and
          detail of fabric, I elected to make the change here instead.

          Fixes #COUCHDB-3264


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user willholley opened a pull request: https://github.com/apache/couchdb-fabric/pull/81 Include conflicts parameter in doc_options When a keys array is passed to _all_docs, fabric translates this to individual open_doc calls. The conflicts=true query parameter is specified as a view-level option and is not, by default, parsed as an option that should be passed to open_doc. As a workaround, explicitly copy the view-level conflict parameter into the document options before open_doc is called. An alternative approach would be to address this when the query parameters are parsed, setting conflicts=true in both #mrargs and detail of fabric, I elected to make the change here instead. Fixes # COUCHDB-3264 You can merge this pull request into a Git repository by running: $ git pull https://github.com/willholley/couchdb-fabric 3264-alldocs-keys-conflicts Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-fabric/pull/81.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #81 commit 22f6a3e7d58548b156a01f7321a41ae8aea739ec Author: Will Holley <willholley@gmail.com> Date: 2017-01-03T09:54:30Z Include conflicts parameter in doc_options When a keys array is passed to _all_docs, fabric translates this to individual open_doc calls. The conflicts=true query parameter is specified as a view-level option and is not, by default, parsed as an option that should be passed to open_doc. As a workaround, explicitly copy the view-level conflict parameter into the document options before open_doc is called. An alternative approach would be to address this when the query parameters are parsed, setting conflicts=true in both #mrargs and detail of fabric, I elected to make the change here instead. Fixes # COUCHDB-3264
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 8dcc3fb175807ac18a3d7c1fc95364910ee8969e in couchdb-fabric's branch refs/heads/master from Will Holley
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb-fabric.git;h=8dcc3fb ]

          Include conflicts parameter in doc_options

          When a keys array is passed to _all_docs, fabric translates this
          to individual open_doc calls. The conflicts=true query parameter is
          specified as a view-level option and is not, by default, parsed as
          an option that should be passed to open_doc.

          As a workaround, explicitly copy the view-level conflict parameter into
          the document options before open_doc is called.

          An alternative approach would be to address this when the query
          parameters are parsed, setting conflicts=true in both #mrargs and
          detail of fabric, I elected to make the change here instead.

          Fixes #COUCHDB-3264

          Show
          jira-bot ASF subversion and git services added a comment - Commit 8dcc3fb175807ac18a3d7c1fc95364910ee8969e in couchdb-fabric's branch refs/heads/master from Will Holley [ https://git-wip-us.apache.org/repos/asf?p=couchdb-fabric.git;h=8dcc3fb ] Include conflicts parameter in doc_options When a keys array is passed to _all_docs, fabric translates this to individual open_doc calls. The conflicts=true query parameter is specified as a view-level option and is not, by default, parsed as an option that should be passed to open_doc. As a workaround, explicitly copy the view-level conflict parameter into the document options before open_doc is called. An alternative approach would be to address this when the query parameters are parsed, setting conflicts=true in both #mrargs and detail of fabric, I elected to make the change here instead. Fixes # COUCHDB-3264
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/couchdb-fabric/pull/81

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/couchdb-fabric/pull/81

            People

            • Assignee:
              Unassigned
              Reporter:
              wilhol Will Holley
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development