small fix on relations

This commit is contained in:
Sébastien Drouyer 2012-12-16 18:20:39 +01:00
parent 3ed14b2ed0
commit 175ad3141d
1 changed files with 3 additions and 4 deletions

View File

@ -402,9 +402,7 @@ AbstractClass.include = function (objects, include, callback, preprocessDataCall
return;
}
console.log('******************* OLD INCLUDE', include);
include = processIncludeJoin(include);
console.log('******************* NEW INCLUDE', include);
var keyVals = {};
var objsByKeys = {};
@ -460,11 +458,10 @@ AbstractClass.include = function (objects, include, callback, preprocessDataCall
var relation = relations[relationName];
var req = {'where': {}};
var keysToBeProcessed = {};
if (!keyVals[relation.keyFrom]) {
objsByKeys[relation.keyFrom] = {};
for (var j = 0; j < objs.length; j++) {
keysToBeProcessed[objs[j][relation.keyFrom]] = true;
if (!objsByKeys[relation.keyFrom][objs[j][relation.keyFrom]]) {
objsByKeys[relation.keyFrom][objs[j][relation.keyFrom]] = [];
}
@ -475,8 +472,10 @@ AbstractClass.include = function (objects, include, callback, preprocessDataCall
if (keyVals[relation.keyFrom].length > 0) {
// deep clone is necessary since inq seems to change the processed array
var keysToBeProcessed = {};
var inValues = [];
for (var j = 0; j < keyVals[relation.keyFrom].length; j++) {
keysToBeProcessed[keyVals[relation.keyFrom][j]] = true;
if (keyVals[relation.keyFrom][j] !== 'null') {
inValues.push(keyVals[relation.keyFrom][j]);
}