From ac7e5b775bef8a5ac6eddc35e2f91f0a9ea5e260 Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Tue, 13 Dec 2011 13:16:47 -0800 Subject: [PATCH] #5: Allowing NextRowKey to be null. --- .../models/queryentitiesresultcontinuation.js | 5 +-- .../queryentitiesresultcontinuation-tests.js | 37 ++++++++++++++++--- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lib/services/table/models/queryentitiesresultcontinuation.js b/lib/services/table/models/queryentitiesresultcontinuation.js index 4dfbc5baa6..2c0a630d49 100644 --- a/lib/services/table/models/queryentitiesresultcontinuation.js +++ b/lib/services/table/models/queryentitiesresultcontinuation.js @@ -57,7 +57,7 @@ QueryEntitiesResultContinuation.parse = function (tableService, tableQuery, resp }; QueryEntitiesResultContinuation.prototype.getNextPage = function (callback) { - if (!azureutil.isNull(this.nextPartitionKey) && !azureutil.isNull(this.nextRowKey)) { + if (!azureutil.isNull(this.nextPartitionKey)) { var nextTableQuery = this.tableQuery .whereNextKeys(this.nextPartitionKey, this.nextRowKey); @@ -68,6 +68,5 @@ QueryEntitiesResultContinuation.prototype.getNextPage = function (callback) { }; QueryEntitiesResultContinuation.prototype.hasNextPage = function () { - return !azureutil.isNull(this.nextPartitionKey) && - !azureutil.isNull(this.nextRowKey); + return !azureutil.isNull(this.nextPartitionKey); }; \ No newline at end of file diff --git a/test/services/table/queryentitiesresultcontinuation-tests.js b/test/services/table/queryentitiesresultcontinuation-tests.js index 038813cbcd..5d853364bd 100644 --- a/test/services/table/queryentitiesresultcontinuation-tests.js +++ b/test/services/table/queryentitiesresultcontinuation-tests.js @@ -18,14 +18,18 @@ var testCase = require('nodeunit').testCase; var azure = require('../../../lib/azure'); var azureutil = require('../../../lib/util/util'); +var testutil = require('../../util/util'); + var ServiceClient = require("../../../lib/services/serviceclient"); var TableQuery = require('../../../lib/services/table/tablequery'); var Constants = require('../../../lib/util/constants'); +var QueryEntitiesResultContinuation = require('../../../lib/services/table/models/queryentitiesresultcontinuation'); var HttpConstants = Constants.HttpConstants; var StorageErrorCodeStrings = Constants.StorageErrorCodeStrings; var tableService; -var tableNames = generateNames('queryentities', 1); +var tableNames = []; +var tablePrefix = 'qecont'; module.exports = testCase( { @@ -56,9 +60,10 @@ module.exports = testCase( }, testContinuationTokens: function (test) { - var tableName = tableNames[0]; - var numberOfEntities = 2500; - var numberOfEntitiesPerBatch = 100; + var tableName = testutil.generateId(tablePrefix, tableNames); + var numberOfEntities = 30; + var numberOfEntitiesPerBatch = 10; + var numberOfEntitiesPerQuery = 10; tableService.createTable(tableName, function (createError, table, createResponse) { test.equal(createError, null); @@ -87,9 +92,10 @@ module.exports = testCase( if (finished === Math.ceil(numberOfEntities / numberOfEntitiesPerBatch)) { // Verify var tableQuery = TableQuery.select() - .from(tableName); + .from(tableName) + .top(numberOfEntitiesPerQuery); - tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation, queryResponse) { + tableService.queryEntities(tableQuery, function (queryError, entries, entriesContinuation) { test.equal(queryError, null); test.notEqual(entries, null); @@ -119,6 +125,25 @@ module.exports = testCase( }); } }); + }, + + testNullNextRowKey: function (test) { + var tableName = testutil.generateId(tablePrefix, tableNames); + var tableQuery = TableQuery.select().from(tableName); + + tableService.createTable(tableName, function (createError) { + test.equal(createError, null); + + var queryEntitiesResultContinuation = new QueryEntitiesResultContinuation(tableService, tableQuery, 'part1', null); + test.equal(queryEntitiesResultContinuation.hasNextPage(), true); + + queryEntitiesResultContinuation.getNextPage(function (error) { + // There should be no error when fetching the next page with a null next row key + test.equal(error, null); + + test.done(); + }); + }); } });