Skip to content

arrays of floats return as strings #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chowey opened this issue Feb 9, 2012 · 1 comment
Closed

arrays of floats return as strings #93

chowey opened this issue Feb 9, 2012 · 1 comment

Comments

@chowey
Copy link
Contributor

chowey commented Feb 9, 2012

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:

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.

@chowey
Copy link
Contributor Author

chowey commented Feb 13, 2012

Addressed with #96.

@chowey chowey closed this as completed Feb 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant