Re: [DOCS] Failing example for to_number()

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [DOCS] Failing example for to_number()
Дата
Msg-id CAKFQuwaWwR5P8U3Y8C3FSfXHVeBgkLG1utG0g8vb5jSx_swX5g@mail.gmail.com
обсуждение исходный текст
Ответ на [DOCS] Failing example for to_number()  (Erwin Brandstetter <brsaweda@gmail.com>)
Ответы Re: [DOCS] Failing example for to_number()  (Erwin Brandstetter <brsaweda@gmail.com>)
Список pgsql-docs
On Mon, Aug 21, 2017 at 5:36 AM, Erwin Brandstetter <brsaweda@gmail.com> wrote:
The manual suggests here:

https://www.postgresql.org/docs/current/static/functions-formatting.html#FUNCTIONS-FORMATTING-TABLE

> to_number(text, text) |  numeric convert string to numeric | to_number ('12,454.8-', '99G999D9S')

The example fails for locales where the comma (',') does not happen to be the group separator and the dot ('.') is not the decimal point.

The example is incorrectly assuming en_US locale. It must instead work locale-agnostic. Replace:

to_number ('12,454.8-', '99G999D9S')

with:

to_number ('12,454.8-', '99,999.9S')


​I can see the appeal of demonstrating the locale-dependent G and D symbols so that a user becoming familiar with the feature knows that they have options other than just writing out the comma and period literally.  If one wants to try the example in a language other than in which the example was written they should modify it so that the literal number being parsed in written in conformance to the locale definition for the language you are using.

David J.

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

Предыдущее
От: Erwin Brandstetter
Дата:
Сообщение: [DOCS] Failing example for to_number()
Следующее
От: Erwin Brandstetter
Дата:
Сообщение: Re: [DOCS] Failing example for to_number()