fix(server): guard createAll against empty values list (#30837)
Co-authored-by: priyanshuANDcoad <priyanshu23154050@akgec.ac.in>
This commit is contained in:
co-authored by
priyanshuANDcoad
parent
d00867d702
commit
b0a9468da7
@@ -448,6 +448,9 @@ export class AssetRepository {
|
||||
|
||||
@ChunkedArray({ chunkSize: 4000 })
|
||||
async createAll(assets: Insertable<AssetTable>[]) {
|
||||
if (assets.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const ids = await this.db.insertInto('asset').values(assets).returning('id').execute();
|
||||
return ids.map(({ id }) => id);
|
||||
}
|
||||
|
||||
@@ -204,4 +204,11 @@ describe(AssetRepository.name, () => {
|
||||
).resolves.toEqual({ lockedProperties: null });
|
||||
});
|
||||
});
|
||||
|
||||
describe('createAll', () => {
|
||||
it('should return an empty array when given an empty input', async () => {
|
||||
const { sut } = setup();
|
||||
await expect(sut.createAll([])).resolves.toStrictEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user