diff --git a/lib/compiler/schemalBuilder.js b/lib/compiler/schemalBuilder.js index bb9454b..1e0633b 100644 --- a/lib/compiler/schemalBuilder.js +++ b/lib/compiler/schemalBuilder.js @@ -30,11 +30,21 @@ const ActionImportStatements = () => [ const StyleAsts = {}; const ActionAsts = {}; const SchemaAsts = {}; +/** + * 部分项目目前存在引用了Schema但是不依赖于其包,因此目前先在此去重。 + * 后续要修正这种行为,让继承的schema分层编译 + * @param many + * @param one + * @param key + * @param notNull + */ function addRelationship(many, one, key, notNull) { const { [many]: manySet } = ManyToOne; const one2 = one === 'Schema' ? many : one; if (manySet) { - manySet.push([one2, key, notNull]); + if (!manySet.find(ele => ele[1] === key && ele[0] === one2)) { + manySet.push([one2, key, notNull]); + } } else { (0, lodash_1.assign)(ManyToOne, { @@ -43,7 +53,9 @@ function addRelationship(many, one, key, notNull) { } const { [one2]: oneSet } = OneToMany; if (oneSet) { - oneSet.push([many, key, notNull]); + if (!oneSet.find(ele => ele[1] === key && ele[0] === many)) { + oneSet.push([many, key, notNull]); + } } else { (0, lodash_1.assign)(OneToMany, { @@ -676,7 +688,9 @@ function analyzeSchemaDefinition(node, moduleName, filename, path, program, refe // 这也是一对多的反指定义 const reverseEntity = typeName.text; if (ReversePointerRelations[reverseEntity]) { - ReversePointerRelations[reverseEntity].push(moduleName); + if (!ReversePointerRelations[reverseEntity].includes(moduleName)) { + ReversePointerRelations[reverseEntity].push(moduleName); + } } else { (0, lodash_1.assign)(ReversePointerRelations, { diff --git a/src/compiler/schemalBuilder.ts b/src/compiler/schemalBuilder.ts index 4825a22..d50398d 100644 --- a/src/compiler/schemalBuilder.ts +++ b/src/compiler/schemalBuilder.ts @@ -122,11 +122,21 @@ const SchemaAsts: { }; } = {}; +/** + * 部分项目目前存在引用了Schema但是不依赖于其包,因此目前先在此去重。 + * 后续要修正这种行为,让继承的schema分层编译 + * @param many + * @param one + * @param key + * @param notNull + */ function addRelationship(many: string, one: string, key: string, notNull: boolean) { const { [many]: manySet } = ManyToOne; const one2 = one === 'Schema' ? many : one; if (manySet) { - manySet.push([one2, key, notNull]); + if (!manySet.find(ele => ele[1] === key && ele[0] === one2)) { + manySet.push([one2, key, notNull]); + } } else { assign(ManyToOne, { @@ -136,7 +146,9 @@ function addRelationship(many: string, one: string, key: string, notNull: boolea const { [one2]: oneSet } = OneToMany; if (oneSet) { - oneSet.push([many, key, notNull]); + if (!oneSet.find(ele => ele[1] === key && ele[0] === many)) { + oneSet.push([many, key, notNull]); + } } else { assign(OneToMany, { @@ -936,7 +948,9 @@ function analyzeSchemaDefinition( // 这也是一对多的反指定义 const reverseEntity = typeName.text; if (ReversePointerRelations[reverseEntity]) { - ReversePointerRelations[reverseEntity].push(moduleName); + if (!ReversePointerRelations[reverseEntity].includes(moduleName)) { + ReversePointerRelations[reverseEntity].push(moduleName); + } } else { assign(ReversePointerRelations, {