Re: BUG #8676: Bug Money JSON

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: BUG #8676: Bug Money JSON
Дата
Msg-id 52B078E8.5020707@dunslane.net
обсуждение исходный текст
Ответ на Re: BUG #8676: Bug Money JSON  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: BUG #8676: Bug Money JSON  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-bugs
On 12/17/2013 10:31 AM, Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
>>> On Wed, Dec 11, 2013 at 02:30:04PM +0000, email@andersonloyola.com.br wrote:
>>>> postgres=# SELECT to_json(a) FROM (VALUES(1000::money)) a(salario);
>>>> to_json
>>>> -----------------------
>>>> {"salario":$1,000.00}
>>>> (1 row)
>> 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.
> Isn't this simply failure to quote the string properly?  What drives
> to_json's choice of whether to quote or not, anyway?
>
>


If it's numeric, it only quotes if it sees a non-numeric character,
defined thus:

    /* letters appearing in numeric output that aren't valid in a JSON
    number */
    #define NON_NUMERIC_LETTER "NnAaIiFfTtYy"


I forgot about money when I did that - some of this dates back to 9.2.

I'm about to test the attached patch which should force money to be
quoted always.

cheers

andrew




Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #8676: Bug Money JSON
Следующее
От: Sandeep Thakkar
Дата:
Сообщение: Re: permission issues with PostgreSQL 9.2 EnterpriseDB one-click installer on windows 7 causes initcluster to fail