fix(server): guard createAll against empty values list (#30837)

Co-authored-by: priyanshuANDcoad <priyanshu23154050@akgec.ac.in>
This commit is contained in:
Priyanshu
2026-08-18 13:56:37 +02:00
committed by GitHub
co-authored by priyanshuANDcoad
parent d00867d702
commit b0a9468da7
2 changed files with 10 additions and 0 deletions
@@ -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([]);
});
});
});