Cyclic relationships are not replaced correctly on deserialize
rsoesemann opened this issue · comments
To clone object structures in APEX I basically serialize and the deserialize it. It worked perfectly for this structure:
with this configuration
new SObjectDataLoader.SerializeConfig()
.followChild(City__c.mdr_Country__c)
.followChild(Citizen__c.mdr_Country__c)
But when I introduced the lkp_LivesIn__c
Lookup it fails to replace its value on deserialize as the value of the original City is not replaced but still points to the original record.
new SObjectDataLoader.SerializeConfig()
.followChild(City__c.mdr_Country__c)
.followChild(Citizen__c.mdr_Country__c)
.followChild(Citizen__c.lkp_LivesIn__c)
SOLUTION: Use follow()
instead of followChild()
new SObjectDataLoader.SerializeConfig()
.followChild(City__c.mdr_Country__c)
.followChild(Citizen__c.mdr_Country__c)
.follow(Citizen__c.lkp_LivesIn__c)