Commit c238422
Fix leaf-list validation when it is a relative path leafref (#626)
* workaround leafref validation
* as commented by @wenovus in #623
The fix is essentially correct: we handle the case of lists (a single level in YANG)
being represented as two levels in Go (map -> element), but don't handle the case of
leaf-lists also being represented as two levels in Go (slice -> element).
The "two levels" is how ForEachField processes elements, which creates this
corner case for DataNodeAtPath.
It turns out we already had a test case for this but it had an extra "../" s
o it was testing the wrong behaviour.
* Do not trim compressed path elements for maps or slices.
Currently, we trim the path for a `map[]{}` or slice type in Go for
lists in order to prevent the list's name from appearing twice in the
data tree while traversing a list element. This is because
`forEachFieldInternal` currently creates new `NodeInfo` elements,
copying the list name, when traversing list elements.
Based on the tests that fail, this behaviour apparently tries to solve
the problem of processing "../" when calling `ytypes.dataNodesAtPath`,
but the logic in there incorrectly identifies compression to be the
issue: compression is indeed not the issue, but rather how slices and
maps are processed in two levels -- slices and maps exist equally in
compressed and uncompressed generated code.
This PR removes the dependency of existing logic on schema compression,
but rather on whether the current element is a map or a slice,
corresponding to a YANG list or leaf-list, and in such cases, it skips
that extra level created by `forEachFieldInternal` instead. This results
in slightly simpler, and much more understandable logic with the comment
updates.
* try using go install
* misspelling
* Add a sentence on why compression is not involved
Co-authored-by: Hans Thienpondt <[email protected]>1 parent 444fa8c commit c238422
File tree
4 files changed
+169
-27
lines changed- util
- ytypes
4 files changed
+169
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | 684 | | |
691 | 685 | | |
692 | 686 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1029 | 1029 | | |
1030 | 1030 | | |
1031 | 1031 | | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
1032 | 1040 | | |
1033 | 1041 | | |
1034 | 1042 | | |
| |||
1152 | 1160 | | |
1153 | 1161 | | |
1154 | 1162 | | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
1155 | 1224 | | |
1156 | 1225 | | |
1157 | 1226 | | |
| |||
1203 | 1272 | | |
1204 | 1273 | | |
1205 | 1274 | | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
1206 | 1293 | | |
1207 | 1294 | | |
1208 | 1295 | | |
| |||
1221 | 1308 | | |
1222 | 1309 | | |
1223 | 1310 | | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
1224 | 1329 | | |
1225 | 1330 | | |
1226 | 1331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
198 | 199 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 200 | + | |
| 201 | + | |
209 | 202 | | |
210 | 203 | | |
211 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
| 339 | + | |
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
570 | 575 | | |
571 | 576 | | |
572 | 577 | | |
573 | 578 | | |
574 | 579 | | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
575 | 585 | | |
576 | 586 | | |
577 | 587 | | |
| |||
620 | 630 | | |
621 | 631 | | |
622 | 632 | | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
623 | 642 | | |
624 | 643 | | |
625 | 644 | | |
| |||
628 | 647 | | |
629 | 648 | | |
630 | 649 | | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
631 | 659 | | |
632 | 660 | | |
633 | 661 | | |
| |||
650 | 678 | | |
651 | 679 | | |
652 | 680 | | |
653 | | - | |
654 | | - | |
655 | | - | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
656 | 686 | | |
657 | 687 | | |
658 | 688 | | |
| |||
712 | 742 | | |
713 | 743 | | |
714 | 744 | | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
715 | 759 | | |
716 | 760 | | |
717 | 761 | | |
718 | 762 | | |
719 | 763 | | |
720 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
721 | 771 | | |
722 | 772 | | |
723 | 773 | | |
| |||
0 commit comments