You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2018/07/13 15:04:58 UTC
[couchdb] branch master updated (71cf9f4 -> 572234f)
This is an automated email from the ASF dual-hosted git repository.
jan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
from 71cf9f4 Adjust deletion tests in different cluster quorum conditions
new 45a0ad9 Add `conflicts: true` option to mango selectors
new 572234f Add tests for mango conflict finding
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/mango/src/mango_cursor_view.erl | 8 ++++----
src/mango/test/19-find-conflicts.py | 41 +++++++++++++++++++++++++++++++++++++
src/mango/test/mango.py | 5 +++++
3 files changed, 50 insertions(+), 4 deletions(-)
create mode 100644 src/mango/test/19-find-conflicts.py
[couchdb] 02/02: Add tests for mango conflict finding
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 572234fb5026ae64ec7f6ed84728f2b1ef63d955
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Fri Jul 13 15:08:46 2018 +0200
Add tests for mango conflict finding
I couldn’t find a cleaner way to add _bulk_docs with
`new_edits: false`.
---
src/mango/test/19-find-conflicts.py | 41 +++++++++++++++++++++++++++++++++++++
src/mango/test/mango.py | 5 +++++
2 files changed, 46 insertions(+)
diff --git a/src/mango/test/19-find-conflicts.py b/src/mango/test/19-find-conflicts.py
new file mode 100644
index 0000000..c6d59f0
--- /dev/null
+++ b/src/mango/test/19-find-conflicts.py
@@ -0,0 +1,41 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+import mango
+import copy
+
+DOC = [
+ {
+ "_id": "doc",
+ "a": 2
+ }
+]
+
+CONFLICT = [
+ {
+ "_id": "doc",
+ "_rev": "1-23202479633c2b380f79507a776743d5",
+ "a": 1
+ }
+]
+
+class ChooseCorrectIndexForDocs(mango.DbPerClass):
+ def setUp(self):
+ self.db.recreate()
+ self.db.save_docs(copy.deepcopy(DOC))
+ self.db.save_docs_with_conflicts(copy.deepcopy(CONFLICT))
+
+ def test_retrieve_conflicts(self):
+ self.db.create_index(["_conflicts"])
+ result = self.db.find({"_conflicts": { "$exists": True}}, conflicts=True)
+ self.assertEqual(result[0]['_conflicts'][0], '1-23202479633c2b380f79507a776743d5')
+ self.assertEqual(result[0]['_rev'], '1-3975759ccff3842adf690a5c10caee42')
diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py
index 9b6b998..bc12bbc 100644
--- a/src/mango/test/mango.py
+++ b/src/mango/test/mango.py
@@ -95,6 +95,11 @@ class Database(object):
def save_doc(self, doc):
self.save_docs([doc])
+ def save_docs_with_conflicts(self, docs, **kwargs):
+ body = json.dumps({"docs": docs, "new_edits": False})
+ r = self.sess.post(self.path("_bulk_docs"), data=body, params=kwargs)
+ r.raise_for_status()
+
def save_docs(self, docs, **kwargs):
body = json.dumps({"docs": docs})
r = self.sess.post(self.path("_bulk_docs"), data=body, params=kwargs)
[couchdb] 01/02: Add `conflicts: true` option to mango selectors
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 45a0ad9e78bbd5596b58f369ddda44254555755b
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Sun Jul 8 15:48:39 2018 +0200
Add `conflicts: true` option to mango selectors
This allows for using Mango queries for finding docs with conflicts.
Closes #1101
---
src/mango/src/mango_cursor_view.erl | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/mango/src/mango_cursor_view.erl b/src/mango/src/mango_cursor_view.erl
index 1e2108b..dbea36e 100644
--- a/src/mango/src/mango_cursor_view.erl
+++ b/src/mango/src/mango_cursor_view.erl
@@ -70,7 +70,8 @@ explain(Cursor) ->
{end_key, maybe_replace_max_json(Args#mrargs.end_key)},
{direction, Args#mrargs.direction},
{stable, Args#mrargs.stable},
- {update, Args#mrargs.update}
+ {update, Args#mrargs.update},
+ {conflicts, Args#mrargs.conflicts}
]}}].
@@ -283,9 +284,8 @@ apply_opts([{r, RStr} | Rest], Args) ->
NewArgs = Args#mrargs{include_docs = IncludeDocs},
apply_opts(Rest, NewArgs);
apply_opts([{conflicts, true} | Rest], Args) ->
- % I need to patch things so that views can specify
- % parameters when loading the docs from disk
- apply_opts(Rest, Args);
+ NewArgs = Args#mrargs{conflicts = true},
+ apply_opts(Rest, NewArgs);
apply_opts([{conflicts, false} | Rest], Args) ->
% Ignored cause default
apply_opts(Rest, Args);