brianc/node-postgres — Issue #93: arrays of floats return as strings
Author: chowey
Created: 2012-02-09 18:27:14+00:00
State: open

There is something wrong with the array parser in pg. It works great when postgres returns strings or integers, but it breaks when pg returns floats.

Try the following example:

```javascript
var pg = require('pg'),
db = 'pg://user:pass@localhost/db',
sql = 'SELECT array_agg(column1) AS foo FROM (VALUES(1.),(2.),(3.)) AS bar';

pg.connect(db, function (err, client) {
client.query(sql, function (err, result) {
var foo = result.rows[0].foo;
console.log(foo);
console.log(foo[0]);
console.log(foo[1]);
console.log(foo[2]);
});
});
```

I would *expect* this result:

[ 1, 2, 3 ]
1
2
3

but I *actually* get this result:

{1,2,3}
{
1
,

pg is obviously returning the array as a string, not an array. Note that the above example works fine if you use integers or strings in the VALUES clause. It just fails for floats.