Skip to content

fix(pg-protocol): decode binary result fields as raw bytes instead of utf-8 - #3734

Open
nigrosimone wants to merge 1 commit into
brianc:masterfrom
nigrosimone:fix-decode-binary
Open

fix(pg-protocol): decode binary result fields as raw bytes instead of utf-8#3734
nigrosimone wants to merge 1 commit into
brianc:masterfrom
nigrosimone:fix-decode-binary

Conversation

@nigrosimone

Copy link
Copy Markdown
Contributor

Results requested with binary: true are silently corrupted. No error is raised, the query
succeeds and returns wrong values:

const client = new Client()
await client.connect()

await client.query({ text: 'SELECT $1::int AS a', values: [127], binary: true })
// { a: 127 }    correct

await client.query({ text: 'SELECT $1::int AS a', values: [128], binary: true })
// { a: 239 }    WRONG

await client.query({ text: 'SELECT $1::int AS a', values: [200], binary: true })
// { a: 239 }    WRONG

await client.query({ text: 'SELECT $1::int AS a', values: [-1], binary: true })
// { a: -272646673 }    WRONG

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

Successfully merging this pull request may close these issues.

1 participant