[YANGTOOLS-824] A non-presence container has at least one mandatory child node shoud be set mandatory true ? Created: 31/Oct/17 Updated: 26/Dec/17 Resolved: 26/Dec/17 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | 2.0.0 |
| Fix Version/s: | 2.0.0 |
| Type: | Bug | Priority: | Medium |
| Reporter: | Jie Han | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
According to RFC rules: Currently , it is false, IMO all ancestor nodes of a mandatory node should set mandatory to be true as default. |
| Comments |
| Comment by Robert Varga [ 31/Oct/17 ] |
|
This really is a question on what isMandatory() reflects. Historically it reflected the presence of a mandatory statement, e.g. the declared model of the world. Making it reflect the reality of effective world is problematic, as it is not a static property, consider e.g.: grouping grp { } leaf bar { type string; }container baz { } |
| Comment by Jie Han [ 31/Oct/17 ] |
|
Yep, anyway, when "mandatory" meets "when", it's not clear and confusing what mandatory does reflect. |
| Comment by Robert Varga [ 31/Oct/17 ] |
|
Ah, I see, I missed those bits. Incidentally I came across isMandatory() just yesterday during the push to cleanup yang-model-api and it still is on my plate. In the end, I think isMandatory() should reflect whether or not a node is effectively mandatory, if it can be proven to be static property and if we can get users working (yang-model-export may need a major update to work completely on the declared model anyway, but there may be others0. |
| Comment by Robert Varga [ 31/Oct/17 ] |
|
Actually that will not completely work, either. Even if we expand the scope of that uses restriction to cover mandatory nodes, it does not solve augmentations, which may explicitly add mandatory nodes only when guarded by a when conditions: module foo: module bar: ; augment /foo:foo { when "../bar"; This case is specifically called out in RFC7950, hence isMandatory() cannot be made a static property, because the intepretation of augment applicability (and hence the decision whether /foo is mandatory) depends on the data being processed. I will add a comment to this effect. |
| Comment by Jie Han [ 01/Nov/17 ] |
|
I also found this in RFC7950 (Section 8.1):
|
| Comment by Jie Han [ 01/Nov/17 ] |
|
In RFC7950 (Section 7.17): |
| Comment by Robert Varga [ 03/Nov/17 ] |
|
Well, I guess the primary question is what use case do we have for such a flag. isMandatory() certainly is going away from ConstraintDefinition (as that entire interface needs to go), hence isMandatory() will not be emitted for containers at all (only leaf/choice/anydata/anyxml will have it). |
| Comment by Robert Varga [ 26/Dec/17 ] |
|
Since ConstraintDefinition has been eliminated, isMandatory() reflects the value of 'mandatory' statement only, making the definition consistent. |