Merge branch 'main' into next

This commit is contained in:
nocobase[bot] 2024-12-21 01:50:25 +00:00
commit 1e5450c86b
2 changed files with 34 additions and 1 deletions

View File

@ -43,7 +43,7 @@ export default class extends Instruction {
const result = await repo.aggregate({ const result = await repo.aggregate({
...options, ...options,
method: aggregators[aggregator], method: aggregators[aggregator],
// transaction: processor.transaction, transaction: this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction),
}); });
return { return {

View File

@ -333,5 +333,38 @@ describe('workflow > instructions > aggregate', () => {
const [job] = await execution.getJobs(); const [job] = await execution.getJobs();
expect(job.result).toBe(1); expect(job.result).toBe(1);
}); });
it('transaction in sync workflow', async () => {
PostRepo = app.dataSourceManager.dataSources.get('another').collectionManager.getRepository('posts');
const w1 = await WorkflowModel.create({
enabled: true,
type: 'collection',
sync: true,
config: {
mode: 1,
collection: 'another:posts',
},
});
const n1 = await w1.createNode({
type: 'aggregate',
config: {
collection: 'another:posts',
aggregator: 'count',
params: {
field: 'id',
},
},
});
const p1 = await PostRepo.create({ values: { title: 't1' } });
const e1s = await w1.getExecutions();
expect(e1s.length).toBe(1);
expect(e1s[0].status).toBe(EXECUTION_STATUS.RESOLVED);
const [job] = await e1s[0].getJobs();
expect(job.result).toBe(1);
});
}); });
}); });