在构建updateTree时,要将可能产生的deduce关系的子树略去

This commit is contained in:
Xu Chang 2023-07-24 15:55:22 +08:00
parent 02b109d21d
commit 46627a2f37
1 changed files with 9 additions and 0 deletions

View File

@ -1737,6 +1737,14 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
};
const addChild = (node: OperationTree<ED>, path: string, child: OperationTree<ED>) => {
// 在这里要把可以被node deduce出来的child处理掉
const paths = path.split('$');
assert(paths.length === 2);
if (this.authDeduceRelationMap[child.entity] === paths[1]) {
assert(paths[1] === 'entity', '当前只支持entity外键上的deduce');
return false;
}
if (node.children[path]) {
if (node.children[path] instanceof Array) {
(node.children[path] as OperationTree<ED>[]).push(child);
@ -1750,6 +1758,7 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
[path]: child,
});
}
return true;
};
const destructInner = <T2 extends keyof ED>(entity: T2, operation: Omit<ED[T2]['Operation'], 'id'>, path?: string, child?: OperationTree<ED>, hasParent?: true): OperationTree<ED> => {