fix(Microsoft SQL Node): Prevent MSSQL max parameters error by chunking (#8390)

This commit is contained in:
Elias Meire
2024-01-19 14:31:44 +01:00
committed by GitHub
parent d2b3c1048e
commit 1b0ba2c028
2 changed files with 36 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import {
configurePool,
deleteOperation,
insertOperation,
mssqlChunk,
updateOperation,
} from '../GenericFunctions';
@@ -142,4 +143,15 @@ describe('MSSQL tests', () => {
expect(querySpy).toHaveBeenCalledWith('DELETE FROM [users] WHERE [id] IN (@v0);');
assertParameters({ v0: 2 });
});
describe('mssqlChunk', () => {
it('should chunk insert values correctly', () => {
const chunks = mssqlChunk(
new Array(3000)
.fill(null)
.map((_, index) => ({ id: index, name: 'John Doe', verified: true })),
);
expect(chunks.map((chunk) => chunk.length)).toEqual([699, 699, 699, 699, 204]);
});
});
});