Skip to content

Commit 2063f20

Browse files
committed
schema compile UPDATE allow deviate-replace implicit properties
Fixes #2212
1 parent ed27758 commit 2063f20

File tree

2 files changed

+1
-36
lines changed

2 files changed

+1
-36
lines changed

src/schema_compile_amend.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author Michal Vasko <[email protected]>
55
* @brief Schema compilation of augments, deviations, and refines.
66
*
7-
* Copyright (c) 2015 - 2021 CESNET, z.s.p.o.
7+
* Copyright (c) 2015 - 2024 CESNET, z.s.p.o.
88
*
99
* This source code is licensed under BSD 3-Clause License (the "License").
1010
* You may not use this file except in compliance with the License.
@@ -1499,13 +1499,6 @@ lys_apply_deviate_replace(struct lysc_ctx *ctx, struct lysp_deviate_rpl *d, stru
14991499
AMEND_WRONG_NODETYPE("deviation", "replace", "mandatory");
15001500
}
15011501

1502-
if (!(target->flags & LYS_MAND_MASK)) {
1503-
LOGVAL(ctx->ctx, LY_VCODE_DEV_NOT_PRESENT, "replacing", "mandatory",
1504-
d->flags & LYS_MAND_TRUE ? "mandatory true" : "mandatory false");
1505-
ret = LY_EVALID;
1506-
goto cleanup;
1507-
}
1508-
15091502
target->flags &= ~LYS_MAND_MASK;
15101503
target->flags |= d->flags & LYS_MAND_MASK;
15111504
}
@@ -1523,12 +1516,6 @@ lys_apply_deviate_replace(struct lysc_ctx *ctx, struct lysp_deviate_rpl *d, stru
15231516
AMEND_WRONG_NODETYPE("deviation", "replace", "min-elements");
15241517
}
15251518

1526-
if (!(target->flags & LYS_SET_MIN)) {
1527-
LOGVAL(ctx->ctx, LYVE_REFERENCE, "Invalid deviation replacing \"min-elements\" property which is not present.");
1528-
ret = LY_EVALID;
1529-
goto cleanup;
1530-
}
1531-
15321519
*num = d->min;
15331520
}
15341521

@@ -1545,12 +1532,6 @@ lys_apply_deviate_replace(struct lysc_ctx *ctx, struct lysp_deviate_rpl *d, stru
15451532
AMEND_WRONG_NODETYPE("deviation", "replace", "max-elements");
15461533
}
15471534

1548-
if (!(target->flags & LYS_SET_MAX)) {
1549-
LOGVAL(ctx->ctx, LYVE_REFERENCE, "Invalid deviation replacing \"max-elements\" property which is not present.");
1550-
ret = LY_EVALID;
1551-
goto cleanup;
1552-
}
1553-
15541535
*num = d->max;
15551536
}
15561537

tests/utests/schema/test_tree_schema_compile.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,10 +3607,6 @@ test_deviation(void **state)
36073607
"deviation /top {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
36083608
CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to replace \"mandatory\" property.",
36093609
"/kk2:{deviation='/top'}", 0);
3610-
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk3 {namespace urn:kk3;prefix kk3; container top {leaf x {type string;}}"
3611-
"deviation /top/x {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
3612-
CHECK_LOG_CTX("Invalid deviation replacing \"mandatory\" property \"mandatory true\" which is not present.",
3613-
"/kk3:{deviation='/top/x'}", 0);
36143610
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk4 {namespace urn:kk4;prefix kk4; leaf x {mandatory true; type string;}"
36153611
"deviation /x {deviate add {mandatory false;}}}", LYS_IN_YANG, &mod));
36163612
CHECK_LOG_CTX("Invalid deviation adding \"mandatory\" property which already exists (with value \"mandatory true\").",
@@ -3661,18 +3657,6 @@ test_deviation(void **state)
36613657
"deviation /x {deviate add {max-elements 1;}}}", LYS_IN_YANG, &mod));
36623658
CHECK_LOG_CTX("Invalid deviation adding \"max-elements\" property which already exists (with value \"5\").",
36633659
"/mm8:{deviation='/x'}", 0);
3664-
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm9 {namespace urn:mm9;prefix mm9; leaf-list x {type string;}"
3665-
"deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
3666-
CHECK_LOG_CTX("Invalid deviation replacing \"min-elements\" property which is not present.", "/mm9:{deviation='/x'}", 0);
3667-
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm10 {namespace urn:mm10;prefix mm10; list x {config false;}"
3668-
"deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
3669-
CHECK_LOG_CTX("Invalid deviation replacing \"min-elements\" property which is not present.", "/mm10:{deviation='/x'}", 0);
3670-
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm11 {namespace urn:mm11;prefix mm11; leaf-list x {type string;}"
3671-
"deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
3672-
CHECK_LOG_CTX("Invalid deviation replacing \"max-elements\" property which is not present.", "/mm11:{deviation='/x'}", 0);
3673-
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm12 {namespace urn:mm12;prefix mm12; list x {config false; }"
3674-
"deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
3675-
CHECK_LOG_CTX("Invalid deviation replacing \"max-elements\" property which is not present.", "/mm12:{deviation='/x'}", 0);
36763660

36773661
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module nn1 {namespace urn:nn1;prefix nn1; anyxml x;"
36783662
"deviation /x {deviate replace {type string;}}}", LYS_IN_YANG, &mod));

0 commit comments

Comments
 (0)