alasql 3.0.0 → 3.1.1

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 v2.5.3 build: develop-26e0bfa8 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v3.1.0 build: v3-hotfix-dfc34cf0 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.5.3
4
+ @version 3.1.0
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -1,2 +1,2 @@
1
- //! AlaSQL v2.5.3 build: develop-26e0bfa8 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v3.1.0 build: v3-hotfix-dfc34cf0 | © 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.fs.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v2.5.3 build: develop-26e0bfa8 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v3.1.0 build: v3-hotfix-dfc34cf0 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.5.3
4
+ @version 3.1.0
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 = '2.5.3';
146
- alasql.build = 'develop-26e0bfa8';
145
+ alasql.version = '3.1.0';
146
+ alasql.build = 'v3-hotfix-dfc34cf0';
147
147
 
148
148
  /**
149
149
  Debug flag
@@ -6650,9 +6650,16 @@ function queryfn3(query) {
6650
6650
  ilen = nd.data.length;
6651
6651
  for (var i = 0; i < ilen; i++) {
6652
6652
  r = {};
6653
- jlen = Math.min(query.columns.length, nd.columns.length);
6654
- for (var j = 0; j < jlen; j++) {
6655
- r[query.columns[j].columnid] = nd.data[i][nd.columns[j].columnid];
6653
+ if (query.columns.length) {
6654
+ jlen = Math.min(query.columns.length, nd.columns.length);
6655
+ for (var j = 0; j < jlen; j++) {
6656
+ r[query.columns[j].columnid] = nd.data[i][nd.columns[j].columnid];
6657
+ }
6658
+ } else {
6659
+ jlen = nd.columns.length;
6660
+ for (var j = 0; j < jlen; j++) {
6661
+ r[nd.columns[j].columnid] = nd.data[i][nd.columns[j].columnid];
6662
+ }
6656
6663
  }
6657
6664
  ud.push(r);
6658
6665
  }
@@ -9062,9 +9069,10 @@ function compileSelectStar(query, aliases, joinstar) {
9062
9069
 
9063
9070
  if (columns && columns.length > 0) {
9064
9071
  columns.forEach(function (tcol) {
9072
+ const escapedColumnId = escapeq(tcol.columnid);
9065
9073
  if (joinstar && alasql.options.joinstar == 'underscore') {
9066
9074
  ss.push(
9067
- "'" + alias + '_' + tcol.columnid + "':p['" + alias + "']['" + tcol.columnid + "']"
9075
+ "'" + alias + '_' + escapedColumnId + "':p['" + alias + "']['" + escapedColumnId + "']"
9068
9076
  );
9069
9077
  } else if (joinstar && alasql.options.joinstar == 'json') {
9070
9078
  // ss.push('\''+alias+'_'+tcol.columnid+'\':p[\''+alias+'\'][\''+tcol.columnid+'\']');
@@ -9072,16 +9080,16 @@ function compileSelectStar(query, aliases, joinstar) {
9072
9080
  "r['" +
9073
9081
  alias +
9074
9082
  "']['" +
9075
- tcol.columnid +
9083
+ escapedColumnId +
9076
9084
  "']=p['" +
9077
9085
  alias +
9078
9086
  "']['" +
9079
- tcol.columnid +
9087
+ escapedColumnId +
9080
9088
  "'];";
9081
9089
  } else {
9082
- var value = "p['" + alias + "']['" + tcol.columnid + "']";
9090
+ var value = "p['" + alias + "']['" + escapedColumnId + "']";
9083
9091
  if (!columnIds[tcol.columnid]) {
9084
- var key = "'" + tcol.columnid + "':";
9092
+ var key = "'" + escapedColumnId + "':";
9085
9093
  ss.push(key + value);
9086
9094
  columnIds[tcol.columnid] = {
9087
9095
  id: ss.length - 1,
@@ -9096,7 +9104,7 @@ function compileSelectStar(query, aliases, joinstar) {
9096
9104
  }
9097
9105
  }
9098
9106
 
9099
- query.selectColumns[escapeq(tcol.columnid)] = true;
9107
+ query.selectColumns[escapedColumnId] = true;
9100
9108
 
9101
9109
  var coldef = {
9102
9110
  columnid: tcol.columnid,
@@ -10574,7 +10582,7 @@ yy.Over = class Over {
10574
10582
  var ljs = '(' + leftJS() + '||{})';
10575
10583
 
10576
10584
  if (typeof this.right === 'string') {
10577
- s = ljs + '["' + this.right + '"]';
10585
+ s = ljs + '["' + escapeq(this.right) + '"]';
10578
10586
  } else if (typeof this.right === 'number') {
10579
10587
  s = ljs + '[' + this.right + ']';
10580
10588
  } else if (this.right instanceof yy.FuncValue) {
@@ -10813,7 +10821,7 @@ yy.Over = class Over {
10813
10821
  }
10814
10822
 
10815
10823
  toJS() {
10816
- return "alasql.vars['" + this.variable + "']";
10824
+ return "alasql.vars['" + escapeq(this.variable) + "']";
10817
10825
  }
10818
10826
  }
10819
10827
 
@@ -11202,7 +11210,7 @@ yy.Over = class Over {
11202
11210
  toJS() {
11203
11211
  var colas = this.nick;
11204
11212
  if (colas === undefined) {
11205
- colas = this.toString();
11213
+ colas = escapeq(this.toString());
11206
11214
  }
11207
11215
  return "g['" + colas + "']";
11208
11216
  }
package/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v2.5.3 build: develop-26e0bfa8 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v3.1.0 build: v3-hotfix-dfc34cf0 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.5.3
4
+ @version 3.1.0
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 = '2.5.3';
146
- alasql.build = 'develop-26e0bfa8';
145
+ alasql.version = '3.1.0';
146
+ alasql.build = 'v3-hotfix-dfc34cf0';
147
147
 
148
148
  /**
149
149
  Debug flag
@@ -6650,9 +6650,16 @@ function queryfn3(query) {
6650
6650
  ilen = nd.data.length;
6651
6651
  for (var i = 0; i < ilen; i++) {
6652
6652
  r = {};
6653
- jlen = Math.min(query.columns.length, nd.columns.length);
6654
- for (var j = 0; j < jlen; j++) {
6655
- r[query.columns[j].columnid] = nd.data[i][nd.columns[j].columnid];
6653
+ if (query.columns.length) {
6654
+ jlen = Math.min(query.columns.length, nd.columns.length);
6655
+ for (var j = 0; j < jlen; j++) {
6656
+ r[query.columns[j].columnid] = nd.data[i][nd.columns[j].columnid];
6657
+ }
6658
+ } else {
6659
+ jlen = nd.columns.length;
6660
+ for (var j = 0; j < jlen; j++) {
6661
+ r[nd.columns[j].columnid] = nd.data[i][nd.columns[j].columnid];
6662
+ }
6656
6663
  }
6657
6664
  ud.push(r);
6658
6665
  }
@@ -9062,9 +9069,10 @@ function compileSelectStar(query, aliases, joinstar) {
9062
9069
 
9063
9070
  if (columns && columns.length > 0) {
9064
9071
  columns.forEach(function (tcol) {
9072
+ const escapedColumnId = escapeq(tcol.columnid);
9065
9073
  if (joinstar && alasql.options.joinstar == 'underscore') {
9066
9074
  ss.push(
9067
- "'" + alias + '_' + tcol.columnid + "':p['" + alias + "']['" + tcol.columnid + "']"
9075
+ "'" + alias + '_' + escapedColumnId + "':p['" + alias + "']['" + escapedColumnId + "']"
9068
9076
  );
9069
9077
  } else if (joinstar && alasql.options.joinstar == 'json') {
9070
9078
  // ss.push('\''+alias+'_'+tcol.columnid+'\':p[\''+alias+'\'][\''+tcol.columnid+'\']');
@@ -9072,16 +9080,16 @@ function compileSelectStar(query, aliases, joinstar) {
9072
9080
  "r['" +
9073
9081
  alias +
9074
9082
  "']['" +
9075
- tcol.columnid +
9083
+ escapedColumnId +
9076
9084
  "']=p['" +
9077
9085
  alias +
9078
9086
  "']['" +
9079
- tcol.columnid +
9087
+ escapedColumnId +
9080
9088
  "'];";
9081
9089
  } else {
9082
- var value = "p['" + alias + "']['" + tcol.columnid + "']";
9090
+ var value = "p['" + alias + "']['" + escapedColumnId + "']";
9083
9091
  if (!columnIds[tcol.columnid]) {
9084
- var key = "'" + tcol.columnid + "':";
9092
+ var key = "'" + escapedColumnId + "':";
9085
9093
  ss.push(key + value);
9086
9094
  columnIds[tcol.columnid] = {
9087
9095
  id: ss.length - 1,
@@ -9096,7 +9104,7 @@ function compileSelectStar(query, aliases, joinstar) {
9096
9104
  }
9097
9105
  }
9098
9106
 
9099
- query.selectColumns[escapeq(tcol.columnid)] = true;
9107
+ query.selectColumns[escapedColumnId] = true;
9100
9108
 
9101
9109
  var coldef = {
9102
9110
  columnid: tcol.columnid,
@@ -10574,7 +10582,7 @@ yy.Over = class Over {
10574
10582
  var ljs = '(' + leftJS() + '||{})';
10575
10583
 
10576
10584
  if (typeof this.right === 'string') {
10577
- s = ljs + '["' + this.right + '"]';
10585
+ s = ljs + '["' + escapeq(this.right) + '"]';
10578
10586
  } else if (typeof this.right === 'number') {
10579
10587
  s = ljs + '[' + this.right + ']';
10580
10588
  } else if (this.right instanceof yy.FuncValue) {
@@ -10813,7 +10821,7 @@ yy.Over = class Over {
10813
10821
  }
10814
10822
 
10815
10823
  toJS() {
10816
- return "alasql.vars['" + this.variable + "']";
10824
+ return "alasql.vars['" + escapeq(this.variable) + "']";
10817
10825
  }
10818
10826
  }
10819
10827
 
@@ -11202,7 +11210,7 @@ yy.Over = class Over {
11202
11210
  toJS() {
11203
11211
  var colas = this.nick;
11204
11212
  if (colas === undefined) {
11205
- colas = this.toString();
11213
+ colas = escapeq(this.toString());
11206
11214
  }
11207
11215
  return "g['" + colas + "']";
11208
11216
  }