编译器处理了Schema继承过程中的多次引用问题
This commit is contained in:
parent
68289a281e
commit
6ae7235a5a
|
|
@ -30,11 +30,21 @@ const ActionImportStatements = () => [
|
||||||
const StyleAsts = {};
|
const StyleAsts = {};
|
||||||
const ActionAsts = {};
|
const ActionAsts = {};
|
||||||
const SchemaAsts = {};
|
const SchemaAsts = {};
|
||||||
|
/**
|
||||||
|
* 部分项目目前存在引用了Schema但是不依赖于其包,因此目前先在此去重。
|
||||||
|
* 后续要修正这种行为,让继承的schema分层编译
|
||||||
|
* @param many
|
||||||
|
* @param one
|
||||||
|
* @param key
|
||||||
|
* @param notNull
|
||||||
|
*/
|
||||||
function addRelationship(many, one, key, notNull) {
|
function addRelationship(many, one, key, notNull) {
|
||||||
const { [many]: manySet } = ManyToOne;
|
const { [many]: manySet } = ManyToOne;
|
||||||
const one2 = one === 'Schema' ? many : one;
|
const one2 = one === 'Schema' ? many : one;
|
||||||
if (manySet) {
|
if (manySet) {
|
||||||
manySet.push([one2, key, notNull]);
|
if (!manySet.find(ele => ele[1] === key && ele[0] === one2)) {
|
||||||
|
manySet.push([one2, key, notNull]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(0, lodash_1.assign)(ManyToOne, {
|
(0, lodash_1.assign)(ManyToOne, {
|
||||||
|
|
@ -43,7 +53,9 @@ function addRelationship(many, one, key, notNull) {
|
||||||
}
|
}
|
||||||
const { [one2]: oneSet } = OneToMany;
|
const { [one2]: oneSet } = OneToMany;
|
||||||
if (oneSet) {
|
if (oneSet) {
|
||||||
oneSet.push([many, key, notNull]);
|
if (!oneSet.find(ele => ele[1] === key && ele[0] === many)) {
|
||||||
|
oneSet.push([many, key, notNull]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(0, lodash_1.assign)(OneToMany, {
|
(0, lodash_1.assign)(OneToMany, {
|
||||||
|
|
@ -676,7 +688,9 @@ function analyzeSchemaDefinition(node, moduleName, filename, path, program, refe
|
||||||
// 这也是一对多的反指定义
|
// 这也是一对多的反指定义
|
||||||
const reverseEntity = typeName.text;
|
const reverseEntity = typeName.text;
|
||||||
if (ReversePointerRelations[reverseEntity]) {
|
if (ReversePointerRelations[reverseEntity]) {
|
||||||
ReversePointerRelations[reverseEntity].push(moduleName);
|
if (!ReversePointerRelations[reverseEntity].includes(moduleName)) {
|
||||||
|
ReversePointerRelations[reverseEntity].push(moduleName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(0, lodash_1.assign)(ReversePointerRelations, {
|
(0, lodash_1.assign)(ReversePointerRelations, {
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
function addRelationship(many: string, one: string, key: string, notNull: boolean) {
|
||||||
const { [many]: manySet } = ManyToOne;
|
const { [many]: manySet } = ManyToOne;
|
||||||
const one2 = one === 'Schema' ? many : one;
|
const one2 = one === 'Schema' ? many : one;
|
||||||
if (manySet) {
|
if (manySet) {
|
||||||
manySet.push([one2, key, notNull]);
|
if (!manySet.find(ele => ele[1] === key && ele[0] === one2)) {
|
||||||
|
manySet.push([one2, key, notNull]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assign(ManyToOne, {
|
assign(ManyToOne, {
|
||||||
|
|
@ -136,7 +146,9 @@ function addRelationship(many: string, one: string, key: string, notNull: boolea
|
||||||
|
|
||||||
const { [one2]: oneSet } = OneToMany;
|
const { [one2]: oneSet } = OneToMany;
|
||||||
if (oneSet) {
|
if (oneSet) {
|
||||||
oneSet.push([many, key, notNull]);
|
if (!oneSet.find(ele => ele[1] === key && ele[0] === many)) {
|
||||||
|
oneSet.push([many, key, notNull]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assign(OneToMany, {
|
assign(OneToMany, {
|
||||||
|
|
@ -936,7 +948,9 @@ function analyzeSchemaDefinition(
|
||||||
// 这也是一对多的反指定义
|
// 这也是一对多的反指定义
|
||||||
const reverseEntity = typeName.text;
|
const reverseEntity = typeName.text;
|
||||||
if (ReversePointerRelations[reverseEntity]) {
|
if (ReversePointerRelations[reverseEntity]) {
|
||||||
ReversePointerRelations[reverseEntity].push(moduleName);
|
if (!ReversePointerRelations[reverseEntity].includes(moduleName)) {
|
||||||
|
ReversePointerRelations[reverseEntity].push(moduleName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assign(ReversePointerRelations, {
|
assign(ReversePointerRelations, {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue