Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vsvsa-00023g-V0 for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Dec 2013 14:44:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VsvsZ-0003e5-W1 for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Dec 2013 14:44:12 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VsvsY-0003dy-TA for pgsql-bugs@postgresql.org; Tue, 17 Dec 2013 14:44:11 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VsvsV-0003Xl-B4 for pgsql-bugs@postgresql.org; Tue, 17 Dec 2013 14:44:09 +0000 Received: from mfilter29-d.gandi.net (mfilter29-d.gandi.net [217.70.178.160]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 2A6701720BD; Tue, 17 Dec 2013 15:44:03 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter29-d.gandi.net Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter29-d.gandi.net (mfilter29-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id gXoAhTTgkmLA; Tue, 17 Dec 2013 15:44:02 +0100 (CET) X-Originating-IP: 98.27.58.255 Received: from [192.168.10.146] (cpe-098-027-058-255.nc.res.rr.com [98.27.58.255]) (Authenticated sender: adsend@dunslane.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id C522A17207C; Tue, 17 Dec 2013 15:44:01 +0100 (CET) Message-ID: <52B06330.1010503@dunslane.net> Date: Tue, 17 Dec 2013 09:44:00 -0500 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bruce Momjian CC: email@andersonloyola.com.br, pgsql-bugs@postgresql.org Subject: Re: BUG #8676: Bug Money JSON References: <20131217141021.GA19059@momjian.us> In-Reply-To: <20131217141021.GA19059@momjian.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 12/17/2013 09:10 AM, Bruce Momjian wrote: > On Wed, Dec 11, 2013 at 02:30:04PM +0000, email@andersonloyola.com.br wrote: >> The following bug has been logged on the website: >> >> Bug reference: 8676 >> Logged by: Anderson Cristian da Silva >> Email address: email@andersonloyola.com.br >> PostgreSQL version: 9.3.2 >> Operating system: Centos 6.3 (Final) >> Description: >> >> Failed to convert money to json EX.: >> >> >> postgres=# SELECT to_json(a) FROM (VALUES(1000::money)) a(salario); >> to_json >> ----------------------- >> {"salario":$1,000.00} >> (1 row) >> >> >> postgres=# SELECT to_json(a)->'salario' FROM (VALUES(1000::money)) >> a(salario); >> ERROR: invalid input syntax for type json >> DETAIL: Token "$" is invalid. >> CONTEXT: JSON data, line 1: {"salario":$... > Well, that is very interesting. It works for integer and text, and it > works if you ask for the entire relation, but if you ask just for that > field _and_ it is money, it fails. Sure looks like a bug to me. Yeah. I'll have a look. In fact this looks like it's possibly a couple of bugs. The JSON produced by the first query is not valid. It looks like we might need to force money to text unconditionally. cheers andrew -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs