-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing DiffOpChange to ListPatcher #65
base: 2.x
Are you sure you want to change the base?
Conversation
+1 I can't see why this shouldn't be done (with tests of course), but I think someone with more knowledge of this component should chime in (@JeroenDeDauw). |
At first glance I'm inclined to say that the list stuff is meant to be non-positional, and that change operations are thus not allowed here. Been some time since I looked at this library though, will double check later. Did you look at MapPatcher? |
I don't see what's "positional" here. A change is a remove and an add combined. The code of the two existing remove and add operations is literally duplicated. As said, I would like to reuse this implementation in the FingerprintPatcher but can't because it misses this operation. |
Oops, forgot to look at this. On my TODO list again now |
Ok, looking at this now. Too bad you did not answer my question, that'd have saved some time. |
This patcher was created to mirror ListDiffer, which it does, as this one never creates change operations. That does not mean adding support for change operations here is bad, though I'd like to understand where those are coming from first. What code in the linked DMS PR is this supposed to replace? |
The refactored I would like to replace the line The reason for this is hidden in the current |
Added tests. |
For completeness:
Are you referring to this?
I really can't tell what you want to know. I probably looked at all code at some point. I looked at this class while working on FingerprintPatcher. So the answer is yes, I guess? Does this answer your question? How could this answer have saved time? |
Are the only tests that are failing new ones added in https://github.com/wmde/WikibaseDataModelServices/pull/123/files (for instance at line 190)? I'm not understanding where in the production code change operations for aliases would come from, as those are a list, not a map. It's now clear to me that the change you made, at least in its current form, goes against the intention of the modified class. As per README "The Diff class can be set to be either associative or non-associative. In case of the later, only DiffOpAdd and DiffOpRemove are allowed in it". And in |
I was wondering if what you where looking for might be |
I wanted to try a refactoring of FingerprintPatcher to make it work on DataModel objects instead of arrays, but found that lots of features are uncovered. I was more fearless a year ago, but nowadays refactoring with insufficient coverage scares me. While collecting tests in https://github.com/wmde/WikibaseDataModelServices/pull/123/files#diff-083f80d290824bee8a9622736e379faaR89 I found that all possible (and actually supported) types of alias changes make sense:
Currently we use number 3. We may switch to number 2. Other users of this component may use these other possibilities. And since the class supports them all, I did not wanted to make my refactoring a breaking change.
I do have the feeling you still miss a critical point: MapPatcher does not always call ListPatcher to apply diffs on non-associative, numerically indexed arrays. Sometimes MapPatcher applies diffs on numerical arrays itself, without calling ListPatcher. This happens in FingerprintPatcher. The interface of FingerprintPatcher does not say it is limited to only one specific type of alias diff. It does support all three. |
Can we close this? |
You mean merge? This would still help making FingerprintPatcher less messy. |
My understanding is still that this patch is going again the intent of the modified code. IIRC we talked about this in person at some point, where I explained this, and you went "oh, I was not aware of that part". |
I don't remember what we talked about. I did not documented it, unfortunately. I just read this thread again and still believe it applies. Aliases are organized in lists. We do apply change operations on lists. This class is supposed to do this job but silently ignores change operations. It doesn't even tell you. For the moment FingerprintPatcher works around this issue by basically holding a copy of the fixed version of this class. I would like to fix this properly. |
As indicated by the check in this patcher, it is not meant to deal with associative diffs. And as indicated in the README, non-associative diffs are not supposed to have change operations. |
Denying a problem exists does not make it go away. |
Please reopen if still relevant |
Found while working on wmde/WikibaseDataModelServices#120. With this, it would be possible to reuse this as a service in FingerprintPatcher.
Bug: T78298