fix invariant glitch unstable
authorAndrew Sutherland <asutherland@asutherland.org>
Sun, 19 Oct 2008 04:19:14 -0700
changeset 981 8e9fe32109b8a7232a5844320ca273bf5c3a4528
parent 980 1640a675f6d98000c103dc484aecc7c27f69b624
child 982 93af40a644fa28e6ced6d14ad4068045780b56f7
push idunknown
push userunknown
push dateunknown
fix invariant glitch
modules/datastore.js
--- a/modules/datastore.js
+++ b/modules/datastore.js
@@ -284,23 +284,31 @@ QFQ_LOG.debug("loading item " + nounDef.
         if (this.selfInverseReferences)
           outReferences = {};
         else
           outReferences = masterReferences;
         let [foundCount, notFoundCount, notFound] =
           GlodaCollectionManager.cacheLookupMany(nounDef.id, references,
               outReferences);
 
-        if (this.selfInverseReferences) {
+        if (nounDef.parentColumnAttr) {
+          let inverseReferences;
+          if (nounDef.id in this.masterInverseReferencesByNounID)
+            inverseReferences =
+              this.masterInverseReferencesByNounID[nounDef.id];
+          else
+            inverseReferences =
+              this.masterInverseReferencesByNounID[nounDef.id] = {};
+          
           for each (let item in outReferences) {
             masterReferences[item.id] = item;
             let parentID = item[nounDef.parentColumnAttr.idStorageAttributeName];
-            let childrenList = this.selfInverseReferences[parentID];
+            let childrenList = inverseReferences[parentID];
             if (childrenList === undefined)
-              childrenList = this.selfInverseReferences[parentID] = [];
+              childrenList = inverseReferences[parentID] = [];
             childrenList.push(item);
           }
         }
         
         QFQ_LOG.debug("  found: " + foundCount + " not found: " + notFoundCount);
         if (notFoundCount === 0) {
           this.collection.resolvedCount++;
         }