node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

types/getTypeParser in query method doesn't work with pg-native?

Open benny-medflyt opened this issue 4 years ago • 1 comments

Hello, I have simple code like this:

var pg = require("pg");

const client = new pg.Client();
// ...
client.query({
        text: "SELECT num FROM data WHERE id = $1",
        values: [1],
        rowMode: "array",
        types: {
            getTypeParser: () => val => val,
        }
    },
    (err, result) {
        console.log(result.rows);
    });

This works great and I get the expected output: [ [ "567" ] ]

But when I change the first "require" line to use "pg-native", like this:

var pg = require("pg").native;

then my custom parser seems to be ignored, and I get the following output: [ [ 567 ] ]

I am using:

  • pg 8.7.1
  • pg-native 3.0.0

Thank you

benny-medflyt avatar Jan 13 '22 20:01 benny-medflyt

I've submitted a pull request to fix this: #2687

benny-medflyt avatar Jan 13 '22 22:01 benny-medflyt