couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Strange behaviour with Erlang views
Date Thu, 20 Jan 2011 11:40:31 GMT

Hi all, I've got a strange problem with Erlang views. I've got a  
simple and useless reduce function which works as expected:
fun(Keys, Values,ReReduce) ->  17 end.
Now I change it to another simple and useless function:
fun(Keys, Values,ReReduce) ->  if true -> 17 end.
The function compiles fine with plain Erlang.
CouchDB complains.
                              <<"\n%% Map Function\nfun({Doc}) ->\n   
<<K,_/binary>> = proplists:get_value(<<\"_rev\">>, Doc, null),\n 
V =  
proplists:get_value(<<\"_id\">>, Doc, null),\n  Emit(<<K>>,  
                                <<"fun(Keys, Values,ReReduce) ->  if  
true -> 17 end.">>}],
** Reason for termination ==
** {{try_clause,[<<"error">>,<<"native_query_server">>,
                  <<"couch native server error: {1,erl_parse,[\"syntax  
error before: \",\"'.'\"]}">>]},

It seems that the native_query_server has problems with valid syntax.  
Originally I wanted to write a group by function where I need if or  
case to react on ReReduce or not.
Does anyone has an idea what went wrong?

Many thanks in advance,


View raw message