|
|
@@ -23,6 +23,7 @@ var GroupDocumentSource = module.exports = function GroupDocumentSource(expCtx)
|
|
|
this.idExpression = null;
|
|
|
this.groups = {}; // GroupsType Value -> Accumulators[]
|
|
|
this.groupsKeys = []; // This is to faciliate easier look up of groups
|
|
|
+ this.originalGroupsKeys = []; // This stores the original group key un-hashed/stringified/whatever
|
|
|
|
|
|
this.fieldNames = [];
|
|
|
this.accumulatorFactories = [];
|
|
|
@@ -225,6 +226,7 @@ proto.populate = function populate() {
|
|
|
} else {
|
|
|
this.groups[idHash] = group = [];
|
|
|
this.groupsKeys[this.currentGroupsKeysIndex] = idHash;
|
|
|
+ this.originalGroupsKeys[this.currentGroupsKeysIndex] = (_id && typeof _id === 'object') ? Document.clone(_id) : _id;
|
|
|
++this.currentGroupsKeysIndex;
|
|
|
for (var ai = 0; ai < this.accumulatorFactories.length; ++ai) {
|
|
|
var accumulator = new this.accumulatorFactories[ai]();
|
|
|
@@ -251,10 +253,11 @@ proto.populate = function populate() {
|
|
|
|
|
|
proto.makeDocument = function makeDocument(groupKeyIndex) {
|
|
|
var groupKey = this.groupsKeys[groupKeyIndex],
|
|
|
+ originalGroupKey = this.originalGroupsKeys[groupKeyIndex],
|
|
|
group = this.groups[groupKey],
|
|
|
doc = {};
|
|
|
|
|
|
- doc[Document.ID_PROPERTY_NAME] = JSON.parse(groupKey);
|
|
|
+ doc[Document.ID_PROPERTY_NAME] = originalGroupKey;
|
|
|
|
|
|
for (var i = 0; i < this.fieldNames.length; ++i) {
|
|
|
var fieldName = this.fieldNames[i],
|