Re: cast from integer to money

Поиск
Список
Период
Сортировка
От Joseph Adams
Тема Re: cast from integer to money
Дата
Msg-id BANLkTinSm_FLWmPoxvK5uTC3yqgxOGottg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: cast from integer to money  (Stephen Frost <sfrost@snowman.net>)
Ответы Re: cast from integer to money  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On Thu, Mar 31, 2011 at 6:39 PM, Stephen Frost <sfrost@snowman.net> wrote:
> Going just integer->money, with the "1" -> "$1.00", seems completely
> reasonable to me.  As for being too late in the cycle..  if someone's
> willing to do the work, I can't imagine it breaking anything, so I
> wouldn't be against putting it in.  It really should be before the
> first beta tho.

Attached is a patch which enables casting int2/int4/int8 to money,
with the same scaling as numeric uses.  Hence, 1::money yields '$1.00'
.  The only other numeric types (other than oid, cardinal_number,
etc.) that can't be casted directly to money are float4 and float8,
and I suspect this is intentional.

The patch includes tests, but does not update the documentation.
Should the docs be updated where it reads "Values of the numeric data
type can be cast to money. Other numeric types can be converted to
money by casting to numeric first" ?

Because this change adds rows to the pg_proc and pg_cast catalogs,
applying this patch for 9.1 will require alpha users to initdb again.
Is that acceptable?


Regards,
Joey Adams

Вложения

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

Предыдущее
От: Darren Duncan
Дата:
Сообщение: Re: Postgres 9.1 - Release Theme
Следующее
От: Rushabh Lathia
Дата:
Сообщение: Re: postgres.exe has encountered a problem on windows