-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Array parser drops decimal section of double precision values #131
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
Comments
Yeah that is an ugly bug. Could you possibly include a sample of failing code? I'll try to get this fixed asap. |
Here is a simple test for the situation (modified CREATE TEMP/INSERT INTO and added test in array-tests.js): var helper = require(__dirname + "/test-helper");
var pg = helper.pg;
test('parsing array results', function() {
pg.connect(helper.config, assert.calls(function(err, client) {
assert.isNull(err);
client.query("CREATE TEMP TABLE why(names text[], numbors integer[], decimals double precision[])");
client.query('INSERT INTO why(names, numbors, decimals) VALUES(\'{"aaron", "brian","a b c" }\', \'{1, 2, 3}\', \'{.1, 0.05, 3.654}\')').on('error', console.log);
...
test('decimals', function() {
// client.connection.on('message', console.log)
client.query('SELECT decimals FROM why', assert.success(function(result) {
assert.lengthIs(result.rows[0].decimals, 3);
assert.equal(result.rows[0].decimals[0], 0.1);
assert.equal(result.rows[0].decimals[1], 0.05);
assert.equal(result.rows[0].decimals[2], 3.654);
}))
})
...
}))
}) |
brianc
pushed a commit
that referenced
this issue
Dec 27, 2019
If an error not related to the query occurs, the client is emitting an error event. Forward this event to the callback.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
parseIntegerArray
function is used for both integer and float value parsing.This isn't working for actual decimal numbers, since parseInt is used:
This is related to the pull request #96.
One possible fix could be checking, if the string contains "." and using parseFloat instead:
Tho, more elegant way would be to write separate
parseFloatArray
function for types 1021, 1022 and 1231.The text was updated successfully, but these errors were encountered: