Open arnemorken opened 7 years ago
Might be relate to #462 where AUTOINCREMENT was not working for localstorage
I think the problem is deeper than AUTOINCREMENT. It seems table rows are determined by the INSERT statement, not the CREATE TABLE statement. Create a table with 3 columns, but only insert data into 1 column (aname). Each row only has 1 column (aname); it should have 3 columns with the other, non-specified columns containing NULL values:
alasql.promise( 'CREATE INDEXEDDB DATABASE IF NOT EXISTS geo2;'+
'ATTACH INDEXEDDB DATABASE geo2;'+
'USE geo2;'+
'DROP TABLE IF EXISTS autoinctab;'+
'CREATE TABLE IF NOT EXISTS autoinctab (aid INT, aname STRING, bname STRING);'+
'INSERT INTO autoinctab (aname) VALUES ("bar1"),("bar2");')
.then ( function() {
alasql.promise('SELECT * FROM autoinctab')
.then ( function(res) { console.log("res:"+JSON.stringify(res)); } )
.catch( function(err) { console.log("err:"+err); } )
})
.catch( function(err) { console.log(err); })
Gives the same result as above:
Result:
res:[{"aname":"bar1"},{"aname":"bar2"}]
I was expecting something like this:
res:[{"aid":NULL,"aname":"bar1","bname":NULL},{"aid":NULL,"aname":"bar2","bname":NULL}]
@rexx-org Thank you for looking into this. Values that are null will never be part of the output from Alasql.
any update on this
@SathishRamV No update on this. PRs very welcome.
if alasql is having capability to alter indexeddb , we can use old indexeddb method to add id and we can alter the current table.
Using alasql 0.3.9 in browser (Firefox, Chrome). The code below prints out the contents of the table, but no value is assigned to aid:
Result: res:[{"aname":"bar1"},{"aname":"bar2"}]
I was expecting something like this: res:[{"aid":0,"aname":"bar1"},{"aid":1,"aname":"bar2"}]