Export to GitHub

couchdb4j - issue #5

AdHoc view failing


Posted on Jan 9, 2008 by Happy Giraffe

What steps will reproduce the problem? 1. Use latest couchdb from svn (0.7.2) and latest couchdb4j 2. Execute the AdHoc view in the given example on the couchdb4j wiki

What is the expected output? What do you see instead? I expect a view result, instead it is null and there is an error in the couchdb console: HTTP Error (code 500): {obj,[{error,"query_language_unknown"}, {reason,"application/json"}]}

What version of the product are you using? On what operating system? couchdb4j-read-only from svn on Ubuntu 6.10, Sun jdk 1.5

Please provide any additional information below. Looking at the docs for couchdb it appears that the content type for a view should be text/javascript. I added a specific method in Session.java to use a different content type and this fixed the problem.

Comment #1

Posted on Jan 9, 2008 by Happy Giraffe

I'm really sorry about this - must look at past issues more carefully! Got the patch now!

Comment #2

Posted on Feb 17, 2008 by Grumpy Rhino

Is there a patch? I changed the source to make requests with URL containgin "_temp_view" to use text/javascript as Content-type instead of default application/json (see http://code.google.com/p/couchdb4j/source/browse/trunk/src/java/com/fourspaces/couchdb/Session.java#276 revision 23).

  • entity = new StringRequestEntity(content, "application/json","UTF-8");
  • // ad hoc view's are sent as a single javascript function
  • if (url.indexOf("_temp_view") != -1) {
  • entity = new StringRequestEntity(content, "text/javascript","UTF-8");
  • } else {
  • entity = new StringRequestEntity(content, "application/json","UTF-8");
  • }

Comment #3

Posted on Apr 11, 2008 by Helpful Elephant

I've added the code from fred above to Session.java .

Mind making sure that this work?

Status: Accepted

Labels:
Type-Defect Priority-Medium