Skip to content
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

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

Open
jamesopstad opened this issue Mar 6, 2024 · 3 comments

Comments

@jamesopstad
Copy link

jamesopstad commented Mar 6, 2024

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
Copy link
Contributor

sehrope commented Mar 6, 2024

What version of pg / pg-types are you using? This should have been fixed in afead5b and there are tests in the repo for that as well:

node-pg-types/test/types.js

Lines 454 to 462 in 37606f8

exports['array/numeric'] = {
format: 'text',
id: 1231,
tests: [
['{1.2,3.4}', function (t, value) {
t.deepEqual(value, ['1.2', '3.4'])
}]
]
}

@jamesopstad
Copy link
Author

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
Copy link
Contributor

sehrope commented Mar 6, 2024

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.

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

2 participants