[JCBC-150] "Failed to access the view" error when querying a view with reduce Created: 19/Nov/12 Updated: 27/Nov/12 Resolved: 27/Nov/12 |
|
| Status: | Resolved |
| Project: | Couchbase Java Client |
| Component/s: | library |
| Affects Version/s: | 1.1-dp4 |
| Fix Version/s: | None |
| Security Level: | Public |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Chris Tashjian | Assignee: | Michael Nitschinger |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Attempting to make a call to CouchbaseClient.query(view, query) with a view that has a reduce (even just "_count") results in the following exception when results are returned:
java.lang.RuntimeException: Failed to access the view at com.couchbase.client.CouchbaseClient.query(CouchbaseClient.java:634) Worth noting: - If the query returns no results (ViewResponse.size() returns 0), you do not get the exception... - If the reduce method is removed from the view, everything works fine. However, using query.setReduce(false) does not work. |
| Comments |
| Comment by Michael Nitschinger [ 20/Nov/12 ] |
|
Hi Chris,
thanks for the report. I'll investigate and let you know! Thanks, Michael |
| Comment by Michael Nitschinger [ 21/Nov/12 ] |
|
Please make sure to use setReduce(true) and .setReduce(false) explicitely on a view with a reduce function right now.
The following code works with setReduce(true) and false, but will throw the exception you mentioned when setReduce is not used at all: query = new Query(); //query.setReduce(false); view = client.getView(DESIGN_DOC_W_REDUCE, VIEW_NAME_W_REDUCE); reduce = client.query(view, query); itr = reduce.iterator(); while(itr.hasNext()) { ViewRow row = itr.next(); System.out.println(row.getKey()); } |
| Comment by Michael Nitschinger [ 21/Nov/12 ] |
|
After more investigation, this is really a shortcoming and should be handled in this changeset:
http://review.couchbase.org/#/c/22710/ It makes sure that reduce = true when nothing is set and the view contains a reduce function. The exception was misleading because it covered a JSON parsing bug underneath. |
| Comment by Michael Nitschinger [ 27/Nov/12 ] |
| fixed and pushed to master; will be available in dp5/beta. |