mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 14:46:13 +00:00
fix: through collection individual hooks (#1378)
This commit is contained in:
parent
47158e0282
commit
d4d8d747b8
@ -22,7 +22,7 @@ describe('update through', () => {
|
||||
type: 'integer',
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
db.collection({
|
||||
@ -45,6 +45,10 @@ describe('update through', () => {
|
||||
fields: [],
|
||||
});
|
||||
await db.sync();
|
||||
const callback1 = jest.fn();
|
||||
const callback2 = jest.fn();
|
||||
db.on('c.afterCreate', callback1);
|
||||
db.on('c.afterBulkCreate', callback2);
|
||||
const b = await db.getRepository('b').create({
|
||||
values: {},
|
||||
});
|
||||
@ -60,7 +64,10 @@ describe('update through', () => {
|
||||
b: [b.toJSON()],
|
||||
},
|
||||
});
|
||||
|
||||
const c2 = await db.getRepository('c').findOne();
|
||||
expect(c1.get('id')).toBe(c2.get('id'))
|
||||
expect(c1.get('id')).toBe(c2.get('id'));
|
||||
expect(callback1).toHaveBeenCalledTimes(1);
|
||||
expect(callback2).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
@ -392,7 +392,7 @@ export async function updateMultipleAssociation(
|
||||
}
|
||||
|
||||
if (isStringOrNumber(value)) {
|
||||
await model[setAccessor](value, { transaction, context });
|
||||
await model[setAccessor](value, { transaction, context, individualHooks: true });
|
||||
return;
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ export async function updateMultipleAssociation(
|
||||
}
|
||||
|
||||
// associate targets in lists1
|
||||
await model[setAccessor](list1, { transaction, context });
|
||||
await model[setAccessor](list1, { transaction, context, individualHooks: true });
|
||||
|
||||
const list3 = [];
|
||||
for (const item of list2) {
|
||||
|
Loading…
Reference in New Issue
Block a user