CRM-20790 - ensure relationships are created on import #10808
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
When importing records that include relationships, the relationships are not created. The core problem seems to be that the error message returned when a duplicate is found was at one point (or sometimes) returns as a comma separated list of IDs, but now (or sometimes) is returned as an array. The import code doesn't check for the array in all places.
Before
Importing a CSV file listing an individual along with the name of the Employer failed to create the employee/employer relationship between the two contacts. This was true if both contacts existed or one existed (if neither existed than it works fine).
After
Now the import works as expected.
Comments
A better fix might be to track down why we sometimes return an comma separated list of ids and sometimes an array and make it consistent.