-
Notifications
You must be signed in to change notification settings - Fork 44
Consider options for dealing with non-List collections #7
Comments
How about JPA? Even if I would model OneToMany relationships with
Maybe Also how about filtering? If we do Not to mention the fact that I think that working with data from DB is primary goal for spring-sync, right? Then we must somehow extend the patch mechanism to understand PKs. |
Also note even if we were somehow able to guarantee the order of items in a list, we still can't guarantee that this list doesn't changed in between GET and PATCH. For example:
Now we have the user 2 can use |
With hibernate usually it is wiser to work with Sets, in a Set the order is not important by definition so in that case, it doesnt matter in which order hibernate returns the entities. However, guys you clearly have a bug in the source code. Lines 119-121 in Diff.java you are casting a collection to a list. As you might know, every List is a collection but not the other way around! |
I'd propose to extend that function like: where diffSet(operations, path + "/" + field.getName(), (Set) origValue, (Set) modValue); |
At the moment, Patch can only deal with changes to Objects and Lists of Objects. For many use cases, that is sufficient. But what if the objects being compare are java.util.Sets or have properties of type Set? What about Map or properties of type Map?
JSON Patch doesn't address these cases very well and thus Spring Sync's Patch (which is initially inspired from JSON Patch) doesn't deal with them very well, either.
Set is particularly tricky. What would the path look like if an entry in a set is to be removed? What would the path look like if the property on a Set entry were to change? Indeed, the path interpreter (which assumes a JSON Patch-style path) would need to be changed to support additional path syntax or even pluggable to support optional path syntax.
The text was updated successfully, but these errors were encountered: