diff --git a/lib/datastore/query.js b/lib/datastore/query.js index 01230d31484..ac7b7f5a7a8 100644 --- a/lib/datastore/query.js +++ b/lib/datastore/query.js @@ -76,6 +76,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'])