Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isMarkedForDestruction seems broken #119

Open
michel3141 opened this issue Mar 27, 2024 · 0 comments
Open

isMarkedForDestruction seems broken #119

michel3141 opened this issue Mar 27, 2024 · 0 comments

Comments

@michel3141
Copy link

if you use isMarkedForDestruction on multiple relationships, the result on the graphiti server is correct
but on the js side only half the relations seems destroyed.

here is the patch i used :

diff --git a/lib-esm/util/write-payload.js b/lib-esm/util/write-payload.js
index 0842980665b01656699b055519c4fa466eb657d1..94f29123cfec88eb5e9911d52c7b3a759eeee4b3 100644
--- a/lib-esm/util/write-payload.js
+++ b/lib-esm/util/write-payload.js
@@ -38,7 +38,7 @@ var WritePayload = /** @class */ (function () {
             var relatedObjects = modelIdx[key];
             if (relatedObjects) { 
                 if (Array.isArray(relatedObjects)) { 
-                    relatedObjects.forEach(function (relatedObject, index) { 
+                    relatedObjects.slice().reduceRight(function(_,relatedObject,index) { 
                         if (relatedObject.isMarkedForDestruction || 
                             relatedObject.isMarkedForDisassociation) { 
                             modelIdx[key].splice(index, 1); 
@@ -46,7 +46,7 @@ var WritePayload = /** @class */ (function () { 
                         else { 
                             _this.removeDeletions(relatedObject, nested); 
                         } 
-                    }); 
+                    },null); 
                 } 
                 else { 
                     var relatedObject = relatedObjects;

index gets wrong when some elements are destroy. So the fix reads the array from right to left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant