[orm-devel] Introduction, thanks and a couple of comments on the 0.7 release
Fri, 6 Dec 2002 12:28:42 +0100
actually you were right about this:
>># float point quantities
>>float, floatColumn = _float, _floatColumn
>>numeric, numericColumn = _float, _floatColumn
>No, that's not the way I wanted to go. The PostgreSQL NUMBERIC type
>is for arbitrary precision quanteties, see, the the Python float type
>has 64 bit (I think). 64 bit's pretty large, but it's not arbitrary.
>I was going to use the egenix-experimental mx.Number class to
>represent arbitrary numerals in ORM. The problem is, it doesn't
>compile out-of-the-box on my maching (MacOSX).
psycopg returns NUMERIC columns as floats. It does not make sense at
all to let orm use mx.Number.Float, because on the way back from the
database the numbers get converted to Python floats.
I have added a line
numeric, numericColumn = float, floatColumn
to adapters.pgsql.columns that should do the job.
As you know a float point number is not what you want to use for
monetary arithmetic. You might want to use integers describing the
number of cents or PostgreSQL's MONEY type. The latter, btw, comes
back as a string from the database like this:
but at least the SQL internal math should work.
Perhaps it would make sense to create a money datatype that implements
Python's number interface i.e. has __add__, __sub__ etc. Methods so
it can be used just like normal numbers in Python.
_..._ Diedrich Vorberg
/ _ _ \ http://www.tux4web.de
| (o)_(o) | email@example.com
\( ) / .---.
//'._.'\ \ / \ Internet Dienstleistungen
// . \ \ \.@-@./ und 'Consulting'.
|| . \ \ /`\_/`\
|\ : / | // _ \\ Linux Rules!
\ `) ' (` /_ | \ )|_
_)``".____,.'"` (_ /`\_`> <_/ \
) )'--'( ( \__/'---'\__/