tree data UPDATE require equal anchor and moved node schema
In other cases it is difficult to verify that the move
is allowed.
@@ -2830,8 +2830,8 @@ lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node)
LOGERR(LYD_CTX(sibling), LY_EINVAL, "Can be used only for user-ordered nodes.");
return LY_EINVAL;
}
- if (lysc_is_key(sibling->schema)) {
- LOGERR(LYD_CTX(sibling), LY_EINVAL, "Cannot insert before keys.");
+ if (node->schema && sibling->schema && (node->schema != sibling->schema)) {
+ LOGERR(LYD_CTX(sibling), LY_EINVAL, "Cannot insert before a different schema node instance.");
return LY_EINVAL;
}
@@ -2854,8 +2854,8 @@ lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node)
LOGERR(LYD_CTX(sibling), LY_EINVAL, "Can be used only for user-ordered nodes.");
return LY_EINVAL;
}
- if (sibling->next && lysc_is_key(sibling->next->schema)) {
- LOGERR(LYD_CTX(sibling), LY_EINVAL, "Cannot insert before keys.");
+ if (node->schema && sibling->schema && (node->schema != sibling->schema)) {
+ LOGERR(LYD_CTX(sibling), LY_EINVAL, "Cannot insert after a different schema node instance.");
return LY_EINVAL;
}
