Re: Python interface and Money? - Mailing list pgsql-interfaces

From Peter Eisentraut
Subject Re: Python interface and Money?
Date
Msg-id Pine.LNX.4.30.0110250005550.647-100000@peter.localdomain
Whole thread Raw
In response to Re: Python interface and Money?  (Thomas Lockhart <lockhart@fourpalms.org>)
List pgsql-interfaces
Thomas Lockhart writes:

> ...
> > > While browsing the mailing list for an answer to this problem I found
> > > several references to the money type being deprecated.  Is that the
> > > problem?
> > They keep saying that DECIMAL should be used instead but they are not
> > exactly equivalent.  The MONEY type was originally written with locale
> > support and displays the local currency symbol.
>
> Hmm. If we keep the money type then we should change the internal
> implementation to use numeric or decimal or at least int64 instead of
> int32. Comments?

The purpose of a data type is to store data and attach a semantic value to
it, not to be a tool for presentation.  The money type doesn't even do the
former correctly because when you change the locale, the amount stored
changes.  Since we have a very fine to_char() function, there is no longer
a need for a separate money type, unless you want to have a type that
stores a number plus a currency unit.

Another reason why I personally consider the money type not very useful is
that the very display format it touts makes it a PITA to parse the output
in client applications.

If you want to have a really silly analogy for why the money type is
wrong, imagine a "length" type, that stores a number, and depending on the
current locale, it prints meters or yards.  (Note, it doesn't do the
conversion, it just prints '#### meters' or '#### yards', where #### =
####.)  I presume that most people would consider a length type nonsense
in the first place, but that added feature makes it useless.

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter



pgsql-interfaces by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: Python interface and Money?
Next
From: Michael Meskes
Date:
Subject: Re: ECPG: Automatic Storage allocation for NULL-pointing output variables