brianc / node-pg-types

Type parsing for node-postgres
268 stars 55 forks source link

numeric[] should be parsed via parseStringArray(...) not parseFloatArray(...) #86

Closed sehrope closed 5 years ago

sehrope commented 5 years ago

Arrays of numeric type are registered to be parsed as an arrays of floats whereas the non-array numeric is returned as a string to ensure to no loss of precision:

https://github.com/brianc/node-pg-types/blob/d9d9dfb87eb50914043cbc178c301b7dd3b0c50d/lib/textParsers.js#L189

It should instead return back an array of the string values so the user gets the full value.

This would be a breaking change to anyone previously expecting an array of Numbers.

bendrucker commented 5 years ago

Good point, would appreciate a PR for this

sehrope commented 5 years ago

Yes this shouldn't be much as it's mainly removing special handling so the default string array handling kicks in.

I took a peek at the binary handlers and looks like there's another inconsistency in that case a non-array numeric is returned as a Number: https://github.com/brianc/node-pg-types/blob/d9d9dfb87eb50914043cbc178c301b7dd3b0c50d/lib/binaryParsers.js#L114-L132

Should be a string to match the text format right?

bendrucker commented 5 years ago

Yes that sounds right. @charmander would you be able to take a look and confirm? Noticed you've worked on this and related packages somewhat recently.

bendrucker commented 5 years ago

Closed via #88