处理了remove/update时,opRecords中可能不记录此operation的情况(实际更新行数为空)
This commit is contained in:
parent
597200f5df
commit
9ac752687a
|
|
@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const entityDesc = {
|
||||
locales: {
|
||||
zh_CN: {
|
||||
name: '用户授权',
|
||||
name: 'i18n',
|
||||
attr: {
|
||||
module: '模块',
|
||||
position: '文件位置',
|
||||
|
|
|
|||
|
|
@ -253,10 +253,13 @@ class TriggerExecutor {
|
|||
cxtStr2 = data.$$triggerData$$?.cxtStr;
|
||||
}
|
||||
const record = opRecords.find(ele => ele.id === operation.id);
|
||||
// 目前框架在operation时,一定会将ids记录在operation当中(见CascadeStore中的doUpdateSingleRowAsync函数
|
||||
(0, assert_1.default)(record && record.a !== 'c');
|
||||
const { f } = record;
|
||||
ids = f.id.$in;
|
||||
if (record) {
|
||||
// 目前框架在operation时,一定会将ids记录在operation当中(见CascadeStore中的doUpdateSingleRowAsync函数
|
||||
// 但也有一种可能,此operation没有更新任何一行。by Xc 20241022
|
||||
(0, assert_1.default)(record.a !== 'c');
|
||||
const { f } = record;
|
||||
ids = f.id.$in;
|
||||
}
|
||||
}
|
||||
// 此时项目的上下文,和执行此trigger时的上下文可能不一致(rootMode),采用当时的上下文cxtStr来执行
|
||||
this.onVolatileTrigger(entity, trigger, ids, cxtStr2, option);
|
||||
|
|
@ -348,12 +351,12 @@ class TriggerExecutor {
|
|||
async execVolatileTrigger(entity, name, ids, context, option) {
|
||||
const trigger = this.triggerNameMap[name];
|
||||
(0, assert_1.default)(trigger && trigger.when === 'commit');
|
||||
(0, assert_1.default)(ids.length > 0);
|
||||
// assert(ids.length > 0);
|
||||
const { fn } = trigger;
|
||||
const closeRoot = trigger.asRoot && context.openRootMode();
|
||||
try {
|
||||
const callback = await fn({ ids }, context, option);
|
||||
if (trigger.strict === 'makeSure') {
|
||||
if (trigger.strict === 'makeSure' && ids.length) {
|
||||
// 这里开root模式,否则还可能有权限问题
|
||||
const closeRoot2 = context.openRootMode();
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export interface Schema extends EntityShape {
|
|||
const entityDesc: EntityDesc<Schema> = {
|
||||
locales: {
|
||||
zh_CN: {
|
||||
name: '用户授权',
|
||||
name: 'i18n',
|
||||
attr: {
|
||||
module: '模块',
|
||||
position: '文件位置',
|
||||
|
|
|
|||
|
|
@ -321,10 +321,13 @@ export class TriggerExecutor<ED extends EntityDict & BaseEntityDict, Cxt extends
|
|||
const record = opRecords.find(
|
||||
ele => (ele as CreateOpResult<ED, keyof ED>).id === operation.id,
|
||||
);
|
||||
// 目前框架在operation时,一定会将ids记录在operation当中(见CascadeStore中的doUpdateSingleRowAsync函数
|
||||
assert(record && record.a !== 'c');
|
||||
const { f } = record as UpdateOpResult<ED, keyof ED>;
|
||||
ids = f!.id!.$in;
|
||||
if (record) {
|
||||
// 目前框架在operation时,一定会将ids记录在operation当中(见CascadeStore中的doUpdateSingleRowAsync函数
|
||||
// 但也有一种可能,此operation没有更新任何一行。by Xc 20241022
|
||||
assert(record.a !== 'c');
|
||||
const { f } = record as UpdateOpResult<ED, keyof ED>;
|
||||
ids = f!.id!.$in;
|
||||
}
|
||||
}
|
||||
// 此时项目的上下文,和执行此trigger时的上下文可能不一致(rootMode),采用当时的上下文cxtStr来执行
|
||||
this.onVolatileTrigger(entity, trigger, ids, cxtStr2, option);
|
||||
|
|
@ -439,13 +442,13 @@ export class TriggerExecutor<ED extends EntityDict & BaseEntityDict, Cxt extends
|
|||
) {
|
||||
const trigger = this.triggerNameMap[name];
|
||||
assert(trigger && trigger.when === 'commit');
|
||||
assert(ids.length > 0);
|
||||
// assert(ids.length > 0);
|
||||
const { fn } = trigger as VolatileTrigger<ED, T, Cxt>;
|
||||
|
||||
const closeRoot = trigger.asRoot && context.openRootMode();
|
||||
try {
|
||||
const callback = await fn({ ids }, context, option);
|
||||
if (trigger.strict === 'makeSure') {
|
||||
if (trigger.strict === 'makeSure' && ids.length) {
|
||||
// 这里开root模式,否则还可能有权限问题
|
||||
const closeRoot2 = context.openRootMode();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue