Skip to content

Commit f26cb73

Browse files
committed
Merge pull request brianc#937 from coagmano/master
Bring native API in line with pure js version. Fixes brianc#743
2 parents ef64f5d + b78a508 commit f26cb73

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/native/result.js

+7
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ NativeResult.prototype.addCommandComplete = function(pq) {
1919
});
2020
}
2121
};
22+
23+
NativeResult.prototype.addRow = function(row) {
24+
// This is empty to ensure pg code doesn't break when switching to pg-native
25+
// pg-native loads all rows into the final result object by default.
26+
// This is because libpg loads all rows into memory before passing the result
27+
// to pg-native.
28+
};

test/integration/client/simple-query-tests.js

+21
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ test("simple query interface", function() {
3636
});
3737
});
3838

39+
test("simple query interface using addRow", function() {
40+
41+
var client = helper.client();
42+
43+
var query = client.query("select name from person order by name");
44+
45+
client.on('drain', client.end.bind(client));
46+
47+
query.on('row', function(row, result) {
48+
assert.ok(result);
49+
result.addRow(row);
50+
});
51+
52+
query.on('end', function(result) {
53+
assert.lengthIs(result.rows, 26, "result returned wrong number of rows");
54+
assert.lengthIs(result.rows, result.rowCount);
55+
assert.equal(result.rows[0].name, "Aaron");
56+
assert.equal(result.rows[25].name, "Zanzabar");
57+
});
58+
});
59+
3960
test("multiple simple queries", function() {
4061
var client = helper.client();
4162
client.query({ text: "create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');"})

0 commit comments

Comments
 (0)