brianc / node-pg-types

Type parsing for node-postgres
268 stars 55 forks source link

Solidify existing UTF-8 decoding behaviour on binary-format text[] #102

Closed charmander closed 5 years ago

charmander commented 5 years ago

This never did the right thing, even when it was introduced back in brianc/node-postgres@5b3c501d74d0b3d1610dadf776c746a956537925, reading from the global object instead of the client. It’ll usually be undefined and result in UTF-8 decoding, but when it isn’t…

> const {Client} = require('pg');
> const client = new Client();
> await client.connect();
> encoding = 'base64';
> (await client.query({text: "SELECT 'foo' x WHERE $1 = 1", values: [1], binary: true})).rows
[ { x: 'foo' } ]
> (await client.query({text: "SELECT ARRAY['foo'] x WHERE $1 = 1", values: [1], binary: true})).rows
[ { x: [ 'Zm9v' ] } ]

UTF-8 matches the non-array binary parser for the text type.

codecov-io commented 5 years ago

Codecov Report

Merging #102 into master will not change coverage. The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #102   +/-   ##
=======================================
  Coverage   80.33%   80.33%           
=======================================
  Files           5        5           
  Lines         300      300           
=======================================
  Hits          241      241           
  Misses         59       59
Impacted Files Coverage Δ
lib/binaryParsers.js 61.97% <0%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update fbe5b0e...b0e31c7. Read the comment docs.