alasql 4.1.2 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.1 build: develop-a17cafee | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.2 build: develop-c4d7c946 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.1
4
+ @version 4.1.2
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -1,2 +1,2 @@
1
- //! AlaSQL v4.1.1 build: develop-a17cafee | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.2 build: develop-c4d7c946 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  !function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function i(r,e,o){"function"==typeof(e=e||[])&&(scope=o,o=e,e=[]),"object"!=typeof e&&(e=[e]);var t=i.lastid++;i.buffer[t]=o,i.webworker.postMessage({id:t,sql:r,params:e})}var a;if(i.options={},i.options.progress=function(){},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)},i.promise=function(){throw new Error("Please include a Promise/A+ library")},"undefined"!=typeof Promise&&(a=function(r,e,n,s){return new Promise(function(o,t){i(r,e,function(r,e){e?t(e):(n&&s&&!1!==i.options.progress&&i.options.progress(n,s),o(r))})})},i.promise=function(r,e){if("undefined"==typeof Promise)throw new Error("Please include a Promise/A+ library");if("string"==typeof r)return a(r,e);if(!isArray(r)||r.length<1||void 0!==e)throw new Error("Error in .promise parameters");var o=r;if(!(o.length<1)){for(var t,n,s=[],i=0;i<o.length;i++){if("string"==typeof(n=o[i])&&(n=[n]),!isArray(n)||n.length<1||2<n.length)throw new Error("Error in .promise parameter");t=n[0],n=n[1]||void 0,s.push(a(t,n,i,o.length))}return Promise.all(s)}}),i=i||!1)return i.worker=function(){throw new Error("Can find webworker in this enviroment")},"undefined"!=typeof Worker&&(i.worker=function(r,e,o){if(void 0===(r=!0===r?void 0:r))for(var t=document.getElementsByTagName("script"),n=0;n<t.length;n++){if("alasql-worker.js"===t[n].src.substr(-16).toLowerCase()){r=t[n].src.substr(0,t[n].src.length-16)+"alasql.js";break}if("alasql-worker.min.js"===t[n].src.substr(-20).toLowerCase()){r=t[n].src.substr(0,t[n].src.length-20)+"alasql.min.js";break}if("alasql.js"===t[n].src.substr(-9).toLowerCase()){r=t[n].src;break}if("alasql.min.js"===t[n].src.substr(-13).toLowerCase()){r=t[n].src.substr(0,t[n].src.length-13)+"alasql.min.js";break}}if(void 0===r)throw new Error("Path to alasql.js is not specified");var s;!1!==r?(s=(s="importScripts('")+r+"');self.onmessage = function(event) {alasql(event.data.sql,event.data.params, function(data){postMessage({id:event.data.id, data:data});});}",s=new Blob([s],{type:"text/plain"}),i.webworker=new Worker(URL.createObjectURL(s)),i.webworker.onmessage=function(r){var e=r.data.id;i.buffer[e](r.data.data),delete i.buffer[e]},i.webworker.onerror=function(r){throw r},1<arguments.length&&i("REQUIRE "+e.map(function(r){return'"'+r+'"'}).join(","),[],o)):!1===r&&delete i.webworker}),i.lastid=0,i.buffer={},i.worker(),i;throw new Error("alasql was not found")});
package/dist/alasql.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  // Project: https://github.com/alasql/alasql
2
2
 
3
- declare module "alasql" {
4
-
3
+ declare module 'alasql' {
5
4
  import * as xlsx from 'xlsx';
6
5
 
7
6
  interface AlaSQLCallback {
@@ -87,4 +86,3 @@ declare module "alasql" {
87
86
  const alasql: AlaSQL;
88
87
  export = alasql;
89
88
  }
90
-
package/dist/alasql.fs.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.1 build: develop-a17cafee | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.2 build: develop-c4d7c946 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.1
4
+ @version 4.1.2
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -142,8 +142,8 @@ var alasql = function(sql, params, cb, scope) {
142
142
  Current version of alasql
143
143
  @constant {string}
144
144
  */
145
- alasql.version = '4.1.1';
146
- alasql.build = 'develop-a17cafee';
145
+ alasql.version = '4.1.2';
146
+ alasql.build = 'develop-c4d7c946';
147
147
 
148
148
  /**
149
149
  Debug flag
@@ -4955,7 +4955,7 @@ var Database = (alasql.Database = function (databaseid) {
4955
4955
  alasql.databases[databaseid] = self;
4956
4956
  // }
4957
4957
  if (!self) {
4958
- throw new Error('Database "' + databaseid + '" not found');
4958
+ throw new Error(`Database ${databaseid} not found`);
4959
4959
  }
4960
4960
  } else {
4961
4961
  // Create new database (or get alasql?)
@@ -5351,10 +5351,6 @@ yy.Search = class Search {
5351
5351
  r, // temp value used many places
5352
5352
  sel = selectors[sidx];
5353
5353
 
5354
- // if(!alasql.srch[sel.srchid]) {
5355
- // throw new Error('Selector "'+sel.srchid+'" not found');
5356
- // };
5357
-
5358
5354
  var INFINITE_LOOP_BREAK = alasql.options.loopbreak || 100000;
5359
5355
 
5360
5356
  if (sel.selid) {
@@ -6297,13 +6293,12 @@ alasql.srch = {
6297
6293
 
6298
6294
  var s = args
6299
6295
  .map(function (st) {
6300
-
6301
6296
  if (st.method === '@') {
6302
- return "alasql.vars['" + st.variable + "']=" + st.expression.toJS('x', '');
6297
+ return `alasql.vars[${JSON.stringify(st.variable)}]=` + st.expression.toJS('x', '');
6303
6298
  } else if (st.method === '$') {
6304
- return "params['" + st.variable + "']=" + st.expression.toJS('x', '');
6299
+ return `params[${JSON.stringify(st.variable)}]=` + st.expression.toJS('x', '');
6305
6300
  } else {
6306
- return "x['" + st.column.columnid + "']=" + st.expression.toJS('x', '');
6301
+ return `x[${JSON.stringify(st.column.columnid)}]=` + st.expression.toJS('x', '');
6307
6302
  }
6308
6303
  })
6309
6304
  .join(';');
@@ -6382,18 +6377,18 @@ var compileSearchOrder = function (order) {
6382
6377
  s += 'if(a' + dg + (ord.direction === 'ASC' ? '>' : '<') + 'b' + dg + ')return 1;';
6383
6378
  s += 'if(a' + dg + '==b' + dg + '){';
6384
6379
  } else {
6385
- s +=
6386
- "if((a['" +
6387
- columnid +
6388
- "']||'')" +
6389
- dg +
6390
- (ord.direction === 'ASC' ? '>' : '<') +
6391
- "(b['" +
6392
- columnid +
6393
- "']||'')" +
6394
- dg +
6395
- ')return 1;';
6396
- s += "if((a['" + columnid + "']||'')" + dg + "==(b['" + columnid + "']||'')" + dg + '){';
6380
+ s += `if (
6381
+ (a[${JSON.stringify(columnid)}]||'')${dg}
6382
+ ${ord.direction === 'ASC' ? '>' : '<'}
6383
+ (b[${JSON.stringify(columnid)}]||'')${dg}
6384
+ ) return 1;
6385
+
6386
+ if(
6387
+ (a[${JSON.stringify(columnid)}]||'')${dg}
6388
+ ==
6389
+ (b[${JSON.stringify(columnid)}]||'')${dg}
6390
+ ){
6391
+ `;
6397
6392
  }
6398
6393
  } else {
6399
6394
  dg = '.valueOf()';
@@ -6596,23 +6591,16 @@ function queryfn3(query) {
6596
6591
  if (query.aggrKeys.length > 0) {
6597
6592
  var gfns = '';
6598
6593
  query.aggrKeys.forEach(function (col) {
6599
- gfns +=
6600
- "g['" +
6601
- col.nick +
6602
- "']=alasql.aggr['" +
6603
- col.funcid +
6604
- "'](undefined,g['" +
6605
- col.nick +
6606
- "'],3);";
6594
+ gfns += `g[${JSON.stringify(col.nick)}] = alasql.aggr[${JSON.stringify(
6595
+ col.funcid
6596
+ )}](undefined,g[${JSON.stringify(col.nick)}],3);`;
6597
+
6607
6598
  // gfns += 'return g[\''+col.nick+'\];';
6608
6599
  });
6609
6600
 
6610
6601
  var gfn = new Function('g,params,alasql', 'var y;' + gfns);
6611
6602
  }
6612
6603
 
6613
- // return "'"+colas+'\':alasql.aggr[\''+col.funcid+'\']('+colexp+',undefined,(acc={}),1),'
6614
- // +'\'__REDUCE__'+colas+'\':acc,';
6615
-
6616
6604
  // *******
6617
6605
 
6618
6606
  // debugger;
@@ -7558,34 +7546,34 @@ yy.Select = class Select {
7558
7546
  alasql.databases[this.into.databaseid || databaseid].engineid
7559
7547
  ) {
7560
7548
  // For external database when AUTOCOMMIT is ONs
7561
- query.intoallfns =
7562
- 'return alasql.engines["' +
7563
- alasql.databases[this.into.databaseid || databaseid].engineid +
7564
- '"]' +
7565
- '.intoTable("' +
7566
- (this.into.databaseid || databaseid) +
7567
- '","' +
7568
- this.into.tableid +
7569
- '",this.data, columns, cb);';
7549
+ query.intoallfns = `return alasql
7550
+ .engines[${JSON.stringify(alasql.databases[this.into.databaseid || databaseid].engineid)}]
7551
+ .intoTable(
7552
+ ${JSON.stringify(this.into.databaseid || databaseid)},
7553
+ ${JSON.stringify(this.into.tableid)},
7554
+ this.data,
7555
+ columns,
7556
+ cb
7557
+ );`;
7570
7558
  } else {
7571
7559
  // Into AlaSQL tables
7572
- query.intofns =
7573
- "alasql.databases['" +
7574
- (this.into.databaseid || databaseid) +
7575
- "'].tables" +
7576
- "['" +
7577
- this.into.tableid +
7578
- "'].data.push(r);";
7560
+ query.intofns = `alasql
7561
+ .databases[${JSON.stringify(this.into.databaseid || databaseid)}]
7562
+ .tables[${JSON.stringify(this.into.tableid)}]
7563
+ .data.push(r);
7564
+ `;
7579
7565
  }
7580
7566
  } else if (this.into instanceof yy.VarValue) {
7581
7567
  //
7582
7568
  // Save into local variable
7583
7569
  // SELECT * INTO @VAR1 FROM ?
7584
7570
  //
7585
- query.intoallfns =
7586
- 'alasql.vars["' +
7587
- this.into.variable +
7588
- '"]=this.data;res=this.data.length;if(cb)res=cb(res);return res;';
7571
+ query.intoallfns = `
7572
+ alasql.vars[${JSON.stringify(this.into.variable)}]=this.data;
7573
+ res=this.data.length;
7574
+ if(cb) res = cb(res);
7575
+ return res;
7576
+ `;
7589
7577
  } else if (this.into instanceof yy.FuncValue) {
7590
7578
  //
7591
7579
  // If this is INTO() function, then call it
@@ -7609,7 +7597,7 @@ yy.Select = class Select {
7609
7597
  // Save data into parameters array
7610
7598
  // like alasql('SELECT * INTO ? FROM ?',[outdata,srcdata]);
7611
7599
  //
7612
- query.intofns = "params['" + this.into.param + "'].push(r)";
7600
+ query.intofns = `params[${JSON.stringify(this.into.param)}].push(r)`;
7613
7601
  }
7614
7602
 
7615
7603
  if (query.intofns) {
@@ -12462,14 +12450,14 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12462
12450
  }
12463
12451
 
12464
12452
  if (col.default) {
12465
- ss.push("'" + col.columnid + "':" + col.default.toJS('r', ''));
12453
+ ss.push(JSON.stringify('' + col.columnid) + ':' + col.default.toJS('r', ''));
12466
12454
  }
12467
12455
 
12468
12456
  // Check for primary key
12469
12457
  if (col.primarykey) {
12470
12458
  var pk = (table.pk = {});
12471
12459
  pk.columns = [col.columnid];
12472
- pk.onrightfns = "r['" + col.columnid + "']";
12460
+ pk.onrightfns = `r[${JSON.stringify(col.columnid)}]`;
12473
12461
  pk.onrightfn = new Function('r', 'var y;return ' + pk.onrightfns);
12474
12462
  pk.hh = hash(pk.onrightfns);
12475
12463
  table.uniqs[pk.hh] = {};
@@ -12481,7 +12469,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12481
12469
  table.uk = table.uk || [];
12482
12470
  table.uk.push(uk);
12483
12471
  uk.columns = [col.columnid];
12484
- uk.onrightfns = "r['" + col.columnid + "']";
12472
+ uk.onrightfns = `r[${JSON.stringify(col.columnid)}]`;
12485
12473
  uk.onrightfn = new Function('r', 'var y;return ' + uk.onrightfns);
12486
12474
  uk.hh = hash(uk.onrightfns);
12487
12475
  table.uniqs[uk.hh] = {};
@@ -12510,10 +12498,6 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12510
12498
 
12511
12499
  if (!fktable.uniqs[fktable.pk.hh][addr]) {
12512
12500
  throw new Error(
12513
- // 'Foreign key "' +
12514
- // r[col.columnid] +
12515
- // '" is not found in table ' +
12516
- // fktable.tableid
12517
12501
  'Foreign key violation' //changed error message
12518
12502
  );
12519
12503
  }
@@ -12524,7 +12508,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12524
12508
  }
12525
12509
 
12526
12510
  if (col.onupdate) {
12527
- uss.push("r['" + col.columnid + "']=" + col.onupdate.toJS('r', ''));
12511
+ uss.push(`r[${JSON.stringify(col.columnid)}]=` + col.onupdate.toJS('r', ''));
12528
12512
  }
12529
12513
 
12530
12514
  table.columns.push(newcol);
@@ -12547,7 +12531,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12547
12531
  pk.columns = con.columns;
12548
12532
  pk.onrightfns = pk.columns
12549
12533
  .map(function (columnid) {
12550
- return "r['" + columnid + "']";
12534
+ return `r[${JSON.stringify(columnid)}]`;
12551
12535
  })
12552
12536
  .join("+'`'+");
12553
12537
  pk.onrightfn = new Function('r', 'var y;return ' + pk.onrightfns);
@@ -12564,7 +12548,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12564
12548
  uk.columns = con.columns;
12565
12549
  uk.onrightfns = uk.columns
12566
12550
  .map(function (columnid) {
12567
- return "r['" + columnid + "']";
12551
+ return `r[${JSON.stringify(columnid)}]`;
12568
12552
  })
12569
12553
  .join("+'`'+");
12570
12554
  uk.onrightfn = new Function('r', 'var y;return ' + uk.onrightfns);
@@ -13198,7 +13182,9 @@ yy.DropTable.prototype.execute = function (databaseid, params, cb) {
13198
13182
  if (!db.tables[tableid]) {
13199
13183
  if (!alasql.options.dropifnotexists) {
13200
13184
  throw new Error(
13201
- "Can not drop table '" + table.tableid + "', because it does not exist in the database."
13185
+ `Can not drop table ${JSON.strnigify(
13186
+ table.tableid
13187
+ )} because it does not exist in the database.`
13202
13188
  );
13203
13189
  }
13204
13190
  } else {
@@ -13312,7 +13298,7 @@ yy.CreateVertex.prototype.compile = function (databaseid) {
13312
13298
  if (this.sets && this.sets.length > 0) {
13313
13299
  var s = this.sets
13314
13300
  .map(function (st) {
13315
- return "x['" + st.column.columnid + "']=" + st.expression.toJS('x', '');
13301
+ return `x[${JSON.stringify(st.column.columnid)}]=` + st.expression.toJS('x', '');
13316
13302
  })
13317
13303
  .join(';');
13318
13304
  var setfn = new Function('x,params,alasql', s);
@@ -13385,7 +13371,7 @@ yy.CreateEdge.prototype.compile = function (databaseid) {
13385
13371
  if (this.sets && this.sets.length > 0) {
13386
13372
  var s = this.sets
13387
13373
  .map(function (st) {
13388
- return "x['" + st.column.columnid + "']=" + st.expression.toJS('x', '');
13374
+ return `x[${JSON.stringify(st.column.columnid)}]=` + st.expression.toJS('x', '');
13389
13375
  })
13390
13376
  .join(';');
13391
13377
  var setfn = new Function('x,params,alasql', 'var y;' + s);
@@ -13651,7 +13637,7 @@ yy.CreateGraph.prototype.compile1 = function (databaseid) {
13651
13637
  if (this.sets && this.sets.length > 0) {
13652
13638
  var s = this.sets
13653
13639
  .map(function (st) {
13654
- return "x['" + st.column.columnid + "']=" + st.expression.toJS('x', '');
13640
+ return `x[${JSON.stringify(st.column.columnid)}]=` + st.expression.toJS('x', '');
13655
13641
  })
13656
13642
  .join(';');
13657
13643
  var setfn = new Function('x,params,alasql', 'var y;' + s);
@@ -13726,14 +13712,10 @@ yy.AlterTable.prototype.execute = function (databaseid, params, cb) {
13726
13712
  var res = 1;
13727
13713
  if (db.tables[newtableid]) {
13728
13714
  throw new Error(
13729
- "Can not rename a table '" +
13730
- oldtableid +
13731
- "' to '" +
13732
- newtableid +
13733
- "', because the table with this name already exists"
13715
+ `Can not rename a table "${oldtableid}" to "${newtableid}" because the table with this name already exists`
13734
13716
  );
13735
13717
  } else if (newtableid === oldtableid) {
13736
- throw new Error("Can not rename a table '" + oldtableid + "' to itself");
13718
+ throw new Error(`Can not rename a table "${oldtableid}" to itself`);
13737
13719
  } else {
13738
13720
  db.tables[newtableid] = db.tables[oldtableid];
13739
13721
  delete db.tables[oldtableid];
@@ -13749,11 +13731,7 @@ yy.AlterTable.prototype.execute = function (databaseid, params, cb) {
13749
13731
  var columnid = this.addcolumn.columnid;
13750
13732
  if (table.xcolumns[columnid]) {
13751
13733
  throw new Error(
13752
- 'Cannot add column "' +
13753
- columnid +
13754
- '", because it already exists in the table "' +
13755
- tableid +
13756
- '"'
13734
+ `Cannot add column "${columnid}" because it already exists in table "${tableid}"`
13757
13735
  );
13758
13736
  }
13759
13737
 
@@ -13787,11 +13765,7 @@ yy.AlterTable.prototype.execute = function (databaseid, params, cb) {
13787
13765
 
13788
13766
  if (!table.xcolumns[columnid]) {
13789
13767
  throw new Error(
13790
- 'Cannot modify column "' +
13791
- columnid +
13792
- '", because it was not found in the table "' +
13793
- tableid +
13794
- '"'
13768
+ `Cannot modify column "${columnid}" because it was not found in table "${tableid}"`
13795
13769
  );
13796
13770
  }
13797
13771
 
@@ -13857,11 +13831,7 @@ yy.AlterTable.prototype.execute = function (databaseid, params, cb) {
13857
13831
 
13858
13832
  if (!found) {
13859
13833
  throw new Error(
13860
- 'Cannot drop column "' +
13861
- columnid +
13862
- '", because it was not found in the table "' +
13863
- tableid +
13864
- '"'
13834
+ `Cannot drop column "${columnid}" because it was not found in the table ${tableid}"`
13865
13835
  );
13866
13836
  }
13867
13837
 
@@ -16520,7 +16490,7 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
16520
16490
  } else {
16521
16491
  s += 'ss:';
16522
16492
  }
16523
- s += attr + '="' + st[key][attr] + '"';
16493
+ s += attr + '=' + JSON.stringify(st[key][attr]);
16524
16494
  }
16525
16495
  s += '/>';
16526
16496
  }
@@ -16530,8 +16500,8 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
16530
16500
  if (styles[hh]) {
16531
16501
  } else {
16532
16502
  styles[hh] = {styleid: stylesn};
16533
- s2 += '<Style ss:ID="s' + stylesn + '">';
16534
- s2 += s;
16503
+ s2 += `<Style ss:ID=${JSON.stringify('s' + stylesn)}>`;
16504
+ s2 += s.replace(/<\s*\/\s*Style /gi, '<');
16535
16505
  s2 += '</Style>';
16536
16506
  stylesn++;
16537
16507
  }
@@ -16597,9 +16567,9 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
16597
16567
 
16598
16568
  // Header
16599
16569
  s3 +=
16600
- '<Worksheet ss:Name="' +
16601
- sheetid +
16602
- '"> \
16570
+ '<Worksheet ss:Name=' +
16571
+ JSON.stringify(sheetid) +
16572
+ '> \
16603
16573
  <Table ss:ExpandedColumnCount="' +
16604
16574
  columns.length +
16605
16575
  '" ss:ExpandedRowCount="' +
@@ -16608,12 +16578,12 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
16608
16578
  x:FullRows="1" ss:DefaultColumnWidth="65" ss:DefaultRowHeight="15">';
16609
16579
 
16610
16580
  columns.forEach(function (column, columnidx) {
16611
- s3 +=
16612
- '<Column ss:Index="' +
16613
- (columnidx + 1) +
16614
- '" ss:AutoFitWidth="0" ss:Width="' +
16615
- column.width +
16616
- '"/>';
16581
+ s3 += `
16582
+ <Column
16583
+ ss:Index="${columnidx + 1}"
16584
+ ss:AutoFitWidth="0"
16585
+ ss:Width=${JSON.stringify('' + column.width)}
16586
+ />`;
16617
16587
  });
16618
16588
 
16619
16589
  // Headers
@@ -16633,7 +16603,7 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
16633
16603
  } else {
16634
16604
  extend(st, column.style);
16635
16605
  }
16636
- s3 += 'ss:StyleID="' + hstyle(st) + '"';
16606
+ s3 += 'ss:StyleID=' + JSON.stringify(hstyle(st));
16637
16607
  }
16638
16608
 
16639
16609
  s3 += '><Data ss:Type="String">';
@@ -16677,7 +16647,7 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
16677
16647
  } else {
16678
16648
  extend(st, srow.style);
16679
16649
  }
16680
- s3 += 'ss:StyleID="' + hstyle(st) + '"';
16650
+ s3 += 'ss:StyleID=' + JSON.stringify(hstyle(st));
16681
16651
  }
16682
16652
  }
16683
16653
 
@@ -16743,7 +16713,6 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
16743
16713
  typestyle = typestyle || 'mso-number-format:"\\@";'; // Default type style
16744
16714
 
16745
16715
  s3 += '<Cell ';
16746
-
16747
16716
  // Row style fromdefault sheet
16748
16717
  var st = {};
16749
16718
  if (typeof cell.style != 'undefined') {
@@ -16752,12 +16721,12 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
16752
16721
  } else {
16753
16722
  extend(st, cell.style);
16754
16723
  }
16755
- s3 += 'ss:StyleID="' + hstyle(st) + '"';
16724
+ s3 += 'ss:StyleID=' + JSON.stringify(hstyle(st));
16756
16725
  }
16757
16726
 
16758
16727
  s3 += '>';
16759
16728
 
16760
- s3 += '<Data ss:Type="' + Type + '">';
16729
+ s3 += '<Data ss:Type=' + JSON.stringify(Type) + '>';
16761
16730
 
16762
16731
  // TODO Replace with extend...
16763
16732
  var format = cell.format;
@@ -16981,10 +16950,6 @@ alasql.into.XLSX = function (filename, opts, data, columns, cb) {
16981
16950
  return buf;
16982
16951
  };
16983
16952
 
16984
- /* the saveAs call downloads a file on the local machine */
16985
- // saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), '"'+filename+'"')
16986
- // saveAs(new Blob([s2ab(wbout)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}), filename)
16987
- // saveAs(new Blob([s2ab(wbout)],{type:"application/vnd.ms-excel"}), '"'+filename+'"');
16988
16953
  saveAs(new Blob([s2ab(wbout)], {type: 'application/octet-stream'}), filename);
16989
16954
  }
16990
16955
  }
@@ -17173,7 +17138,7 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
17173
17138
  separator: ',',
17174
17139
  quote: '"',
17175
17140
  headers: true,
17176
- raw: false
17141
+ raw: false,
17177
17142
  };
17178
17143
  alasql.utils.extend(opt, opts);
17179
17144
  var res;
@@ -17256,7 +17221,12 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
17256
17221
  hs.forEach(function (h, idx) {
17257
17222
  r[h] = a[idx];
17258
17223
  // Please avoid === here
17259
- if (!opt.raw && typeof r[h] !== 'undefined' && r[h].length !== 0 && r[h].trim() == +r[h]) {
17224
+ if (
17225
+ !opt.raw &&
17226
+ typeof r[h] !== 'undefined' &&
17227
+ r[h].length !== 0 &&
17228
+ r[h].trim() == +r[h]
17229
+ ) {
17260
17230
  // jshint ignore:line
17261
17231
  r[h] = +r[h];
17262
17232
  }
@@ -17267,7 +17237,12 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
17267
17237
  var r = {};
17268
17238
  hs.forEach(function (h, idx) {
17269
17239
  r[h] = a[idx];
17270
- if (!opt.raw && typeof r[h] !== 'undefined' && r[h].length !== 0 && r[h].trim() == +r[h]) {
17240
+ if (
17241
+ !opt.raw &&
17242
+ typeof r[h] !== 'undefined' &&
17243
+ r[h].length !== 0 &&
17244
+ r[h].trim() == +r[h]
17245
+ ) {
17271
17246
  // jshint ignore:line
17272
17247
  r[h] = +r[h];
17273
17248
  }
@@ -17280,7 +17255,12 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
17280
17255
  // different bug here, if headers are not defined, the numerical values will not be parsed
17281
17256
  a.forEach(function (v, idx) {
17282
17257
  r[idx] = a[idx];
17283
- if (!opt.raw && typeof r[idx] !== 'undefined' && r[idx].length !== 0 && r[idx].trim() == +r[idx]) {
17258
+ if (
17259
+ !opt.raw &&
17260
+ typeof r[idx] !== 'undefined' &&
17261
+ r[idx].length !== 0 &&
17262
+ r[idx].trim() == +r[idx]
17263
+ ) {
17284
17264
  // jshint ignore:line
17285
17265
  r[idx] = +r[idx];
17286
17266
  }
@@ -18143,7 +18123,9 @@ IDB.fromTable = function (databaseid, tableid, cb, idx, query) {
18143
18123
  cur.onsuccess = () => {
18144
18124
  const cursor = cur.result;
18145
18125
  if (cursor) {
18146
- res.push(cursor.value);
18126
+ // if keyPath(columns) is not present then we take the key and value as object.
18127
+ const cursorValue = typeof cursor === Object ? cursor.value : { [cursor.key]: cursor.value };
18128
+ res.push(cursorValue);
18147
18129
  cursor.continue();
18148
18130
  } else {
18149
18131
  ixdb.close();