This may be something I am doing wrong, but I am having an issue that I believe is repeatable. It may be by design, but right now I can't figure out how to get around it.
I have an entity with a few complexType arrays on them. If I push a new complexType into the array, I see the correct number of objects in the collection. If I call rejectChanges on the parent entity, it removes the new complexType but then copies all of the objects in that array.
Sample metadata -
metadataStore.addEntityType({
shortName: "Person",
namespace: "MyNameSpace",
dataProperties: {
id: { dataType: "String", isPartOfKey: true },
emails: { complexTypeName: "Email:#MyNameSpace", isScalar: false }
}
});
metadataStore.addEntityType({
shortName: "Email",
namespace: "MyNameSpace",
isComplexType: true,
dataProperties: {
id: { dataType: "String" },
text: { dataType: "String" },
preferred: { dataType: "Boolean" }
}
});
Steps to reproduce -
- Create an entity
- Add two complex types of email
- Save all changes
- Add another complex type of email
- Call entityAspect.rejectChanges() on the parent entity
- Look at the number of emails in the array now
I assume on steps 1-3 this will still reproduce the issue, right now I am getting the entity and the complex types from the server so I am only doing steps 4-6.
Notes
I tried calling rejectChanges on the complexAspect instead but it doesn't exist.
I have a ko.computed on the list of emails to return the 'preferred' one that sets the others to false, don't know if this is contributing
I am sorting the list of emails in the DOM
Edit
Just found that the same thing occurs when deleting one of the complex types and cancelling that change.
Sorry for taking so long on this one. It slipped... It is now in the current GitHub repo and will go out with the next release.
I don't know if you got a response for your problem but here is mine!
Reason: There is a bug in breeze that causes this behavior. I am referring to breeze v1.4.11 (still present in 1.4.12)
Solution: This is my fix for the issue: