Skip to content

Bring native API in line with pure js version. Fixes #743 #937

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

Merged
merged 2 commits into from
Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/native/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ NativeResult.prototype.addCommandComplete = function(pq) {
});
}
};

NativeResult.prototype.addRow = function(row) {
// This is empty to ensure pg code doesn't break when switching to pg-native
// pg-native loads all rows into the final result object by default.
// This is because libpg loads all rows into memory before passing the result
// to pg-native.
};
21 changes: 21 additions & 0 deletions test/integration/client/simple-query-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ test("simple query interface", function() {
});
});

test("simple query interface using addRow", function() {

var client = helper.client();

var query = client.query("select name from person order by name");

client.on('drain', client.end.bind(client));

query.on('row', function(row, result) {
assert.ok(result);
result.addRow(row);
});

query.on('end', function(result) {
assert.lengthIs(result.rows, 26, "result returned wrong number of rows");
assert.lengthIs(result.rows, result.rowCount);
assert.equal(result.rows[0].name, "Aaron");
assert.equal(result.rows[25].name, "Zanzabar");
});
});

test("multiple simple queries", function() {
var client = helper.client();
client.query({ text: "create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');"})
Expand Down