couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From IOMATIX <ioma...@yahoo.com>
Subject Template Matching
Date Thu, 20 Jan 2011 14:52:24 GMT
How would one go about getting the results of a list merged into a show?

/ Jeff



________________________________
From: Robert Newson <robert.newson@gmail.com>
To: user@couchdb.apache.org
Sent: Thu, January 20, 2011 7:51:45 AM
Subject: Re: Strange behaviour with Erlang views

You want;

fun(Keys, Values,ReReduce) ->  if true -> 17 end end.

You didn't end your if statement, basically.

B.

On Thu, Jan 20, 2011 at 12:22 PM, Filipe David Manana
<fdmanana@apache.org> wrote:
> This:
>
> fun(Keys, Values,ReReduce) ->  if true -> 17 end.
>
> is invalid Erlang.
>
> Have you tried it an Erlang shell?
> You miss the "else" clause likely. Look at section 7.7 of
> http://www.erlang.org/doc/reference_manual/expressions.html
>
> Anyway that logic it seems you always want to return the integer 17.
>
>
>
> 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
>>
>>
>
>
>
> --
> Filipe David Manana,
> fdmanana@gmail.com, fdmanana@apache.org
>
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."
>



      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message