-
Notifications
You must be signed in to change notification settings - Fork 47
Incorrect move operation behavior #61
Comments
@TFleury Could you share a repro where you are seeing this issue? |
I'd want to patch a Here is a simplified version of my classes : public class Template {
private TrackedList<Theme> _theme = new TrackedList<Theme>();
public string Label { get; set; }
public IList<Theme> Themes {
retrun _themes;
}
}
public class Theme {
private TrackedList<Theme> _theme = new TrackedList<Theme>();
public string Label { get; set; }
public IList<Theme> Themes {
retrun _themes;
}
} Here is a sample patch : [
{op:"move",from:"/themes/3",path:"/themes/1"},
{op:"move",from:"/themes/4/themes/1",path:"/themes/2"}
]
The issue is that moved item is copied, removed, and then the copy is inserted at the destination position : the reference is lost. It's backed in a database with EntityFramework, and I have to keep reference of objects to know which entry is new, removed or updated. |
@kichalla can you confirm this is an issue and not the expected behavior ? |
I fixed the copy issue in my PR, and added matching unit tests. |
@kichalla can you confirm you agree with the issue? |
@Eilon and I discussed about this and agree that this is an issue. Changing the label to |
When performing a
move
operation, target object is not moved, but it is removed from source and a copy is added to the destination.There is no problem with value types, but there is one with reference types : reference was lost.
To handle move operation,
ObjectAdapter
gets the moved property, removes it from the source, then adds it to the destination. That's OK.The issue is in
ListAdapter
,PocoAdapter
andExpandoAdapter
(don't know why, but not inDictionaryAdapter
), inTryConvertValue
method where the value is copied regardless of its type.If object's type is compatible with target property's type, the reference should be kept.
The text was updated successfully, but these errors were encountered: