From ad9626e5b57ced2fc5a273e4231993fd00e8bd09 Mon Sep 17 00:00:00 2001 From: Silvano Luciani Date: Mon, 21 Jul 2014 11:13:05 -0700 Subject: [PATCH] Query.start should set the offset to 0. --- lib/datastore/query.js | 1 + test/datastore.query.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/datastore/query.js b/lib/datastore/query.js index ef5947e17af..18d2770111a 100644 --- a/lib/datastore/query.js +++ b/lib/datastore/query.js @@ -75,6 +75,7 @@ Query.prototype.select = function(fieldNames) { Query.prototype.start = function(start) { var q = util.extend(this, new Query()); q.startVal = start; + q.offsetVal = 0; return q; } diff --git a/test/datastore.query.js b/test/datastore.query.js index 9c59fc6b257..2652cc8ba49 100644 --- a/test/datastore.query.js +++ b/test/datastore.query.js @@ -112,6 +112,13 @@ describe('Query', function() { done(); }); + it('should reset the offset to 0 when using start tokens', function(done) { + var q = ds.createQuery(['kind1']).offset(5); + q.start('startVal'); + assert.strictEqual(q.offsetVal, 0); + done(); + }); + it('should be converted to a query proto successfully', function(done) { var q = ds.createQuery(['Kind']) .select(['name', 'count'])