IsRelational determines if a given permission corresponds to a relational attribute in the provided entity definition.
(en *base.EntityDefinition, permission string)
| 353 | // IsRelational determines if a given permission corresponds to a relational attribute |
| 354 | // in the provided entity definition. |
| 355 | func IsRelational(en *base.EntityDefinition, permission string) bool { |
| 356 | // Default to non-relational |
| 357 | isRelational := false |
| 358 | |
| 359 | // Attempt to get the type of reference for the given permission in the entity definition |
| 360 | tor, err := schema.GetTypeOfReferenceByNameInEntityDefinition(en, permission) |
| 361 | if err == nil && tor != base.EntityDefinition_REFERENCE_ATTRIBUTE { |
| 362 | // If the type of reference is anything other than REFERENCE_ATTRIBUTE, |
| 363 | // treat it as a relational attribute |
| 364 | isRelational = true |
| 365 | } |
| 366 | |
| 367 | return isRelational |
| 368 | } |
no test coverage detected