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

With duplicated column names, result row gets value from rightmost non-null column (or default null) #3062

Closed
Tol1 opened this issue Sep 7, 2023 · 4 comments · Fixed by #3063
Labels

Comments

@Tol1
Copy link

Tol1 commented Sep 7, 2023

Noticed when upgraded to 8.11.3 that the parsing of duplicated column names has changed, and broke some of our queries.
I made a minimal example of situation:

const res1 = await client.query('SELECT NULL AS test, 10 AS test, NULL AS test')
const res2 = await client.query('SELECT NULL AS test, 10 AS test, 12 AS test')
console.log(res1.rows[0].test)
console.log(res2.rows[0].test)

With 8.11.3, code above prints

10
12

And with 8.11.2, it prints

null
12

For me, it should be consistent, either leftmost or rightmost column, but never some kind of "last non-null"

I also checked code, and this is caused by #3043 dropping else-branch https://github.com/brianc/node-postgres/pull/3043/files#diff-e7208163de109ecdddff33a5473cb7c255bd7693a1ec06da8300fe88cabf7a4fL70 here

@charmander
Copy link
Collaborator

@brianc Probably worth making a release just for this?

@brianc
Copy link
Owner

brianc commented Oct 30, 2023

yup you're totally right, i'll get this patched up. sorry about that!

@stdrc
Copy link

stdrc commented Mar 27, 2024

Hi! Is this fix released? Seems the latest version 8.11.3 is released earlier than this PR? Or did I miss something? Thanks.

@brianc
Copy link
Owner

brianc commented Mar 28, 2024

Sorry! Will try to release this today or tomorrow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants