Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 23749 invoked from network); 11 May 2010 19:36:26 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 May 2010 19:36:26 -0000 Received: (qmail 86169 invoked by uid 500); 11 May 2010 19:36:25 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 86142 invoked by uid 500); 11 May 2010 19:36:25 -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 86134 invoked by uid 99); 11 May 2010 19:36:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 May 2010 19:36:25 +0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=AWL,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [66.46.182.57] (HELO relay.ihostexchange.net) (66.46.182.57) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 May 2010 19:36:21 +0000 Received: from VMBX122.ihostexchange.net ([192.168.40.2]) by hub107.ihostexchange.net ([66.46.182.57]) with mapi; Tue, 11 May 2010 15:35:53 -0400 From: Mike Keen To: "user@couchdb.apache.org" Date: Tue, 11 May 2010 15:35:48 -0400 Subject: Re: Strange integer anomaly in Erlang view Thread-Topic: Strange integer anomaly in Erlang view Thread-Index: AcrxQSsIM2/Zrk5YRSuk7t5vD2lx8g== Message-ID: <10462DA3-AC32-4B4A-A8AD-A9A781C9A7C9@visiture.com> References: <0B8367C6-CECE-48FB-AE62-1C270DE70221@visiture.com> <059B0C98-2D2F-4F09-A867-4D6ABFB1C335@apache.org> <41ECF4E0-5FD5-4F46-8144-6D6770415676@apache.org> In-Reply-To: <41ECF4E0-5FD5-4F46-8144-6D6770415676@apache.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cheers! I was just hacking around. On May 11, 2010, at 3:29 PM, Adam Kocoloski wrote: > Correct version: >=20 > [Emit(proplists:get_value(<<"id">>, Campaign, null), {Campaign}) || {Camp= aign} <- AdwordsCampaigns]; >=20 > But you get the idea. >=20 > On May 11, 2010, at 3:23 PM, Adam Kocoloski wrote: >=20 >> Hi Mike, are you sure this is what you want? >>=20 >>> [Emit(proplists:get_value(<<"id">>, StrippedCampaign, null), Campaig= n) || Campaign <- AdwordsCampaigns, {StrippedCampaign} <- AdwordsCampaigns]= ; >>=20 >> Try it in the emulator >>=20 >> 1> Foo =3D [1,2,3]. >> [1,2,3] >> 2> [{X,Y} || Y <- Foo, X <- Foo]. >> [{1,1},{2,1},{3,1},{1,2},{2,2},{3,2},{1,3},{2,3},{3,3}] >>=20 >> You're generating combinatoric pairs of all elements of AdwordsCampaigns= , pulling the key from the first element of the pair and the value from the= second part of the pair. Perhaps you're looking for this instead? >>=20 >> [Emit(proplists:get_value(<<"id">>, Campaign, null), {Campaign}) || Camp= aign <- AdwordsCampaigns]; >>=20 >> Best, Adam >>=20 >> On May 11, 2010, at 2:58 PM, Mike Keen wrote: >>=20 >>> You're right. In the value column, the id shows up as 50573744 which is= the correct value. In the key column, it shows up as 53518364. >>>=20 >>> On May 11, 2010, at 2:44 PM, Randall Leeds wrote: >>>=20 >>>> On Tue, May 11, 2010 at 11:40, Jarrod Roberson wrote: >>>>> On Tue, May 11, 2010 at 2:31 PM, Mike Keen wrote: >>>>>=20 >>>>>> I guess I'm confused as to why JavaScript is ever even involved when >>>>>> writing views in Erlang. Excuse my ignorance, but does all JSON go t= hrough >>>>>> it? >>>>>>=20 >>>>>> Mike >>>>>>=20 >>>>>> read all the comments to that bug report, it is the JSON parser that >>>>> conforms to the limitations of JavaScript. And everything goes thru t= he JSON >>>>> parser. >>>>>=20 >>>>=20 >>>> I think we're missing the point. Even if the erlang JSON parser >>>> conforms to JSON's notion of numbers then I'd expect the id to be >>>> transformed the same way for both the key and the value. >>>>=20 >>>> Maybe the key is implicitly treated as a string? Mike, which is the >>>> "correct" value for the id? >>>=20 >>=20 >=20