You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If registered in parallel, the index will not be built correctly and the select results that use it will be less.
Expected behavior
Even if they are registered in parallel, search results equal to the number of registrations can be obtained.
Example
<!-- save it as index.html and use npx http-server --><scriptsrc="https://cdn.jsdelivr.net/npm/@nano-sql/[email protected]/dist/nano-sql.min.js"
integrity="sha256-W1pVgKda7GC4fwXqq9jfOrssBDJJXZqck+ultRPVzmc=" crossorigin="anonymous"></script><script>// table schema with primary key id column and data value columnconstmodel={"id:string": {pk: true},"value:string": {},};// data value column index definitionconstindexes={"value:string": {},};// number of rows in tableconstNUM=100;// original data of the table (number from 0 to NUM-1, used for primary key)constkeys=[...Array(NUM).keys()];// query definition for data registration (write data of value '0' with table name and primary key value as arguments)constupsert=(table,key)=>nSQL(table).query('upsert',{"id": String(key),"value": '0'}).exec();// query definition for data search (counts the number of rows of data with value '0' using the table name as an argument)constselect=(table)=>nSQL(table).query('select').where(['value','=','0']).exec().then((rows)=>rows.length);// database generation (create two tables of the same structure in IndexedDB with names sync and async)nSQL().createDatabase({id: "sample_db",mode: "PERM",tables: [{name: "sync",model: model,indexes: indexes,},{name: "async",model: model,indexes: indexes,},],version: 1,}).then(()=>{// register data (keys) in parallel in the async table asynchronouslyreturnPromise.all(keys.map((key)=>upsert("async",key)));}).then(()=>{// register data (keys) in serial in the sync table asynchronouslyreturnkeys.reduce((promise,key)=>promise.then(()=>upsert("sync",key)),Promise.resolve());}).then(()=>{console.log("completed!");// count number of rows with a value of 0 in the sync tablereturnselect('sync');}).then((count)=>{console.log('sync='+count);// count number of rows with value 0 in the async tablereturnselect('async');}).then((count)=>{console.log('async='+count);}).catch((err)=>{console.log(err);});</script>
The text was updated successfully, but these errors were encountered:
Which version are you using?
2.3.7
Describe the bug
If registered in parallel, the index will not be built correctly and the select results that use it will be less.
Expected behavior
Even if they are registered in parallel, search results equal to the number of registrations can be obtained.
Example
The text was updated successfully, but these errors were encountered: