diff --git a/lib/native/result.js b/lib/native/result.js index 485f36b46..9fd23f52c 100644 --- a/lib/native/result.js +++ b/lib/native/result.js @@ -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. +}; diff --git a/test/integration/client/simple-query-tests.js b/test/integration/client/simple-query-tests.js index f8ef1adad..c311193b7 100644 --- a/test/integration/client/simple-query-tests.js +++ b/test/integration/client/simple-query-tests.js @@ -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');"})