You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After getting some errors "Queued save failed: Converting circular structure to JSON" when saving in Breeze I tracked the issue down to the function rememberAddedOriginalValues in breeze.savequeuing.js
My theory is that the circular structure issue happens because the list of Added entities sometimes ends up containing Modified (and other?) entities.
The entityManager seems to also return Modified entities.
I have used a similar solution to the one provided by @Eblax with great success.
My version of it just adds a condition in the forEach and uses entityState.isAdded() rather than entityState.name:
I feel like I am doing something wrong to cause this strange behaviour from the EntityManager, but I can't see what it is. My Entities are fetched from a server via EntityManager.query() and start in the Unchanged state.
If I make two successive calls to EntityManager.saveChanges() so as to trigger the special queuing behaviour, the problem arises.
After getting some errors "Queued save failed: Converting circular structure to JSON" when saving in Breeze I tracked the issue down to the function rememberAddedOriginalValues in breeze.savequeuing.js
My theory is that the circular structure issue happens because the list of Added entities sometimes ends up containing Modified (and other?) entities.
On line ~189 after:
var added = entities ? entities.filter(function (e) { return e.entityAspect.entityState.isAdded(); }) : entities.filter(function (e) { return e.entityAspect.entityState.isAdded(); }) : self.entityManager.getChanges(null, breeze.EntityState.Added);
It looks like the array in added should contain only Added entities, however for some reason it sometimes contains other entries.
To remove these other entities I added this immediately after the previous lines to remove entities with entitystates other than Added:
for(var x = 0; x < added.length; x++) { if(added[x].entityAspect && added[x].entityAspect.entityState.name != breeze.EntityState.Added) { added.splice(x, 1); x--; } }
This at least seems to have sorted my issues.
The text was updated successfully, but these errors were encountered: