From 1285843db3aceaeccf5a7daf29d8e5706f7767b2 Mon Sep 17 00:00:00 2001 From: Brent Erickson Date: Mon, 15 Oct 2018 16:09:45 -0700 Subject: [PATCH] Fix a misplaced paren from previous PR (#68) * Fix a misplaced paren from previous PR * Add a test to prevent regressions --- src/SqlProviderBase.ts | 2 +- src/tests/NoSqlProviderTests.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/SqlProviderBase.ts b/src/SqlProviderBase.ts index 552f29f..e8f40fb 100644 --- a/src/SqlProviderBase.ts +++ b/src/SqlProviderBase.ts @@ -959,7 +959,7 @@ class SqlStore implements NoSqlProvider.DbStore { const itemPageSize = Math.floor(this._trans.internal_getMaxVariables() / insertParamCount); // data contains all the input parameters for (let i = 0; i < (data.length / insertParamCount); i += itemPageSize) { - const thisPageCount = Math.min(itemPageSize, (data.length / insertParamCount)) - i; + const thisPageCount = Math.min(itemPageSize, (data.length / insertParamCount) - i); const qmarksValues = _.fill(new Array(thisPageCount), generateParamPlaceholder(insertParamCount)); insertQueries.push(this._trans.internal_nonQuery('INSERT INTO ' + this._schema.name + '_' + index.name + ' (nsp_key, nsp_refpk' + (index.includeDataInIndex ? ', nsp_data' : '') + diff --git a/src/tests/NoSqlProviderTests.ts b/src/tests/NoSqlProviderTests.ts index 2c5d7a0..393563b 100644 --- a/src/tests/NoSqlProviderTests.ts +++ b/src/tests/NoSqlProviderTests.ts @@ -729,6 +729,34 @@ describe('NoSqlProvider', function () { }); }); + // Ensure that we properly batch multi-key sql inserts + if (provName.indexOf('sql') !== -1) { + it('MultiEntry multipart index - large index put', () => { + return openProvider(provName, { + version: 1, + stores: [ + { + name: 'test', + primaryKeyPath: 'id', + indexes: [ + { + name: 'key', + multiEntry: true, + keyPath: 'k.k', + } + ] + } + ] + }, true).then(prov => { + const keys: string[] = []; + _.times(1000, () => { + keys.push(_.uniqueId('multipartKey')); + }); + return prov.put('test', { id: 'a', val: 'b', k: { k: keys } }); + }); + }); + } + it('MultiEntry multipart indexed tests - Compound Key', () => { return openProvider(provName, { version: 1,