incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Barnes <>
Subject Suspected view generator bug...
Date Fri, 19 Feb 2010 05:30:39 GMT
I was tearing my hair out because this view:

map: function(doc) {
	if (doc.doc_type=='group') {
		emit(doc.path, doc.display_name);

Was supposed to take one element off the end of the path array and using 
the array as a view key. However, when I triggered view creation it 
would remove TWO elements!

Strangely, if I opened the view function from within futon, added some 
whitespace and re-ran the function it worked fine.

There are two similar views that both use the doc.path.pop() call.
I'm fairly confident that behind the scenes, the couchdb (trunk) view 
generator is
a) sharing a single copy of each document between all the map functions.
b) permitting map functions to modify that copy, meaning that subsequent 
map functions might get a CORRUPTED version of the document.


For now, I've rewritten my map functions to clone the array to a local 
var before I call path.pop().

-Patrick Barnes

View raw message