Skip to content

Import mapping with "External-Id Relationship Fields" #83

Open
@amureki

Description

@amureki

Description

Imagine you have the structure in your code/Salesforce like:

# salesforce/models.py
class SalesforceRelatedObject(hc_models.HerokuConnectModel):
    sf_object_name = 'RelatedObject__c'
    backend_uuid = hc_models.ExternalID(sf_field_name='BackendUUID__c',)


class MySalesforceObject(hc_models.HerokuConnectModel):
    related_object_id = hc_models.ID(
            sf_field_name='RelatedObject__c', unique=False, db_index=True
    )
    related_object = hc_models.Lookup(
        'salesforce.SalesforceRelatedObject',
        sf_field_name='RelatedObject__r__BackendUUID__c',
        blank=True,
        on_delete=models.SET_NULL,
        to_field='backend_uuid',
    )

In this case, import mappings command will produce mapping that contains both fields, but it would not generate an index part of the mapping for RelatedObject__c. This is silently breaking the whole mapping and RelatedObject__r__BackendUUID__c won't be added.

To Do

  1. We need to add a validation to prevent this kind of failure. This could be done somewhere around heroku_connect.db.models.base.HerokuConnectModel.get_heroku_connect_field_mapping
  2. A ticket to Heroku asking why this silently breaks would be also good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions