alasql 2.5.3 → 2.5.5

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.
package/bin/alasql-cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  //
4
4
  // Command line interface for Alasql
5
- // Version: 0.2.3
5
+ // Version: 2.5.5
6
6
  // Date: 28.07.2015
7
7
  // (c) 2014-2022, Andrey Gershun & Mathias Wulff
8
8
  //
@@ -1,7 +1,7 @@
1
- //! AlaSQL v2.5.2 build: develop-0e8a5557 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.5.5 build: v2-hotfix-8eb69ccf | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.5.2
4
+ @version 2.5.5
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -1,2 +1,2 @@
1
- //! AlaSQL v2.5.2 build: develop-0e8a5557 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.5.5 build: v2-hotfix-8eb69ccf | © 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.2 build: develop-0e8a5557 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.5.5 build: v2-hotfix-8eb69ccf | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.5.2
4
+ @version 2.5.5
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.2';
146
- alasql.build = 'develop-0e8a5557';
145
+ alasql.version = '2.5.5';
146
+ alasql.build = 'v2-hotfix-8eb69ccf';
147
147
 
148
148
  /**
149
149
  Debug flag
@@ -4022,11 +4022,11 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
4022
4022
  return +obj;
4023
4023
  }
4024
4024
 
4025
- var temp = new obj.constructor(); // changed
4025
+ var temp = new (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
4026
4026
 
4027
4027
  for (var key in obj) {
4028
4028
  if (obj.hasOwnProperty(key)) {
4029
- temp[key] = cloneDeep(obj[key]);
4029
+ /* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(temp, key, {value: cloneDeep(obj[key]), writable: true, enumerable: true, configurable: true}); } else { temp[key] = cloneDeep(obj[key]); }
4030
4030
  }
4031
4031
  }
4032
4032
  return temp;
@@ -4098,7 +4098,7 @@ var extend = (utils.extend = function extend(a, b) {
4098
4098
  a = a || {};
4099
4099
  for (var key in b) {
4100
4100
  if (b.hasOwnProperty(key)) {
4101
- a[key] = b[key];
4101
+ /* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(a, key, {value: b[key], writable: true, enumerable: true, configurable: true}); } else { a[key] = b[key]; }
4102
4102
  }
4103
4103
  }
4104
4104
  return a;
@@ -8670,7 +8670,7 @@ yy.Select.prototype.compileGroup = function (query) {
8670
8670
  aft2 = '';
8671
8671
 
8672
8672
  if (typeof query.groupStar !== 'undefined') {
8673
- aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
8673
+ aft2 += "for(var f in p['" + query.groupStar + "']) {if(/^__proto__$/.test(f))Object.defineProperty(g,f,{writable:true,enumerable:true,configurable:true});g[f]=p['" + query.groupStar + "'][f];};";
8674
8674
  }
8675
8675
 
8676
8676
  /*
@@ -9062,9 +9062,10 @@ function compileSelectStar(query, aliases, joinstar) {
9062
9062
 
9063
9063
  if (columns && columns.length > 0) {
9064
9064
  columns.forEach(function (tcol) {
9065
+ const escapedColumnId = escapeq(tcol.columnid);
9065
9066
  if (joinstar && alasql.options.joinstar == 'underscore') {
9066
9067
  ss.push(
9067
- "'" + alias + '_' + tcol.columnid + "':p['" + alias + "']['" + tcol.columnid + "']"
9068
+ "'" + alias + '_' + escapedColumnId + "':p['" + alias + "']['" + escapedColumnId + "']"
9068
9069
  );
9069
9070
  } else if (joinstar && alasql.options.joinstar == 'json') {
9070
9071
  // ss.push('\''+alias+'_'+tcol.columnid+'\':p[\''+alias+'\'][\''+tcol.columnid+'\']');
@@ -9072,16 +9073,16 @@ function compileSelectStar(query, aliases, joinstar) {
9072
9073
  "r['" +
9073
9074
  alias +
9074
9075
  "']['" +
9075
- tcol.columnid +
9076
+ escapedColumnId +
9076
9077
  "']=p['" +
9077
9078
  alias +
9078
9079
  "']['" +
9079
- tcol.columnid +
9080
+ escapedColumnId +
9080
9081
  "'];";
9081
9082
  } else {
9082
- var value = "p['" + alias + "']['" + tcol.columnid + "']";
9083
+ var value = "p['" + alias + "']['" + escapedColumnId + "']";
9083
9084
  if (!columnIds[tcol.columnid]) {
9084
- var key = "'" + tcol.columnid + "':";
9085
+ var key = "'" + escapedColumnId + "':";
9085
9086
  ss.push(key + value);
9086
9087
  columnIds[tcol.columnid] = {
9087
9088
  id: ss.length - 1,
@@ -9096,7 +9097,7 @@ function compileSelectStar(query, aliases, joinstar) {
9096
9097
  }
9097
9098
  }
9098
9099
 
9099
- query.selectColumns[escapeq(tcol.columnid)] = true;
9100
+ query.selectColumns[escapedColumnId] = true;
9100
9101
 
9101
9102
  var coldef = {
9102
9103
  columnid: tcol.columnid,
@@ -9112,7 +9113,7 @@ function compileSelectStar(query, aliases, joinstar) {
9112
9113
  } else {
9113
9114
 
9114
9115
  // if column not exist, then copy all
9115
- sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
9116
+ sp += 'var w=p["' + alias + '"];for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
9116
9117
 
9117
9118
  query.dirtyColumns = true;
9118
9119
  }
@@ -9440,10 +9441,10 @@ yy.Select.prototype.compileSelectGroup1 = function (query) {
9440
9441
  self.columns.forEach(function (col) {
9441
9442
 
9442
9443
  if (col instanceof yy.Column && col.columnid === '*') {
9443
- // s += 'for(var k in g){r[k]=g[k]};';
9444
+ // s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9444
9445
  // s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
9445
9446
 
9446
- s += 'for(var k in g) {r[k]=g[k]};';
9447
+ s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9447
9448
  return '';
9448
9449
 
9449
9450
  } else {
@@ -10574,7 +10575,7 @@ yy.Over = class Over {
10574
10575
  var ljs = '(' + leftJS() + '||{})';
10575
10576
 
10576
10577
  if (typeof this.right === 'string') {
10577
- s = ljs + '["' + this.right + '"]';
10578
+ s = ljs + '["' + escapeq(this.right) + '"]';
10578
10579
  } else if (typeof this.right === 'number') {
10579
10580
  s = ljs + '[' + this.right + ']';
10580
10581
  } else if (this.right instanceof yy.FuncValue) {
@@ -10813,7 +10814,7 @@ yy.Over = class Over {
10813
10814
  }
10814
10815
 
10815
10816
  toJS() {
10816
- return "alasql.vars['" + this.variable + "']";
10817
+ return "alasql.vars['" + escapeq(this.variable) + "']";
10817
10818
  }
10818
10819
  }
10819
10820
 
@@ -11202,7 +11203,7 @@ yy.Over = class Over {
11202
11203
  toJS() {
11203
11204
  var colas = this.nick;
11204
11205
  if (colas === undefined) {
11205
- colas = this.toString();
11206
+ colas = escapeq(this.toString());
11206
11207
  }
11207
11208
  return "g['" + colas + "']";
11208
11209
  }
@@ -12798,7 +12799,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12798
12799
 
12799
12800
  table.update(
12800
12801
  function (t) {
12801
- for (var f in r) t[f] = r[f];
12802
+ for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
12802
12803
  },
12803
12804
  table.data.indexOf(toreplace),
12804
12805
  params
@@ -14372,7 +14373,7 @@ yy.Insert.prototype.compile = function (databaseid) {
14372
14373
  });
14373
14374
  } else {
14374
14375
 
14375
- // sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
14376
+ // sw = 'var w='+JSONtoJS(values)+';for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
14376
14377
  sw = JSONtoJS(values);
14377
14378
  }
14378
14379
  }
package/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v2.5.2 build: develop-0e8a5557 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.5.5 build: v2-hotfix-8eb69ccf | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.5.2
4
+ @version 2.5.5
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.2';
146
- alasql.build = 'develop-0e8a5557';
145
+ alasql.version = '2.5.5';
146
+ alasql.build = 'v2-hotfix-8eb69ccf';
147
147
 
148
148
  /**
149
149
  Debug flag
@@ -4022,11 +4022,11 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
4022
4022
  return +obj;
4023
4023
  }
4024
4024
 
4025
- var temp = new obj.constructor(); // changed
4025
+ var temp = new (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
4026
4026
 
4027
4027
  for (var key in obj) {
4028
4028
  if (obj.hasOwnProperty(key)) {
4029
- temp[key] = cloneDeep(obj[key]);
4029
+ /* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(temp, key, {value: cloneDeep(obj[key]), writable: true, enumerable: true, configurable: true}); } else { temp[key] = cloneDeep(obj[key]); }
4030
4030
  }
4031
4031
  }
4032
4032
  return temp;
@@ -4098,7 +4098,7 @@ var extend = (utils.extend = function extend(a, b) {
4098
4098
  a = a || {};
4099
4099
  for (var key in b) {
4100
4100
  if (b.hasOwnProperty(key)) {
4101
- a[key] = b[key];
4101
+ /* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(a, key, {value: b[key], writable: true, enumerable: true, configurable: true}); } else { a[key] = b[key]; }
4102
4102
  }
4103
4103
  }
4104
4104
  return a;
@@ -8670,7 +8670,7 @@ yy.Select.prototype.compileGroup = function (query) {
8670
8670
  aft2 = '';
8671
8671
 
8672
8672
  if (typeof query.groupStar !== 'undefined') {
8673
- aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
8673
+ aft2 += "for(var f in p['" + query.groupStar + "']) {if(/^__proto__$/.test(f))Object.defineProperty(g,f,{writable:true,enumerable:true,configurable:true});g[f]=p['" + query.groupStar + "'][f];};";
8674
8674
  }
8675
8675
 
8676
8676
  /*
@@ -9062,9 +9062,10 @@ function compileSelectStar(query, aliases, joinstar) {
9062
9062
 
9063
9063
  if (columns && columns.length > 0) {
9064
9064
  columns.forEach(function (tcol) {
9065
+ const escapedColumnId = escapeq(tcol.columnid);
9065
9066
  if (joinstar && alasql.options.joinstar == 'underscore') {
9066
9067
  ss.push(
9067
- "'" + alias + '_' + tcol.columnid + "':p['" + alias + "']['" + tcol.columnid + "']"
9068
+ "'" + alias + '_' + escapedColumnId + "':p['" + alias + "']['" + escapedColumnId + "']"
9068
9069
  );
9069
9070
  } else if (joinstar && alasql.options.joinstar == 'json') {
9070
9071
  // ss.push('\''+alias+'_'+tcol.columnid+'\':p[\''+alias+'\'][\''+tcol.columnid+'\']');
@@ -9072,16 +9073,16 @@ function compileSelectStar(query, aliases, joinstar) {
9072
9073
  "r['" +
9073
9074
  alias +
9074
9075
  "']['" +
9075
- tcol.columnid +
9076
+ escapedColumnId +
9076
9077
  "']=p['" +
9077
9078
  alias +
9078
9079
  "']['" +
9079
- tcol.columnid +
9080
+ escapedColumnId +
9080
9081
  "'];";
9081
9082
  } else {
9082
- var value = "p['" + alias + "']['" + tcol.columnid + "']";
9083
+ var value = "p['" + alias + "']['" + escapedColumnId + "']";
9083
9084
  if (!columnIds[tcol.columnid]) {
9084
- var key = "'" + tcol.columnid + "':";
9085
+ var key = "'" + escapedColumnId + "':";
9085
9086
  ss.push(key + value);
9086
9087
  columnIds[tcol.columnid] = {
9087
9088
  id: ss.length - 1,
@@ -9096,7 +9097,7 @@ function compileSelectStar(query, aliases, joinstar) {
9096
9097
  }
9097
9098
  }
9098
9099
 
9099
- query.selectColumns[escapeq(tcol.columnid)] = true;
9100
+ query.selectColumns[escapedColumnId] = true;
9100
9101
 
9101
9102
  var coldef = {
9102
9103
  columnid: tcol.columnid,
@@ -9112,7 +9113,7 @@ function compileSelectStar(query, aliases, joinstar) {
9112
9113
  } else {
9113
9114
 
9114
9115
  // if column not exist, then copy all
9115
- sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
9116
+ sp += 'var w=p["' + alias + '"];for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
9116
9117
 
9117
9118
  query.dirtyColumns = true;
9118
9119
  }
@@ -9440,10 +9441,10 @@ yy.Select.prototype.compileSelectGroup1 = function (query) {
9440
9441
  self.columns.forEach(function (col) {
9441
9442
 
9442
9443
  if (col instanceof yy.Column && col.columnid === '*') {
9443
- // s += 'for(var k in g){r[k]=g[k]};';
9444
+ // s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9444
9445
  // s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
9445
9446
 
9446
- s += 'for(var k in g) {r[k]=g[k]};';
9447
+ s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9447
9448
  return '';
9448
9449
 
9449
9450
  } else {
@@ -10574,7 +10575,7 @@ yy.Over = class Over {
10574
10575
  var ljs = '(' + leftJS() + '||{})';
10575
10576
 
10576
10577
  if (typeof this.right === 'string') {
10577
- s = ljs + '["' + this.right + '"]';
10578
+ s = ljs + '["' + escapeq(this.right) + '"]';
10578
10579
  } else if (typeof this.right === 'number') {
10579
10580
  s = ljs + '[' + this.right + ']';
10580
10581
  } else if (this.right instanceof yy.FuncValue) {
@@ -10813,7 +10814,7 @@ yy.Over = class Over {
10813
10814
  }
10814
10815
 
10815
10816
  toJS() {
10816
- return "alasql.vars['" + this.variable + "']";
10817
+ return "alasql.vars['" + escapeq(this.variable) + "']";
10817
10818
  }
10818
10819
  }
10819
10820
 
@@ -11202,7 +11203,7 @@ yy.Over = class Over {
11202
11203
  toJS() {
11203
11204
  var colas = this.nick;
11204
11205
  if (colas === undefined) {
11205
- colas = this.toString();
11206
+ colas = escapeq(this.toString());
11206
11207
  }
11207
11208
  return "g['" + colas + "']";
11208
11209
  }
@@ -12798,7 +12799,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12798
12799
 
12799
12800
  table.update(
12800
12801
  function (t) {
12801
- for (var f in r) t[f] = r[f];
12802
+ for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
12802
12803
  },
12803
12804
  table.data.indexOf(toreplace),
12804
12805
  params
@@ -14372,7 +14373,7 @@ yy.Insert.prototype.compile = function (databaseid) {
14372
14373
  });
14373
14374
  } else {
14374
14375
 
14375
- // sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
14376
+ // sw = 'var w='+JSONtoJS(values)+';for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
14376
14377
  sw = JSONtoJS(values);
14377
14378
  }
14378
14379
  }