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