Skip to content

Commit

Permalink
[Bug]: 当公式字段中引用的字段值在before触发器中赋值时会导致公式计算不准 #6860
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlianghui committed May 20, 2024
1 parent 32cf72d commit 8e3f33f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/objectql/src/types/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,12 @@ export class SteedosObjectType extends SteedosObjectProperties {
args.splice(args.length - 1, 1, userSession ? userSession.userId : undefined)
returnValue = await adapterMethod.apply(this._datasource, args);
} else {
let beforeTriggerContext = await this.getTriggerContext('before', method, args)
if (paramRecordId) {
beforeTriggerContext = Object.assign({} , beforeTriggerContext, { id: paramRecordId });
}
await this.runBeforeTriggers(method, beforeTriggerContext)

let previousDoc: any;
// update/delete时始终查一次整个record doc,公式中依赖了完整doc(比如单元格编辑等情况下doc不完整),after trigger中需要previousDoc
if (method === 'update' || method === 'delete') {
Expand All @@ -2251,11 +2257,7 @@ export class SteedosObjectType extends SteedosObjectProperties {
if(docAfterFormulaRun){
Object.assign(doc, docAfterFormulaRun);
}
let beforeTriggerContext = await this.getTriggerContext('before', method, args)
if (paramRecordId) {
beforeTriggerContext = Object.assign({} , beforeTriggerContext, { id: paramRecordId });
}
await this.runBeforeTriggers(method, beforeTriggerContext)

await runValidationRules(method, beforeTriggerContext, args[0], userSession)
let afterTriggerContext = await this.getTriggerContext('after', method, args)
if (method === 'update' || method === 'delete') {
Expand Down

0 comments on commit 8e3f33f

Please sign in to comment.