isRelationshipKey method
If the keys are a single relationship field of entityHandler's
entity: a to-one (an entity, User? owner, or an EntityReference) or
a to-many (a List of entities or an EntityReferenceList). Not a
path through one (owner.email), nor a field of another type.
A relationship is compared by the IDs of its related entities, and it
never has a null ID: so a null element of a =~/!~ list
(=~ [1, null], =~ [null]) is ignored (for another field, it matches
a null, as IS NULL). As any field, =~ null (or a null
parameter) is an empty set (=~ matches none, !~ all, as with []),
and ==/!= with [] are with null ("without related entities" /
"with some").
Cached per entityHandler (see _isRelationshipKeyCacheHandler).
Implementation
bool isRelationshipKey(EntityHandler? entityHandler) {
if (identical(entityHandler, _isRelationshipKeyCacheHandler)) {
return _isRelationshipKeyCacheResult ?? false;
}
var relationship = false;
var key = keys.length == 1 ? keys.first : null;
if (entityHandler != null && key is ConditionKeyField) {
var type = entityHandler.getFieldType(
null,
key.name,
resolveFiledName: true,
);
if (type != null) {
relationship = isRelationshipType(type, entityHandler);
}
}
_isRelationshipKeyCacheHandler = entityHandler;
_isRelationshipKeyCacheResult = relationship;
return relationship;
}