I'm trying to export some data from my sandbox org for import into a scratch org, but I seem to be encountering an issue with my query:
MediaQualitySetJunction__c
looks like this:
And this is the query I'm using:
SELECT
Id,
Name,
(SELECT Id, Name, Width__c, Height__c, Resolution__c FROM MediaQuality__r)
FROM MediaQualitySetJunction__c
The full error:
Didn't understand relationship 'mediaquality__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
I'm referencing MediaQuality by the its name on the junction object (with the __r suffix). I've also tried it without this suffix, and with the "Child Relationship Name" I see in Salesforce (MediaQualityJunction), with and without the __r, and I still get the same error.
Based on sfdcfox's answer, I've tried the following export:
sfdx force:data:tree:export -u "[email protected]" -q "SELECT Id, Name, MediaQuality__r.Id, MediaQuality__r.Name, MediaQuality__r.Width__c, MediaQuality__r.Height__c, MediaQuality__r.Resolution__c, MediaQualitySet__r.Id, MediaQualitySet__r.Name FROM MediaQualitySetJunction__c"
Which produces the following JSON:
{
"records": [
{
"attributes":
{
"type": "MediaQualitySetJunction__c",
"referenceId": "MediaQualitySetJunction__cRef1"
},
"Name": "000035",
"MediaQuality__r":
{
"attributes":
{
"type": "MediaQuality__c",
"url": "/services/data/v50.0/sobjects/MediaQuality__c/a020p000001WR5oAAG"
},
"Id": "a020p000001WR5oAAG",
"Name": "1080p",
"Width__c": 1920,
"Height__c": 1080,
"Resolution__c": "1920x1080"
},
"MediaQualitySet__r":
{
"attributes":
{
"type": "MediaQualitySet__c",
"url": "/services/data/v50.0/sobjects/MediaQualitySet__c/a010p000001O3YZAA0"
},
"Id": "a010p000001O3YZAA0",
"Name": "540p, 720p, 1080p (sandbox)"
}
}
]
}
And then executed the following to import it into my scratch org:
sfdx force:data:tree:import -u [email protected] -f "MediaQualitySetJunction__c.json"
I've confirmed that I have access to all of the fields involved and that the field visibility is checked for the System Administrator. I get the following result from the above command:
{
"hasErrors": true,
"results": [
{
"referenceId": "MediaQualitySetJunction__cRef1",
"errors": [
{
"statusCode": "INVALID_FIELD",
"message": "Cannot reference a foreign key field MediaQuality__r.",
"fields": []
},
{
"statusCode": "INVALID_FIELD",
"message": "Cannot reference a foreign key field MediaQualitySet__r.",
"fields": []
}
]
}
]
}
How do I solve this?