Skip to content

Commit

Permalink
Azure#5: Allowing NextRowKey to be null.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rodrigues committed Dec 13, 2011
1 parent 94ce549 commit ac7e5b7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
5 changes: 2 additions & 3 deletions lib/services/table/models/queryentitiesresultcontinuation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
};
37 changes: 31 additions & 6 deletions test/services/table/queryentitiesresultcontinuation-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
});
});
}
});

Expand Down

0 comments on commit ac7e5b7

Please sign in to comment.