fix(plugin-workflow): fix appends null to collection trigger (#1661)
This commit is contained in:
parent
cefe678348
commit
3ec8b2d45f
@ -204,6 +204,35 @@ describe('workflow > triggers > collection', () => {
|
||||
expect(job.result.data.category.title).toBe('c1');
|
||||
});
|
||||
|
||||
it('appends belongsTo null', async () => {
|
||||
const workflow = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
type: 'collection',
|
||||
config: {
|
||||
mode: 1,
|
||||
collection: 'posts',
|
||||
appends: ['category']
|
||||
}
|
||||
});
|
||||
|
||||
await workflow.createNode({
|
||||
type: 'echo'
|
||||
});
|
||||
|
||||
const post = await PostRepo.create({
|
||||
values: {
|
||||
title: 't1',
|
||||
}
|
||||
});
|
||||
|
||||
await sleep(500);
|
||||
|
||||
const [execution] = await workflow.getExecutions();
|
||||
expect(execution.status).toBe(EXECUTION_STATUS.RESOLVED);
|
||||
const [job] = await execution.getJobs();
|
||||
expect(job.result.data.category).toBeNull();
|
||||
});
|
||||
|
||||
it('appends hasMany', async () => {
|
||||
const workflow = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
|
@ -79,7 +79,7 @@ async function handler(this: CollectionTrigger, workflow: WorkflowModel, data: M
|
||||
});
|
||||
includeFields.forEach(field => {
|
||||
const value = included!.get(field);
|
||||
data.set(field, Array.isArray(value) ? value.map(item => item.toJSON()) : value.toJSON(), { raw: true });
|
||||
data.set(field, Array.isArray(value) ? value.map(item => item.toJSON()) : (value ? value.toJSON() : null), { raw: true });
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user