diff --git a/org.ektorp/src/main/java/org/ektorp/ViewQuery.java b/org.ektorp/src/main/java/org/ektorp/ViewQuery.java index dab7c928..4a97437e 100644 --- a/org.ektorp/src/main/java/org/ektorp/ViewQuery.java +++ b/org.ektorp/src/main/java/org/ektorp/ViewQuery.java @@ -112,6 +112,7 @@ public void copyTo(KeyOrRawKey other) { private boolean inclusiveEnd = true; private boolean ignoreNotFound = false; private boolean updateSeq = false; + private boolean conflicts = false; private boolean cacheOk = false; @@ -191,6 +192,10 @@ public boolean isUpdateSeq() { return updateSeq; } + public boolean isConflicts() { + return conflicts; + } + public ViewQuery dbPath(String s) { reset(); dbPath = s; @@ -608,6 +613,17 @@ public ViewQuery updateSeq(boolean b) { return this; } + /** + * The conflicts option will include the conflicting revisions for each document. + * @param b the conflicts flag + * @return the view query for chained calls + */ + public ViewQuery conflicts(boolean b) { + reset(); + conflicts = b; + return this; + } + public ViewQuery queryParam(String name, String value) { queryParams.put(name, value); return this; @@ -721,6 +737,11 @@ public URI buildQueryURI() { if(updateSeq) { query.param("update_seq", "true"); } + + if (conflicts) { + query.param("conflicts", "true"); + } + return query; } @@ -752,6 +773,7 @@ public ViewQuery clone() { copy.startDocId = startDocId; startKey.copyTo(copy.startKey); copy.updateSeq = updateSeq; + copy.conflicts = conflicts; copy.viewName = viewName; return copy; } @@ -813,6 +835,7 @@ public int hashCode() { result = prime * result + (includeDocs ? 1231 : 1237); result = prime * result + (inclusiveEnd ? 1231 : 1237); result = prime * result + (updateSeq ? 1231 : 1237); + result = prime * result + (conflicts ? 1231 : 1237); result = prime * result + ((key == null) ? 0 : key.hashCode()); result = prime * result + limit; result = prime * result @@ -878,6 +901,8 @@ public boolean equals(Object obj) { return false; if (updateSeq != other.updateSeq) return false; + if (conflicts != other.conflicts) + return false; if (key == null) { if (other.key != null) return false; diff --git a/org.ektorp/src/test/java/org/ektorp/ViewQueryTest.java b/org.ektorp/src/test/java/org/ektorp/ViewQueryTest.java index b9eb3bf1..c037c2fe 100644 --- a/org.ektorp/src/test/java/org/ektorp/ViewQueryTest.java +++ b/org.ektorp/src/test/java/org/ektorp/ViewQueryTest.java @@ -219,7 +219,15 @@ public void update_seq_parameter_added() { .buildQuery(); assertTrue(contains(url, "?update_seq=true")); } - + + @Test + public void conflicts_parameter_added() { + String url = query + .conflicts(true) + .buildQuery(); + assertTrue(contains(url, "?conflicts=true")); + } + @Test public void stale_ok_parameter_added() { String url = query