Alternate foreign keys incorrectly updated on navigation property entities
See original GitHub issueIn breeze.debug.js, on line 5405 in setNpValue, the statement:
var inverseKeyProps = property.entityType.keyProperties;
incorrectly assigns the inverse property’s key properties and the result is that the primary key values of the inverse navigation property are assigned to the foreign key properties instead of their original values and data is corrupted.
Consider the following scenario:
A Department object has an Id primary key, a DeptId alternate foreign key that is unique, and a navigation property of DepartmentMembers, an array of class DepartmentMember that has an Id (primary key), DeptId related to Department.DeptId, and a MemberId.
In this scenario instead of the original value of DeptId being used upon loading into the navigation property, setNpValue will assign the Department.Id value to DepartmentMember.DeptId instead of correctly maintaining the inverse foreign key mapping of Department.DeptId to DeparmentMember.DeptId, resulting in corrupted data.
updating the statement on line 5405 as follows fixes this issue:
var inverseKeyProps = property.entityType.inverseForeignKeyProperties;
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top GitHub Comments
I was able to reproduce the problem in tests, and have fixed in breeze-client 2.1.1. Now Breeze supports relationships to foreign keys that are not the PK.
Correct. the isScalar property is false because it is a list/array for a one-to-many relationship. I did get everything working for navigation properties both one-to-many and one-to-one, but I did have to modify Breeze to do it. I’m pressed for time on a project, but once I have it completed, I will be making a pull request with the modifications.