diff --git a/test/integration/generic/generic_test.js b/test/integration/generic/generic_test.js index e16bab6ed..aa7a8f8c5 100644 --- a/test/integration/generic/generic_test.js +++ b/test/integration/generic/generic_test.js @@ -55,6 +55,37 @@ describe.only('test generic binding', () => { assert.equal(connectionId, null); }); + it('should execute queries with bind parameters', () => { + const connectionId = generic.connectUserPassword(connectionParams); + let result = generic.executeQuery(connectionId, 'create or replace table generic_1 (id int, data text);'); + assert.deepEqual(result, [['Table GENERIC_1 successfully created.']]); + result = generic.executeQuery(connectionId, 'insert into generic_1 (id, data) values (?, ?)', { + binds: [1, 'test żółć'] + }); + assert.deepEqual(result, [[1]], 'insert'); // one inserted row + result = generic.executeQuery(connectionId, 'select id, data from generic_1 where id = ?', { + binds: [1] + }); + assert.deepEqual(result, [[1, 'test żółć']], 'select after insert'); + result = generic.executeQuery(connectionId, 'update generic_1 set data = ? where id = ?', { + binds: ['test 2', 1] + }); + assert.deepEqual(result, [[1, 0]], 'update'); // one updated row, 0 number of multi-joined rows updated + result = generic.executeQuery(connectionId, 'select id, data from generic_1 where id = ?', { + binds: [1] + }); + assert.deepEqual(result, [[1, 'test 2']], 'select after update'); + result = generic.executeQuery(connectionId, 'delete from generic_1 where id = ?', { + binds: [1] + }); + assert.deepEqual(result, [[1]], 'delete'); // one deleted row + result = generic.executeQuery(connectionId, 'select id, data from generic_1 where id = ?', { + binds: [1] + }); + assert.deepEqual(result, [], 'select after delete'); + generic.closeConnection(connectionId); + }); + describe('Perf selects', () => { ['JSON', 'ARROW'].forEach(resultFormat => { let connectionId; @@ -68,7 +99,7 @@ describe.only('test generic binding', () => { }); [10, 10000, 1000000].forEach(sourceRowCount => { - it(`should select ${sourceRowCount} rows in ${resultFormat}`, () => { + it(`GENERIC|${sourceRowCount}|${resultFormat}|ROWS`, () => { const result = generic.executeQuery(connectionId, `select randstr(10, random()) from table (generator(rowcount =>${sourceRowCount}))`); @@ -80,7 +111,7 @@ describe.only('test generic binding', () => { }); }); - it(`should select ${sourceRowCount} rows in ${resultFormat} with delayed rows fetch`, () => { + it(`GENERIC|${sourceRowCount}|${resultFormat}|DELAYED`, () => { const streamRowsSize = 1000; const statementId = generic.executeQueryWithoutFetchingRows(connectionId, `select randstr(10, random()) @@ -103,7 +134,7 @@ describe.only('test generic binding', () => { assert.equal(fetchedRows, sourceRowCount); }); - it(`should select ${sourceRowCount} rows in ${resultFormat} with streaming`, () => { + it(`GENERIC|${sourceRowCount}|${resultFormat}|STREAM`, () => { let fetchedRows = 0; let invalidRows = 0; const options = { @@ -126,37 +157,6 @@ describe.only('test generic binding', () => { }); }); }); - - it('should execute queries with bind parameters', () => { - const connectionId = generic.connectUserPassword(connectionParams); - let result = generic.executeQuery(connectionId, 'create or replace table generic_1 (id int, data text);'); - assert.deepEqual(result, [['Table GENERIC_1 successfully created.']]); - result = generic.executeQuery(connectionId, 'insert into generic_1 (id, data) values (?, ?)', { - binds: [1, 'test żółć'] - }); - assert.deepEqual(result, [[1]], 'insert'); // one inserted row - result = generic.executeQuery(connectionId, 'select id, data from generic_1 where id = ?', { - binds: [1] - }); - assert.deepEqual(result, [[1, 'test żółć']], 'select after insert'); - result = generic.executeQuery(connectionId, 'update generic_1 set data = ? where id = ?', { - binds: ['test 2', 1] - }); - assert.deepEqual(result, [[1, 0]], 'update'); // one updated row, 0 number of multi-joined rows updated - result = generic.executeQuery(connectionId, 'select id, data from generic_1 where id = ?', { - binds: [1] - }); - assert.deepEqual(result, [[1, 'test 2']], 'select after update'); - result = generic.executeQuery(connectionId, 'delete from generic_1 where id = ?', { - binds: [1] - }); - assert.deepEqual(result, [[1]], 'delete'); // one deleted row - result = generic.executeQuery(connectionId, 'select id, data from generic_1 where id = ?', { - binds: [1] - }); - assert.deepEqual(result, [], 'select after delete'); - generic.closeConnection(connectionId); - }); }) ; @@ -181,7 +181,9 @@ describe.only('Perf selects standard nodejs', () => { }); [10, 10000, 1000000].forEach(sourceRowCount => { - it(`should select ${sourceRowCount} rows in JSON`, async () => { + const resultFormat = 'JSON'; + + it(`NODEJS|${sourceRowCount}|${resultFormat}|ROWS`, async () => { const result = await testUtil.executeCmdAsync(connection, `select randstr(10, random()) as a from table (generator(rowcount =>${sourceRowCount}))`, @@ -217,7 +219,7 @@ describe.only('Perf selects standard nodejs', () => { }); }; - it(`should select ${sourceRowCount} rows in JSON with streaming`, async () => { + it(`NODEJS|${sourceRowCount}|${resultFormat}|STREAM`, async () => { const rowLength = await countRows(connection, `select randstr(10, random()) as a from table (generator(rowcount =>${sourceRowCount}))`,