-
Notifications
You must be signed in to change notification settings - Fork 519
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
Modifications to registerDirty( SObject, List<SObjectField> ) to only register dirtyFields #201
base: master
Are you sure you want to change the base?
Conversation
…w only registering the specified fields. * Method implies to only register the fields specified, but at first method-call the complete record is registered without upfront notice * Current method was only beneficial when having multiple memory references, with same recordId; Note, due to kept reference, any update on originally registered record will get updated and no registerDirty is needed * New implementation will allow registration of only specified fields; reference is lost to original record, but is not necessary when only updating per field. * Additional Exception is provided when mixing registerDirty with and without dirtyFields to avoid system overwriting specific field updates
These seem like good clarification changes to me. My only concern is breaking backward compatibility, even though the original behavior was likely not expected code could be inadvertently depending on it. Thoughts? |
@foxcreation - I know that my org's implementation calls |
@ImJohnMDaniel whats your views on this one? |
So have studied this PR further again and am warming to just going ahead with it. I would like @ImJohnMDaniel opinion and @Autobat if he has time? |
so, currentmethod registerDirty(Sobject) is unchanged? e.g.
will update the Account id=x with Website='w' and Rating = 'foo' ? and new method would work as follows
will update the Account id=x with Website='w' and Rating = 'foo' ? |
@afawcett @cropredyHelix Apologies for the late response. Please find the clarification below. @cropredyHelix all your examples will indeed stay as they were before
The scenarios which are tend to be fixed with this scenario are: Initially, this would insert an Account with Website, Name and Rating, where Name = 'Failure'; However, in my perspective the desire for only registering certain fields is to avoid the reference to the object and the update of additional fields specified on the provided record. We only want to store the values which are in the defined Fields at that time (so only the Website); As of now, I can think of two scenarios which will NOT NOT be backward compatible:
I do acknowledge backward compatibility should be the goal, however, in my perspective both scenarios are undesirable and should be prevented in the first place. They do not make sense to be applied. However, I do fully understand the disadvantage of such impact. In case of any questions or comments, feel free to reach out. My aim is to respond quicker from now on :). |
@foxcreation - I don't understand your example code. What is If I follow, the essence of this is that if one uses the new second arg List, then one should use it consistently up until commitWork. If that is the intent, then, you could throw an error if the caller tried to mix use cases (e.g. |
@cropredyHelix you're absolutely right, I copied from an initiation question, but didn't replace all. I've edited my post to correctly refer to I think I can only agree with your summary partially, as the second arg list method already existed, although it did the exact same as It is correct that one should not mix. From my perspective it also wouldn't make sense:
I hope this elaborates a bit better on the impact of this PR, but please do challenge me to discuss the benefits of this change. |
@foxcreation -- I have read the discussion above and please forgive me if I am missing something in that description but can you answer why registering only field changes becomes a benefit verses simply registering the entire record as dirty? |
@ImJohnMDaniel no problem, but please do note this method already exists in the current code base and my pull request only applies some changes for a more logical behaviour. My understanding to allow a developer to only explicitly register certain fields is to give control of what is updated. One could image the following situation:
Please let me know whether this elaborates the need for the function and the need for this change sufficiently. |
@ImJohnMDaniel @afawcett @cropredyHelix what would be the next steps for this Pull Request to be further reviewd? Please let me know in case any additional input is needed. Thanks! |
@foxcreation -- I just downloaded the code and tested it. I am getting a failed test execution. Here is the output:
Can you investigate please and let me know what you are seeing? Thanks for the help |
@foxcreation I'm aligned with this, but we do need to get the test failure @ImJohnMDaniel points out above fixed. |
@ImJohnMDaniel could you please retry, I tested it now a couple times, but on my dev environment all methods pass smoothly. Might it accidentally be some local changes in your environment? Please let me know when the issue remains, then I'll further investigate. Thanks! |
G'day @foxcreation -- at the moment, this PR is probably in a bad state. Not because of your changes (which I believe have merit), but because the main branch of the project has changed directory structure to DX Source Format since mid-April. My advice is to capture the changes to UOW files, cancel this PR, fork the main repo again (which is in DX Source Format) and begin the PR again. Either that, or update your forked branch with all changes from the main repo and let's see where that gets us. |
Modifications to registerDirty( SObject, List ) to enable only registering the specified fields.
This change is