Use Case:
Need to allow changes to only one specific field on an opportunity when at a certain stage.
Problem:
How to efficiently determine within a trigger context that a only the specific field has changed and no other values have changed.
Info:
Salesforce's documentation on Sobject equality states that Sobject1 == Sobject2 will perform a field by field comparison of the two sobjects. Though my testing seems to indicate that Salesforce's is performing this field by field comparison with more fields than is returned by performing a metadata describe. As when I perform a metadata describe to get the Sobjects set of fields and iterate said set comparing the two Sobjects values I get a result indicating the two Sobjects are equal. Yet when I do the check of Sobject1 == Sobject2 it comes back false.
Questions:
Does a trigger context Sobject(as in the Sobjects in trigger.new) contain extra values that would cause an equality check to fail despite all metadata describe visible fields being equal?
Conversely does a Sobject clone contain extra values that would cause an equality check to fail despite all metadata describe visible fields being equal?
Why would the following not result as being equal assuming only the Opportunity Type field has changed?
Opportunity oldOppClone = trigger.old[0].clone(true,true,true,true);
oldOppClone.Type = trigger.new[0].Type;
system.assert(trigger.new[0]==oldOppClone);
Is there any other way to facilitate obtaining a set of fields which have changed between two Sobjects than metadata describing and iterating the fields and checking each individually?