← Back to team overview

anewt-developers team mailing list archive

[Bug 370360] [NEW] PostgreSQL result: numeric column type

 

Public bug reported:

The 'numeric' column type in a PostgreSQL result is now converted to
float. However, 'numeric' doesn't necessarily mean it is a floating
point value. Doing a SUM() over some BIGINT column also reports a
'numeric' type, and by converting it to a float I've lost precision
information.

I'm not exactly sure what is the best way to handle this. One option
would be to leave it a string, but this isn't very typesafe. Another
option might be to be able to override the types somehow.

There already is a (ugly) way to do this, but I'd say this is a
workaround:

$pq = $db->prepare('SELECT SUM(bigcol) AS sum FROM mytable');
$res = $pq->execute();
$res->data_type['sum'] = 'text';    // override float type
$row = $res->fetch();
$res->free();

At the moment I don't need the precision, so this is not a high priority
for me. But still, this is a flaw.

** Affects: anewt
     Importance: Low
         Status: New

-- 
PostgreSQL result: numeric column type
https://bugs.launchpad.net/bugs/370360
You received this bug notification because you are a member of Anewt
developers, which is subscribed to Anewt.



Follow ups

References