The Wayback Machine - https://web.archive.org/web/20200906044107/https://github.com/brianc/node-postgres/issues/743/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
adayton1 opened this issue Mar 6, 2015 · 5 comments
Closed

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

adayton1 opened this issue Mar 6, 2015 · 5 comments

Comments

@adayton1
Copy link

@adayton1 adayton1 commented Mar 6, 2015

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();
    });
});
@deyhle
Copy link

@deyhle deyhle commented May 7, 2015

+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}]}
@vaseker
Copy link

@vaseker vaseker commented Jun 23, 2015

@traviscrawford
Copy link

@traviscrawford traviscrawford commented Jan 29, 2016

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",
@coagmano
Copy link
Contributor

@coagmano coagmano commented Feb 2, 2016

+1
node 4.2.4

"pg": "4.4.4",
"pg-native": "1.10.0"
@coagmano
Copy link
Contributor

@coagmano coagmano commented Feb 12, 2016

Made a PR ^^ to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.