Merge pull request #937 from coagmano/master
Bring native API in line with pure js version. Fixes #743
This commit is contained in:
commit
f26cb73356
@ -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.
|
||||
};
|
||||
|
@ -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');"})
|
||||
|
Loading…
Reference in New Issue
Block a user