Re: Money casting too liberal?

From: ajmcello <ajmcello78(at)gmail(dot)com>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Money casting too liberal?
Date: 2013-03-31 03:41:31
Message-ID: CANuED-Mk-hCQOVkj4=f5qPgzwNxL9ir4efxS5M=CF+37L5AOuQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

unsubscribe

On Wed, Mar 27, 2013 at 3:12 PM, Steve Crawford <
scrawford(at)pinpointresearch(dot)com> wrote:

> In contrast to certain other open-source databases, PostgreSQL leans
> toward protecting data from surprises and erroneous input, i.e. rejecting a
> date of 2013-02-31 instead of arbitrarily assigning a date of 2013-03-03.
> Similar "throw error" instead of "take a guess" philosophy applies to
> numeric and string operations as well. It's an approach I appreciate.
>
> But it appears that the philosophy does not extend to the "money" type.
> Although there are certain checks including no alpha, '$' and '-', if
> present, must be in the first two characters of the string and commas can't
> be at the end. Otherwise the casting is fairly liberal. Commas, for
> instance, can appear nearly anywhere including after the decimal point:
>
> select ',123,456,,7,8.1,0,9'::money;
> money
> ----------------
> $12,345,678.11
>
> Somewhat more worrisome is the fact that it automatically rounds input
> (away from zero) to fit.
>
> select '123.456789'::money;
> money
> ---------
> $123.46
>
> select '$-123.456789'::money;
> money
> ----------
> -$123.46
>
> Thoughts? Is this the "no surprises" way that money input should behave?
>
> Cheers,
> Steve
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/**mailpref/pgsql-general<http://www.postgresql.org/mailpref/pgsql-general>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message ajmcello 2013-03-31 03:42:09 Re: Regular function
Previous Message ajmcello 2013-03-31 03:40:34 Re: Regular function