couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <robert.new...@gmail.com>
Subject Re: Strange behaviour with Erlang views
Date Thu, 20 Jan 2011 12:23:11 GMT
That doesn't compile for me;

1> Fun = fun(Keys, Values,ReReduce) ->  if true -> 17 end.
* 1: syntax error before: '.'
1> Fun = fun(Keys, Values,ReReduce) -> 17 end.
#Fun<erl_eval.18.105910772>

B.

On Thu, Jan 20, 2011 at 11:40 AM,  <j.kalsbach@jk-itberatung.de> wrote:
>
> 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.
> Couch.log:
> ...
> [{view,0,
>                             [<<"_temp">>],
>                             <<"\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>>,
V)\nend.\n\n">>,
>                             nil,
>                             [{<<"_temp">>,
>                               <<"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: \",\"'.'\"]}">>]},
>    [{couch_query_servers,os_reduce,3},
>     {couch_query_servers,reduce,3},
>     {couch_view_group,'-init_group/4-fun-0-',4},
>     {couch_btree,'-write_node/3-lc$^0/1-0-',3},
>     {couch_btree,write_node,3},
>     {couch_btree,modify_node,4},
>     {couch_btree,query_modify,4},
>     {couch_btree,add_remove,3}]}
>
> 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,
>
> Jörg
>
>

Mime
View raw message