Browse Source

EAGLESIX-812: Fix potential regression with key values

Chris Sexton 11 years ago
parent
commit
0ee13db4c2
1 changed files with 6 additions and 3 deletions
  1. 6 3
      lib/pipeline/documentSources/GroupDocumentSource.js

+ 6 - 3
lib/pipeline/documentSources/GroupDocumentSource.js

@@ -33,6 +33,7 @@ var GroupDocumentSource = module.exports = function GroupDocumentSource(expCtx)
 	this.currentAccumulators = [];
 	this.groups = {}; // GroupsType Value -> Accumulators[]
 	this.groupsKeys = []; // This is to faciliate easier look up of groups
+	this.originalGroupsKeys = [];
 	this.variables = null;
 	this.fieldNames = [];
 	this.idFieldNames = [];
@@ -107,9 +108,10 @@ proto.getNext = function getNext(callback) {
 					return next(null, null);
 				}
 
-				var id = self.groupsKeys[self.currentGroupsKeysIndex],
-					accumulators = self.groups[id],
-					out = self.makeDocument(JSON.parse(id), accumulators, self.expCtx.inShard);
+				var id = self.originalGroupsKeys[self.currentGroupsKeysIndex],
+					stringifiedId = self.groupsKeys[self.currentGroupsKeysIndex],
+					accumulators = self.groups[stringifiedId],
+					out = self.makeDocument(id, accumulators, self.expCtx.inShard);
 
 				if(++self.currentGroupsKeysIndex === self.groupsKeys.length) {
 					self.dispose();
@@ -310,6 +312,7 @@ proto.populate = function populate(callback) {
 					group = self.groups[groupKey];
 
 				if(!group) {
+					self.originalGroupsKeys.push(id);
 					self.groupsKeys.push(groupKey);
 					group = [];
 					self.groups[groupKey] = group;