Skip to content

Commit a645dc7

Browse files
authored
Fix a misplaced paren from previous PR (#68)
* Fix a misplaced paren from previous PR * Add a test to prevent regressions
1 parent c80e892 commit a645dc7

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nosqlprovider",
3-
"version": "0.6.21",
3+
"version": "0.6.22",
44
"description": "A cross-browser/platform indexeddb-like client library",
55
"author": "David de Regt <David.de.Regt@microsoft.com>",
66
"scripts": {

src/SqlProviderBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ class SqlStore implements NoSqlProvider.DbStore {
959959
const itemPageSize = Math.floor(this._trans.internal_getMaxVariables() / insertParamCount);
960960
// data contains all the input parameters
961961
for (let i = 0; i < (data.length / insertParamCount); i += itemPageSize) {
962-
const thisPageCount = Math.min(itemPageSize, (data.length / insertParamCount)) - i;
962+
const thisPageCount = Math.min(itemPageSize, (data.length / insertParamCount) - i);
963963
const qmarksValues = _.fill(new Array(thisPageCount), generateParamPlaceholder(insertParamCount));
964964
insertQueries.push(this._trans.internal_nonQuery('INSERT INTO ' +
965965
this._schema.name + '_' + index.name + ' (nsp_key, nsp_refpk' + (index.includeDataInIndex ? ', nsp_data' : '') +

src/tests/NoSqlProviderTests.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,34 @@ describe('NoSqlProvider', function () {
762762
});
763763
});
764764

765+
// Ensure that we properly batch multi-key sql inserts
766+
if (provName.indexOf('sql') !== -1) {
767+
it('MultiEntry multipart index - large index put', () => {
768+
return openProvider(provName, {
769+
version: 1,
770+
stores: [
771+
{
772+
name: 'test',
773+
primaryKeyPath: 'id',
774+
indexes: [
775+
{
776+
name: 'key',
777+
multiEntry: true,
778+
keyPath: 'k.k',
779+
}
780+
]
781+
}
782+
]
783+
}, true).then(prov => {
784+
const keys: string[] = [];
785+
_.times(1000, () => {
786+
keys.push(_.uniqueId('multipartKey'));
787+
});
788+
return prov.put('test', { id: 'a', val: 'b', k: { k: keys } });
789+
});
790+
});
791+
}
792+
765793
it('MultiEntry multipart indexed tests - Compound Key', () => {
766794
return openProvider(provName, {
767795
version: 1,

0 commit comments

Comments
 (0)