Skip to content

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

Closed
@Tol1

Description

@Tol1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions