[MDSAL-161] Leaf of union type in grouping does not work as key in list Created: 02/May/16  Updated: 05/May/21  Resolved: 25/Feb/18

Status: Resolved
Project: mdsal
Component/s: Binding codegen
Affects Version/s: Oxygen, Nitrogen SR1, Carbon SR2
Fix Version/s: Oxygen, Nitrogen SR2, Carbon SR4

Type: Bug
Reporter: Jakub Morvay Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Blocks
is blocked by MDSAL-237 Milestone: Implement Binding Specific... Resolved
External issue ID: 5826

 Description   

If you use a leaf from grouping of type union as a key in list, binding generates key class without that leaf as part of key.

 

grouping common-cars {
  leaf brand {
    type union {
      type uint64;
      type string;
    }

  }
  leaf engine { type string; }
  leaf gearbox { type string; }
}
container cars {
  list car {
    key "brand";
    uses common-cars;
  }

}

 

From this yang we get empty key binding class

 

public class CarKey
  implements Identifier<Car> {
  private static final long serialVersionUID = -7229666078144872030L;
  public CarKey() {
  }
}

 

Simple workaround is to not use grouping. You can also define your own type with the appropriate union type as the base type and use this new type as a type for leaf in grouping.



 Comments   
Comment by Filip Gregor [ 17/May/16 ]

This will be fixed in binding spec v2. Union is generated as inner class from grouping and this causes duplicate getters. This will not occur in binding spec v2.

Comment by Robert Varga [ 01/Feb/18 ]

Filip's analysis is utterly incorrect. The problem is that the return type is not found when we are searching for the key definition, as that codepath is looking only into public type definitions, not inner types. The correct fix is to publish inner types into ModuleContext just as we do for inner enums and then look those definitions up.

Oxygen: https://git.opendaylight.org/gerrit/67826

Comment by Robert Varga [ 05/Feb/18 ]

Carbon: https://git.opendaylight.org/gerrit/67918

Nitrogen: https://git.opendaylight.org/gerrit/67917

 

Generated at Wed Feb 07 20:08:48 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.