Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B8DEDC849 for ; Thu, 27 Jun 2013 14:55:03 +0000 (UTC) Received: (qmail 52963 invoked by uid 500); 27 Jun 2013 14:55:02 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 52921 invoked by uid 500); 27 Jun 2013 14:55:02 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 52913 invoked by uid 99); 27 Jun 2013 14:55:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jun 2013 14:55:01 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of dch@jsonified.com designates 209.85.215.48 as permitted sender) Received: from [209.85.215.48] (HELO mail-la0-f48.google.com) (209.85.215.48) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jun 2013 14:54:55 +0000 Received: by mail-la0-f48.google.com with SMTP id lx15so927411lab.21 for ; Thu, 27 Jun 2013 07:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jsonified.com; s=google; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=u+VqgI5rgOEQhQLsYyR0nQZQv622IwEu+UgpiApV2ik=; b=ff9HTXWqWvHF21M1kN3dMLqOkFfB4Q5t6+FMJZdWQyY+++yksDxauda7GsirfjAB7S BZm34FTNXMO2j8MiQFEk/oifzBVqcJ1Sx42Ax5B7YLiXXXIDKTUimmifY4dJvGUue7D1 OeNMe9h4CUCmYIphQx1tvvjkTHapKxRqIXPMw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding :x-gm-message-state; bh=u+VqgI5rgOEQhQLsYyR0nQZQv622IwEu+UgpiApV2ik=; b=LtwdUO+fqyxnqYdPlBzFMIYHEu27ETcTI3uWt+bpiobQqZLXjKV0D/jE9hImyYoxuK accd2S0pVW8hbKLBtxzSY7vYavAxaKFlhePbtNLqNMt4VWs9BWBF/QrBEkHlOH+Q5XBD orMiHWSsoCf/JN1JrFTkViyfB/eweXcBEP3SDeQmVWTgO0S0PspEB2ieQ9UH98N+jQPM hOq0DQzCvhTy2marrUDcvzM1UonTMHcwesZK/DfzdvII3r3G+rRuXdCmWyJJSwS4/WEq 1prQSWomL9WRt/aTUKQgSGtQ67ZqEeoVYIKBAiyKA9WWZqPolT+eel/8yaBqYNHMhesu BYgQ== MIME-Version: 1.0 X-Received: by 10.152.23.99 with SMTP id l3mr4313662laf.82.1372344874996; Thu, 27 Jun 2013 07:54:34 -0700 (PDT) Received: by 10.112.97.230 with HTTP; Thu, 27 Jun 2013 07:54:34 -0700 (PDT) X-Originating-IP: [84.112.19.176] In-Reply-To: <2122761033.41746.1372343884015.JavaMail.root@tpip.net> References: <2122761033.41746.1372343884015.JavaMail.root@tpip.net> Date: Thu, 27 Jun 2013 16:54:34 +0200 Message-ID: Subject: Re: {case_clause,{error,[],function_clause}} in CouchDb-1.2.0 From: Dave Cottlehuber To: user@couchdb.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQnVuj29thVLHDCbZqAKA1d3rcF1hUfn8TjJuDWcmXtmeFu+Oo7JSH7C5ICJgN6BwqbvlE5g X-Virus-Checked: Checked by ClamAV on apache.org On 27 June 2013 16:38, Alexander Kuleshov wrote: > Hello, > > I'm trying to use Couchdb-1.2.0 with Couchbeam. > > I create database, documents and etc... > > I have a view: > > { > "_id": "_design/task", > "_rev": "1-0ba3c64c158deb66749cf23aaee9e855", > "language": "erlang", > "views": { > "by_task_creation": { > "map": "fun({Doc}) ->\n\tcase couch_util:get_value(<<\"_id\">>= , Doc, null) of\n\t TaskId =3D <<\"task:\", _/binary>> ->\n\t\tcase couc= h_util:get_value(<<\"created\">>, Doc, null) of\n\t\t null -> ok;\n\t\t = Created -> Emit(Created, null)\n\t\tend;\n\t _ -> ok\n\tend\nend.\n", > "reduce": "fun(_Keys, Values, false) -> length(Values);\n (_= Keys, Values, true) -> lists:sum(Values) end.\n" > }, > "by_task_selector": { > "map": "fun({Doc}) ->\n\tcase couch_util:get_value(<<\"_id\">>= , Doc, null) of\n\t TaskId =3D <<\"task:\", _/binary>> ->\n\t\tcase couc= h_util:get_value(<<\"selector\">>, Doc, null) of\n\t\t null -> ok;\n\t\t= Selector -> Emit(Selector, TaskId)\n\t\tend;\n\t _ -> ok\n\tend\nend= .\n" > } > } > } > > But when i'm trying to fetch it i got error: > > {case_clause,{error,[],function_clause}} > > I'm trying with: couchbeam_view:fetch(DB, {<<"_design/task">>, <<"by_task= _creation">>}, [{reduce, true}]) > > How can i make it correctly? > > Thank you. case_clause is a runtime error telling you that your erlang function doesn't match all cases encountered. Add a default case in and you should be fine. I'm not trying to decipher the \n\t\tunread\table\n\t\tcontent above but if you start couchdb in interactive mode `couchdb -i` then you can test stuff in the shell very easily: where you'll need to update the "=85" stuff obviously. rr("/repos/couch/git/src/couchdb/*.hrl"). rr("/repos/couch/git/src/couch_mrview/include/*.hrl"). {ok, Db} =3D couch_db:open_int(<<"somedb">>, []). {ok, Doc} =3D couch_db:open_doc(Db, <<"somedocid">>). Body =3D couch_doc:with_ejson_body(Doc). may also be useful. and then call your fun on these docs to see what's happening. If you `couch_config:set("log","level","debug").` prior to triggering a view rebuild, you will probably see what doc this is failing on in the logs. Most commonly people forget that databases contain ddocs and don't account for that in the view. A+ Dave