Field's getRelationshipOrder() is always 0 or 1
- Dominant language
- Java
- Stars
- 276
- Forks
- 223
- PR merge metrics
- No merged PRs in 30d
Description
I got an apex class that is used for determining whether a particular field of an object is part of a master-detail or a lookup relationship. It utilizes getRelationshipOrder() which has possible values {1, 0, null}.
Sample apex code where CR1__c, CR2__c are custom objects where CR2__c.CR1_CR2__c is involved in a master-detail relationship with CR1 and CR1__c.CR2_CR1_Lookup__c is involved in a lookup with CR2__c.
@isTest
public class Scratchpad {
static testMethod void printMessage(){
System.debug('Hello world!');
System.debug(Opportunity.AccountId.getDescribe().getRelationshipOrder());
System.debug(CR1__c.CR2_CR1_Lookup__c.getDescribe().getRelationshipOrder());
System.debug(CR2__c.CR1_CR2__c.getDescribe().getRelationshipOrder());
}
}
The above snippet yields the output as:
'Hello world!'
null
null
0
When the same equivalent code is run in Force's wsc connector SOAP API, it is displayed as:
'Hello world!'
0
0
0
Checking the source, Field.class
```
private int relationshipOrder;
@Override
public int getRelationshipOrder() {
return relationshipOrder;
}
@Override
public void setRelationshipOrder(int relationshipOrder) {
this.relationshipOrder = relationshipOrder;
relationshipOrder__is_set = true;
}
```
is the root cause that can never have null. Can this be fixed to accommodate what the apex does.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.