[Zope] ZSQL Method against Postgresql returns int

Jim Penny jpenny@universal-fasteners.com
Mon, 18 Feb 2002 16:39:46 -0500


On Mon, Feb 18, 2002 at 04:22:13PM -0500, Bryan C. Andregg wrote:
> On Mon, Feb 18, 2002 at 04:16:40PM -0500, Jim Penny mailed:
> > On Mon, Feb 18, 2002 at 02:13:26PM -0500, Bryan C. Andregg wrote:
> > > I have a table in a postgresql database that is type float. Querying this
> > > table through a ZSQL Method returns the values of that row as an int.
> > 
> > Is it float, or is it fixed?
> 
> Actually, it's NUMERIC.
> -- 
> Bryan C. Andregg		Duke University Medical Center
>  Programmer			Dept. of Anesthesiology
>  e <bryan.andregg@duke.edu>
>  p +1 919 684 6201

In PoPyMoodule.c at line 93 or thereabouts, you should see
case POPY_NUMERIC.  Cut and paste this from here to line
132 or so.  That is, you want to move POPY_NUMERIC from being
one of the cases that falls into res = PyInt_FromLong(...
to being one of cases that falls into PyFloat_FromDouble(...

Recompile.   It will then work.  Note:  python2.1 and python2.2
exhibit different behavior than python1.5.  In python1.5, if you
had 2.10 stored, the result would be displayed as 2.1.  In the 2.x
family it will be displayed as something like 2.100000001.  Make sure
you pass it through your own formatting routine before displaying.

Jim Penny