brianc / node-pg-types

Type parsing for node-postgres
267 stars 54 forks source link

Numeric values are parsed as strings but arrays of numerics are parsed as number arrays #151

Open jamesopstad opened 5 months ago

jamesopstad commented 5 months ago

I've come across an issue where numeric values are parsed as strings but arrays of numerics are parsed as number arrays. Here is a minimal query to reproduce:

SELECT 1.11::numeric AS single_numeric, '{1.11,2.22,3.33}'::numeric[] AS numeric_array

I would expect numeric arrays to parse as string arrays.

sehrope commented 5 months ago

What version of pg / pg-types are you using? This should have been fixed in https://github.com/brianc/node-pg-types/commit/afead5b156c179364d173965bae2d661beb2230f and there are tests in the repo for that as well:

https://github.com/brianc/node-pg-types/blob/37606f8111b91ef6237bc10abaf671cd078179eb/test/types.js#L454-L462

jamesopstad commented 5 months ago

I am seeing this behaviour in the latest version of pg (8.11.3). Looking at its dependencies though, I see that it is using an old version of pg-types(2.1.0). Apologies, I assumed they would be updated together. Should I raise an issue in the node-postgres repo instead?

sehrope commented 5 months ago

Yes it needs to be updated in pg. Check if there's an existing issue as IIRC this has come up previously and if not open an issue. There's some (potentially?) breaking changes that would mandate a major version bump on the pg side to incorporate the newer version of this library but after five years it's probably time we do it.