Skip to content

Commit

Permalink
Fix a misplaced paren from previous PR (#68)
Browse files Browse the repository at this point in the history
* Fix a misplaced paren from previous PR
* Add a test to prevent regressions
  • Loading branch information
berickson1 committed Oct 15, 2018
1 parent c80e892 commit a645dc7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nosqlprovider",
"version": "0.6.21",
"version": "0.6.22",
"description": "A cross-browser/platform indexeddb-like client library",
"author": "David de Regt <David.de.Regt@microsoft.com>",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/SqlProviderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' : '') +
Expand Down
28 changes: 28 additions & 0 deletions src/tests/NoSqlProviderTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,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,
Expand Down

0 comments on commit a645dc7

Please sign in to comment.