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
{{ message }}
Repository navigation
Same List instance is returned for empty arrays #3417
I'm running into an issue where when a model includes multiple List<T>s, such a List<string> or a List<int>, and I add a new item to the List<T>, that same new item is added to all List<T>s with the same T.
and you add an item to PropFour, both PropThree and PropTwo get the same item added. Note that PropOne will be unaffected as it is a different type. I have a fully functional example of this issue in this repository. Hopefully this isn't one of those instances where it's unproducible on other machines :).
@jrhodnik I can see the odd behavior - thanks for reporting this! I've opened dotnet/efcore#23726 as this is reproducible on EF Core regardless of PostgreSQL.
@jrhodnik thanks again for flagging this - this will be fixed fox 5.0.2. In the meantime, rather than mutating the List on the loaded entity instance, replace it with a new List which contains the new contents.
Activity
roji commentedon Dec 18, 2020
@jrhodnik I can see the odd behavior - thanks for reporting this! I've opened dotnet/efcore#23726 as this is reproducible on EF Core regardless of PostgreSQL.
roji commentedon Dec 18, 2020
This turned out to be an ADO.NET-level bug - we return the same instance when an empty
List<T>is returned.[-]Model List<T> Additions Leaking To Other List<T>s[/-][+]Same List instance is returned for empty arrays[/+]roji commentedon Dec 18, 2020
@jrhodnik thanks again for flagging this - this will be fixed fox 5.0.2. In the meantime, rather than mutating the List on the loaded entity instance, replace it with a new List which contains the new contents.
Don't return same List instance for empty PG arrays
Don't return same List instance for empty PG arrays (#3418)
Don't return same List instance for empty PG arrays (#3418)
roji commentedon Dec 19, 2020
Note: this bug isn't present in 4.1 (introduced in c95b6ec)