Uploaded image for project: 'mdsal'
  1. mdsal
  2. MDSAL-161

Leaf of union type in grouping does not work as key in list

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Oxygen, Nitrogen SR2, Carbon SR4
    • Oxygen, Nitrogen SR1, Carbon SR2
    • Binding codegen
    • None
    • Operating System: All
      Platform: All

    • 5826

      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.

            rovarga Robert Varga
            jmorvay@cisco.com Jakub Morvay
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: