alasql 4.1.10 → 4.1.12

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: 4.1.12
6
6
  // Date: 28.07.2015
7
7
  // (c) 2014-2022, Andrey Gershun & Mathias Wulff
8
8
  //
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.9 build: develop-a3395d54 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.12 build: develop-1493d57a | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.9
4
+ @version 4.1.12
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
package/dist/alasql.fs.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.9 build: develop-a3395d54 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.12 build: develop-1493d57a | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.9
4
+ @version 4.1.12
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -141,8 +141,8 @@ var alasql = function(sql, params, cb, scope) {
141
141
  Current version of alasql
142
142
  @constant {string}
143
143
  */
144
- alasql.version = '4.1.9';
145
- alasql.build = 'develop-a3395d54';
144
+ alasql.version = '4.1.12';
145
+ alasql.build = 'develop-1493d57a';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -4019,11 +4019,11 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
4019
4019
  return +obj;
4020
4020
  }
4021
4021
 
4022
- var temp = new obj.constructor(); // changed
4022
+ var temp = new (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
4023
4023
 
4024
4024
  for (var key in obj) {
4025
4025
  if (obj.hasOwnProperty(key)) {
4026
- temp[key] = cloneDeep(obj[key]);
4026
+ /* 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]); }
4027
4027
  }
4028
4028
  }
4029
4029
  return temp;
@@ -4095,7 +4095,7 @@ var extend = (utils.extend = function extend(a, b) {
4095
4095
  a = a || {};
4096
4096
  for (var key in b) {
4097
4097
  if (b.hasOwnProperty(key)) {
4098
- a[key] = b[key];
4098
+ /* 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]; }
4099
4099
  }
4100
4100
  }
4101
4101
  return a;
@@ -6613,9 +6613,8 @@ function queryfn3(query) {
6613
6613
  var d = query.selectgfn(g, query.params, alasql);
6614
6614
 
6615
6615
  for (const key in query.groupColumns) {
6616
- if (query.groupColumns[key] !== key
6617
- && d[query.groupColumns[key]])
6618
- delete d[query.groupColumns[key]]
6616
+ if (query.groupColumns[key] !== key && d[query.groupColumns[key]])
6617
+ delete d[query.groupColumns[key]];
6619
6618
  }
6620
6619
  query.data.push(d);
6621
6620
  }
@@ -6883,7 +6882,7 @@ var preIndex = function (query) {
6883
6882
  // Check if index already exists
6884
6883
  var ixx =
6885
6884
  alasql.databases[source.databaseid].tables[source.tableid].indices[
6886
- hash(source.onrightfns + '`' + source.srcwherefns)
6885
+ hash(source.onrightfns + '`' + source.srcwherefns)
6887
6886
  ];
6888
6887
  if (!alasql.databases[source.databaseid].tables[source.tableid].dirty && ixx) {
6889
6888
  source.ix = ixx;
@@ -6938,7 +6937,7 @@ var preIndex = function (query) {
6938
6937
  // Check if index exists
6939
6938
  ixx =
6940
6939
  alasql.databases[source.databaseid].tables[source.tableid].indices[
6941
- hash(source.wxleftfns + '`')
6940
+ hash(source.wxleftfns + '`')
6942
6941
  ];
6943
6942
  }
6944
6943
  if (!alasql.databases[source.databaseid].tables[source.tableid].dirty && ixx) {
@@ -8681,7 +8680,7 @@ yy.Select.prototype.compileGroup = function (query) {
8681
8680
  aft2 = '';
8682
8681
 
8683
8682
  if (typeof query.groupStar !== 'undefined') {
8684
- aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
8683
+ 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];};";
8685
8684
  }
8686
8685
 
8687
8686
  /*
@@ -9073,9 +9072,10 @@ function compileSelectStar(query, aliases, joinstar) {
9073
9072
 
9074
9073
  if (columns && columns.length > 0) {
9075
9074
  columns.forEach(function (tcol) {
9075
+ const escapedColumnId = escapeq(tcol.columnid);
9076
9076
  if (joinstar && alasql.options.joinstar == 'underscore') {
9077
9077
  ss.push(
9078
- "'" + alias + '_' + tcol.columnid + "':p['" + alias + "']['" + tcol.columnid + "']"
9078
+ "'" + alias + '_' + escapedColumnId + "':p['" + alias + "']['" + escapedColumnId + "']"
9079
9079
  );
9080
9080
  } else if (joinstar && alasql.options.joinstar == 'json') {
9081
9081
  // ss.push('\''+alias+'_'+tcol.columnid+'\':p[\''+alias+'\'][\''+tcol.columnid+'\']');
@@ -9083,16 +9083,16 @@ function compileSelectStar(query, aliases, joinstar) {
9083
9083
  "r['" +
9084
9084
  alias +
9085
9085
  "']['" +
9086
- tcol.columnid +
9086
+ escapedColumnId +
9087
9087
  "']=p['" +
9088
9088
  alias +
9089
9089
  "']['" +
9090
- tcol.columnid +
9090
+ escapedColumnId +
9091
9091
  "'];";
9092
9092
  } else {
9093
- var value = "p['" + alias + "']['" + tcol.columnid + "']";
9093
+ var value = "p['" + alias + "']['" + escapedColumnId + "']";
9094
9094
  if (!columnIds[tcol.columnid]) {
9095
- var key = "'" + tcol.columnid + "':";
9095
+ var key = "'" + escapedColumnId + "':";
9096
9096
  ss.push(key + value);
9097
9097
  columnIds[tcol.columnid] = {
9098
9098
  id: ss.length - 1,
@@ -9107,7 +9107,7 @@ function compileSelectStar(query, aliases, joinstar) {
9107
9107
  }
9108
9108
  }
9109
9109
 
9110
- query.selectColumns[escapeq(tcol.columnid)] = true;
9110
+ query.selectColumns[escapedColumnId] = true;
9111
9111
 
9112
9112
  var coldef = {
9113
9113
  columnid: tcol.columnid,
@@ -9123,7 +9123,7 @@ function compileSelectStar(query, aliases, joinstar) {
9123
9123
  } else {
9124
9124
 
9125
9125
  // if column not exist, then copy all
9126
- sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
9126
+ 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]};';
9127
9127
 
9128
9128
  query.dirtyColumns = true;
9129
9129
  }
@@ -9451,10 +9451,10 @@ yy.Select.prototype.compileSelectGroup1 = function (query) {
9451
9451
  self.columns.forEach(function (col) {
9452
9452
 
9453
9453
  if (col instanceof yy.Column && col.columnid === '*') {
9454
- // s += 'for(var k in g){r[k]=g[k]};';
9454
+ // s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9455
9455
  // s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
9456
9456
 
9457
- s += 'for(var k in g) {r[k]=g[k]};';
9457
+ s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9458
9458
  return '';
9459
9459
 
9460
9460
  } else {
@@ -10574,7 +10574,7 @@ yy.Over = class Over {
10574
10574
  var ljs = '(' + leftJS() + '||{})';
10575
10575
 
10576
10576
  if (typeof this.right === 'string') {
10577
- s = ljs + '["' + this.right + '"]';
10577
+ s = ljs + '["' + escapeq(this.right) + '"]';
10578
10578
  } else if (typeof this.right === 'number') {
10579
10579
  s = ljs + '[' + this.right + ']';
10580
10580
  } else if (this.right instanceof yy.FuncValue) {
@@ -10813,7 +10813,7 @@ yy.Over = class Over {
10813
10813
  }
10814
10814
 
10815
10815
  toJS() {
10816
- return "alasql.vars['" + this.variable + "']";
10816
+ return "alasql.vars['" + escapeq(this.variable) + "']";
10817
10817
  }
10818
10818
  }
10819
10819
 
@@ -11202,7 +11202,7 @@ yy.Over = class Over {
11202
11202
  toJS() {
11203
11203
  var colas = this.nick;
11204
11204
  if (colas === undefined) {
11205
- colas = this.toString();
11205
+ colas = escapeq(this.toString());
11206
11206
  }
11207
11207
  return "g['" + colas + "']";
11208
11208
  }
@@ -12715,7 +12715,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12715
12715
 
12716
12716
  table.update(
12717
12717
  function (t) {
12718
- for (var f in r) t[f] = r[f];
12718
+ for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
12719
12719
  },
12720
12720
  table.data.indexOf(toreplace),
12721
12721
  params
@@ -14268,7 +14268,7 @@ yy.Insert.prototype.compile = function (databaseid) {
14268
14268
  });
14269
14269
  } else {
14270
14270
 
14271
- // sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
14271
+ // 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]};';
14272
14272
  sw = JSONtoJS(values);
14273
14273
  }
14274
14274
  }
package/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.9 build: develop-a3395d54 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.12 build: develop-1493d57a | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.9
4
+ @version 4.1.12
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -141,8 +141,8 @@ var alasql = function(sql, params, cb, scope) {
141
141
  Current version of alasql
142
142
  @constant {string}
143
143
  */
144
- alasql.version = '4.1.9';
145
- alasql.build = 'develop-a3395d54';
144
+ alasql.version = '4.1.12';
145
+ alasql.build = 'develop-1493d57a';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -4019,11 +4019,11 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
4019
4019
  return +obj;
4020
4020
  }
4021
4021
 
4022
- var temp = new obj.constructor(); // changed
4022
+ var temp = new (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
4023
4023
 
4024
4024
  for (var key in obj) {
4025
4025
  if (obj.hasOwnProperty(key)) {
4026
- temp[key] = cloneDeep(obj[key]);
4026
+ /* 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]); }
4027
4027
  }
4028
4028
  }
4029
4029
  return temp;
@@ -4095,7 +4095,7 @@ var extend = (utils.extend = function extend(a, b) {
4095
4095
  a = a || {};
4096
4096
  for (var key in b) {
4097
4097
  if (b.hasOwnProperty(key)) {
4098
- a[key] = b[key];
4098
+ /* 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]; }
4099
4099
  }
4100
4100
  }
4101
4101
  return a;
@@ -6613,9 +6613,8 @@ function queryfn3(query) {
6613
6613
  var d = query.selectgfn(g, query.params, alasql);
6614
6614
 
6615
6615
  for (const key in query.groupColumns) {
6616
- if (query.groupColumns[key] !== key
6617
- && d[query.groupColumns[key]])
6618
- delete d[query.groupColumns[key]]
6616
+ if (query.groupColumns[key] !== key && d[query.groupColumns[key]])
6617
+ delete d[query.groupColumns[key]];
6619
6618
  }
6620
6619
  query.data.push(d);
6621
6620
  }
@@ -6883,7 +6882,7 @@ var preIndex = function (query) {
6883
6882
  // Check if index already exists
6884
6883
  var ixx =
6885
6884
  alasql.databases[source.databaseid].tables[source.tableid].indices[
6886
- hash(source.onrightfns + '`' + source.srcwherefns)
6885
+ hash(source.onrightfns + '`' + source.srcwherefns)
6887
6886
  ];
6888
6887
  if (!alasql.databases[source.databaseid].tables[source.tableid].dirty && ixx) {
6889
6888
  source.ix = ixx;
@@ -6938,7 +6937,7 @@ var preIndex = function (query) {
6938
6937
  // Check if index exists
6939
6938
  ixx =
6940
6939
  alasql.databases[source.databaseid].tables[source.tableid].indices[
6941
- hash(source.wxleftfns + '`')
6940
+ hash(source.wxleftfns + '`')
6942
6941
  ];
6943
6942
  }
6944
6943
  if (!alasql.databases[source.databaseid].tables[source.tableid].dirty && ixx) {
@@ -8681,7 +8680,7 @@ yy.Select.prototype.compileGroup = function (query) {
8681
8680
  aft2 = '';
8682
8681
 
8683
8682
  if (typeof query.groupStar !== 'undefined') {
8684
- aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
8683
+ 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];};";
8685
8684
  }
8686
8685
 
8687
8686
  /*
@@ -9073,9 +9072,10 @@ function compileSelectStar(query, aliases, joinstar) {
9073
9072
 
9074
9073
  if (columns && columns.length > 0) {
9075
9074
  columns.forEach(function (tcol) {
9075
+ const escapedColumnId = escapeq(tcol.columnid);
9076
9076
  if (joinstar && alasql.options.joinstar == 'underscore') {
9077
9077
  ss.push(
9078
- "'" + alias + '_' + tcol.columnid + "':p['" + alias + "']['" + tcol.columnid + "']"
9078
+ "'" + alias + '_' + escapedColumnId + "':p['" + alias + "']['" + escapedColumnId + "']"
9079
9079
  );
9080
9080
  } else if (joinstar && alasql.options.joinstar == 'json') {
9081
9081
  // ss.push('\''+alias+'_'+tcol.columnid+'\':p[\''+alias+'\'][\''+tcol.columnid+'\']');
@@ -9083,16 +9083,16 @@ function compileSelectStar(query, aliases, joinstar) {
9083
9083
  "r['" +
9084
9084
  alias +
9085
9085
  "']['" +
9086
- tcol.columnid +
9086
+ escapedColumnId +
9087
9087
  "']=p['" +
9088
9088
  alias +
9089
9089
  "']['" +
9090
- tcol.columnid +
9090
+ escapedColumnId +
9091
9091
  "'];";
9092
9092
  } else {
9093
- var value = "p['" + alias + "']['" + tcol.columnid + "']";
9093
+ var value = "p['" + alias + "']['" + escapedColumnId + "']";
9094
9094
  if (!columnIds[tcol.columnid]) {
9095
- var key = "'" + tcol.columnid + "':";
9095
+ var key = "'" + escapedColumnId + "':";
9096
9096
  ss.push(key + value);
9097
9097
  columnIds[tcol.columnid] = {
9098
9098
  id: ss.length - 1,
@@ -9107,7 +9107,7 @@ function compileSelectStar(query, aliases, joinstar) {
9107
9107
  }
9108
9108
  }
9109
9109
 
9110
- query.selectColumns[escapeq(tcol.columnid)] = true;
9110
+ query.selectColumns[escapedColumnId] = true;
9111
9111
 
9112
9112
  var coldef = {
9113
9113
  columnid: tcol.columnid,
@@ -9123,7 +9123,7 @@ function compileSelectStar(query, aliases, joinstar) {
9123
9123
  } else {
9124
9124
 
9125
9125
  // if column not exist, then copy all
9126
- sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
9126
+ 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]};';
9127
9127
 
9128
9128
  query.dirtyColumns = true;
9129
9129
  }
@@ -9451,10 +9451,10 @@ yy.Select.prototype.compileSelectGroup1 = function (query) {
9451
9451
  self.columns.forEach(function (col) {
9452
9452
 
9453
9453
  if (col instanceof yy.Column && col.columnid === '*') {
9454
- // s += 'for(var k in g){r[k]=g[k]};';
9454
+ // s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9455
9455
  // s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
9456
9456
 
9457
- s += 'for(var k in g) {r[k]=g[k]};';
9457
+ s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
9458
9458
  return '';
9459
9459
 
9460
9460
  } else {
@@ -10574,7 +10574,7 @@ yy.Over = class Over {
10574
10574
  var ljs = '(' + leftJS() + '||{})';
10575
10575
 
10576
10576
  if (typeof this.right === 'string') {
10577
- s = ljs + '["' + this.right + '"]';
10577
+ s = ljs + '["' + escapeq(this.right) + '"]';
10578
10578
  } else if (typeof this.right === 'number') {
10579
10579
  s = ljs + '[' + this.right + ']';
10580
10580
  } else if (this.right instanceof yy.FuncValue) {
@@ -10813,7 +10813,7 @@ yy.Over = class Over {
10813
10813
  }
10814
10814
 
10815
10815
  toJS() {
10816
- return "alasql.vars['" + this.variable + "']";
10816
+ return "alasql.vars['" + escapeq(this.variable) + "']";
10817
10817
  }
10818
10818
  }
10819
10819
 
@@ -11202,7 +11202,7 @@ yy.Over = class Over {
11202
11202
  toJS() {
11203
11203
  var colas = this.nick;
11204
11204
  if (colas === undefined) {
11205
- colas = this.toString();
11205
+ colas = escapeq(this.toString());
11206
11206
  }
11207
11207
  return "g['" + colas + "']";
11208
11208
  }
@@ -12715,7 +12715,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
12715
12715
 
12716
12716
  table.update(
12717
12717
  function (t) {
12718
- for (var f in r) t[f] = r[f];
12718
+ for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
12719
12719
  },
12720
12720
  table.data.indexOf(toreplace),
12721
12721
  params
@@ -14268,7 +14268,7 @@ yy.Insert.prototype.compile = function (databaseid) {
14268
14268
  });
14269
14269
  } else {
14270
14270
 
14271
- // sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
14271
+ // 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]};';
14272
14272
  sw = JSONtoJS(values);
14273
14273
  }
14274
14274
  }