Skip to content

require('pg').native doesn't work with query row event #743

Closed

Description

@adayton1

If I uncomment the query.on('row'...) section below, node complains that the function addRow does not exist. When I just use require('pg') it works properly.

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

pg.connect(connectionString, function(err, client, done) {

    if (err) {
        console.error(err);
    }

    var query = client.query(queryString, params);

    query.on('error', function(err) {
        console.error(err);
    });

    /*query.on('row', function(row, result) {
        result.addRow(row);
    });*/

    query.on('end', function(result) {
        done();
    });
});

Activity

  1. deyhle commented on May 7, 2015

    @deyhle

    +1

    Tested with node 0.12.2.

    Apparently the result parameter is no Result object. My debugger shows that it is module.exports instead.

    JSON.stringify(result) returns:

    {"command":"SELECT","rowCount":1,"rows":[{"description":"0.2.1"}],"fields":[{"name":"description","dataTypeID":25}]}
    
  2. vaseker commented on Jun 23, 2015

    @vaseker

    +1
    node 0.12.4
    pg@4.4.0
    pg-native@1.8.1

  3. traviscrawford commented on Jan 29, 2016

    @traviscrawford

    Hi all, I just came across this today when switching to pg-native. Per this note in the project readme I believe this method should be available, even if its a no-op when using libpq:

    node-postgres abstracts over the pg-native module to provide exactly the same interface as the pure JavaScript version. No other code changes are required. If you find yourself having to change code other than the require statement when switching from require('pg') to require('pg').native please report an issue.

    "pg": "4.4.4",
    "pg-native": "1.10.0",
    
  4. coagmano commented on Feb 2, 2016

    @coagmano
    Contributor

    +1
    node 4.2.4

    "pg": "4.4.4",
    "pg-native": "1.10.0"
    
  5. coagmano commented on Feb 12, 2016

    @coagmano
    Contributor

    Made a PR ^^ to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions