|
|
@ -3491,7 +3491,7 @@ class BaseModelSqlv2 { |
|
|
|
rowId, |
|
|
|
rowId, |
|
|
|
}: { |
|
|
|
}: { |
|
|
|
cookie: any; |
|
|
|
cookie: any; |
|
|
|
childIds: string | string[] | number | number[]; |
|
|
|
childIds: (string|number)[]; |
|
|
|
colId: string; |
|
|
|
colId: string; |
|
|
|
rowId: string; |
|
|
|
rowId: string; |
|
|
|
}) { |
|
|
|
}) { |
|
|
@ -3525,7 +3525,8 @@ class BaseModelSqlv2 { |
|
|
|
if (this.isSnowflake) { |
|
|
|
if (this.isSnowflake) { |
|
|
|
const parentPK = this.dbDriver(parentTn) |
|
|
|
const parentPK = this.dbDriver(parentTn) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.where(_wherePk(parentTable.primaryKeys, childId)) |
|
|
|
// .where(_wherePk(parentTable.primaryKeys, childId))
|
|
|
|
|
|
|
|
.whereIn(parentTable.primaryKey.column_name, childIds) |
|
|
|
.first(); |
|
|
|
.first(); |
|
|
|
|
|
|
|
|
|
|
|
const childPK = this.dbDriver(childTn) |
|
|
|
const childPK = this.dbDriver(childTn) |
|
|
@ -3541,7 +3542,8 @@ class BaseModelSqlv2 { |
|
|
|
await this.dbDriver(vTn).insert({ |
|
|
|
await this.dbDriver(vTn).insert({ |
|
|
|
[vParentCol.column_name]: this.dbDriver(parentTn) |
|
|
|
[vParentCol.column_name]: this.dbDriver(parentTn) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.where(_wherePk(parentTable.primaryKeys, childId)) |
|
|
|
// .where(_wherePk(parentTable.primaryKeys, childId))
|
|
|
|
|
|
|
|
.where(parentTable.primaryKey.column_name, childIds) |
|
|
|
.first(), |
|
|
|
.first(), |
|
|
|
[vChildCol.column_name]: this.dbDriver(childTn) |
|
|
|
[vChildCol.column_name]: this.dbDriver(childTn) |
|
|
|
.select(childColumn.column_name) |
|
|
|
.select(childColumn.column_name) |
|
|
@ -3563,7 +3565,8 @@ class BaseModelSqlv2 { |
|
|
|
.as('___cn_alias'), |
|
|
|
.as('___cn_alias'), |
|
|
|
), |
|
|
|
), |
|
|
|
}) |
|
|
|
}) |
|
|
|
.where(_wherePk(childTable.primaryKeys, childId)); |
|
|
|
// .where(_wherePk(childTable.primaryKeys, childId));
|
|
|
|
|
|
|
|
.whereIn(childTable.primaryKey.column_name, childIds); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
@ -3573,7 +3576,8 @@ class BaseModelSqlv2 { |
|
|
|
[childColumn.column_name]: this.dbDriver.from( |
|
|
|
[childColumn.column_name]: this.dbDriver.from( |
|
|
|
this.dbDriver(parentTn) |
|
|
|
this.dbDriver(parentTn) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.where(_wherePk(parentTable.primaryKeys, childId)) |
|
|
|
// .where(_wherePk(parentTable.primaryKeys, childId))
|
|
|
|
|
|
|
|
.whereIn(parentTable.primaryKey.column_name, childIds) |
|
|
|
.first() |
|
|
|
.first() |
|
|
|
.as('___cn_alias'), |
|
|
|
.as('___cn_alias'), |
|
|
|
), |
|
|
|
), |
|
|
@ -3583,9 +3587,9 @@ class BaseModelSqlv2 { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const response = await this.readByPk(rowId); |
|
|
|
// const response = await this.readByPk(rowId);
|
|
|
|
await this.afterInsert(response, this.dbDriver, cookie); |
|
|
|
// await this.afterInsert(response, this.dbDriver, cookie);
|
|
|
|
await this.afterAddChild(rowId, childId, cookie); |
|
|
|
// await this.afterAddChild(rowId, childId, cookie);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async removeLinks({ |
|
|
|
async removeLinks({ |
|
|
@ -3595,7 +3599,7 @@ class BaseModelSqlv2 { |
|
|
|
rowId, |
|
|
|
rowId, |
|
|
|
}: { |
|
|
|
}: { |
|
|
|
cookie: any; |
|
|
|
cookie: any; |
|
|
|
childIds: string | string[] | number | number[]; |
|
|
|
childIds: (string|number)[]; |
|
|
|
colId: string; |
|
|
|
colId: string; |
|
|
|
rowId: string; |
|
|
|
rowId: string; |
|
|
|
}) { |
|
|
|
}) { |
|
|
@ -3632,7 +3636,7 @@ class BaseModelSqlv2 { |
|
|
|
.where({ |
|
|
|
.where({ |
|
|
|
[vParentCol.column_name]: this.dbDriver(parentTn) |
|
|
|
[vParentCol.column_name]: this.dbDriver(parentTn) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.where(_wherePk(parentTable.primaryKeys, childId)) |
|
|
|
.whereIn(parentTable.primaryKey.column_name,childIds) |
|
|
|
.first(), |
|
|
|
.first(), |
|
|
|
[vChildCol.column_name]: this.dbDriver(childTn) |
|
|
|
[vChildCol.column_name]: this.dbDriver(childTn) |
|
|
|
.select(childColumn.column_name) |
|
|
|
.select(childColumn.column_name) |
|
|
@ -3651,7 +3655,8 @@ class BaseModelSqlv2 { |
|
|
|
// .where(parentTable.primaryKey.cn, rowId)
|
|
|
|
// .where(parentTable.primaryKey.cn, rowId)
|
|
|
|
// .first()
|
|
|
|
// .first()
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
.where(_wherePk(childTable.primaryKeys, childId)) |
|
|
|
// .where(_wherePk(childTable.primaryKeys, childId))
|
|
|
|
|
|
|
|
.whereIn(childTable.primaryKey.column_name, childIds) |
|
|
|
.update({ [childColumn.column_name]: null }); |
|
|
|
.update({ [childColumn.column_name]: null }); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
@ -3664,15 +3669,16 @@ class BaseModelSqlv2 { |
|
|
|
// .where(parentTable.primaryKey.cn, childId)
|
|
|
|
// .where(parentTable.primaryKey.cn, childId)
|
|
|
|
// .first()
|
|
|
|
// .first()
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
.where(_wherePk(childTable.primaryKeys, rowId)) |
|
|
|
// .where(_wherePk(childTable.primaryKeys, rowId))
|
|
|
|
|
|
|
|
.where(childTable.primaryKey.column_name, rowId) |
|
|
|
.update({ [childColumn.column_name]: null }); |
|
|
|
.update({ [childColumn.column_name]: null }); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const newData = await this.readByPk(rowId); |
|
|
|
// const newData = await this.readByPk(rowId);
|
|
|
|
await this.afterUpdate(prevData, newData, this.dbDriver, cookie); |
|
|
|
// await this.afterUpdate(prevData, newData, this.dbDriver, cookie);
|
|
|
|
await this.afterRemoveChild(rowId, childId, cookie); |
|
|
|
// await this.afterRemoveChild(rowId, childIds, cookie);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|