alasql 4.17.2 → 4.17.4

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/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.17.1 build: develop-a8ee499a | © 2014-2025 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.17.4 build: develop-f960d23a | © 2014-2025 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.17.1
4
+ @version 4.17.4
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2025 Andrey Gershun & Mathias Wulff
@@ -141,8 +141,8 @@ SOFTWARE.
141
141
  Current version of alasql
142
142
  @constant {string}
143
143
  */
144
- alasql.version = '4.17.1';
145
- alasql.build = 'develop-a8ee499a';
144
+ alasql.version = '4.17.4';
145
+ alasql.build = 'develop-f960d23a';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -4581,11 +4581,11 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
4581
4581
  return +obj;
4582
4582
  }
4583
4583
 
4584
- var temp = new obj.constructor(); // changed
4584
+ var temp = new (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
4585
4585
 
4586
4586
  for (var key in obj) {
4587
4587
  if (obj.hasOwnProperty(key)) {
4588
- temp[key] = cloneDeep(obj[key]);
4588
+ /* 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]); }
4589
4589
  }
4590
4590
  }
4591
4591
  return temp;
@@ -4657,7 +4657,7 @@ var extend = (utils.extend = function extend(a, b) {
4657
4657
  a = a || {};
4658
4658
  for (var key in b) {
4659
4659
  if (b.hasOwnProperty(key)) {
4660
- a[key] = b[key];
4660
+ /* 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]; }
4661
4661
  }
4662
4662
  }
4663
4663
  return a;
@@ -9615,7 +9615,7 @@ yy.Select.prototype.compileGroup = function (query) {
9615
9615
  aft2 = '';
9616
9616
 
9617
9617
  if (typeof query.groupStar !== 'undefined') {
9618
- aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
9618
+ 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];};";
9619
9619
  }
9620
9620
 
9621
9621
  s += query.selectGroup
@@ -10099,7 +10099,7 @@ function compileSelectStar(query, aliases, joinstar) {
10099
10099
  'var w=p["' + escapeq(alias) + '"];for(var k in w){r["' + escapeq(alias) + '_"+k]=w[k]};';
10100
10100
  } else {
10101
10101
  // Default overwrite mode
10102
- sp += 'var w=p["' + escapeq(alias) + '"];for(var k in w){r[k]=w[k]};';
10102
+ sp += 'var w=p["' + escapeq(alias) + '"];for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
10103
10103
  }
10104
10104
 
10105
10105
  query.dirtyColumns = true;
@@ -10575,10 +10575,10 @@ yy.Select.prototype.compileSelectGroup1 = function (query) {
10575
10575
  self.columns.forEach(function (col) {
10576
10576
 
10577
10577
  if (col instanceof yy.Column && col.columnid === '*') {
10578
- // s += 'for(var k in g){r[k]=g[k]};';
10578
+ // s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
10579
10579
  // s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
10580
10580
 
10581
- s += 'for(var k in g) {r[k]=g[k]};';
10581
+ s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
10582
10582
  return '';
10583
10583
 
10584
10584
  } else {
@@ -11880,7 +11880,7 @@ yy.Over = class Over {
11880
11880
  const allValues = this.right.map(value => value.value);
11881
11881
  const allValuesStr = allValues.join(',');
11882
11882
  alasql.sets[allValuesStr] = alasql.sets[allValuesStr] || new Set(allValues);
11883
- s = `alasql.sets["${allValuesStr}"].has(alasql.utils.getValueOf(${leftJS()}))`;
11883
+ s = `alasql.sets[${JSON.stringify(allValuesStr)}].has(alasql.utils.getValueOf(${leftJS()}))`;
11884
11884
  }
11885
11885
  } else {
11886
11886
  s = `(${rightJS()}.indexOf(${leftJS()}) > -1)`;
@@ -11914,7 +11914,7 @@ yy.Over = class Over {
11914
11914
  const allValues = this.right.map(value => value.value);
11915
11915
  const allValuesStr = allValues.join(',');
11916
11916
  alasql.sets[allValuesStr] = alasql.sets[allValuesStr] || new Set(allValues);
11917
- s = `!alasql.sets["${allValuesStr}"].has(alasql.utils.getValueOf(${leftJS()}))`;
11917
+ s = `!alasql.sets[${JSON.stringify(allValuesStr)}].has(alasql.utils.getValueOf(${leftJS()}))`;
11918
11918
  }
11919
11919
  } else {
11920
11920
  s = `(${rightJS()}.indexOf(${leftJS()}) === -1)`;
@@ -13941,7 +13941,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
13941
13941
 
13942
13942
  table.update(
13943
13943
  function (t) {
13944
- for (var f in r) t[f] = r[f];
13944
+ for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
13945
13945
  },
13946
13946
  table.data.indexOf(toreplace),
13947
13947
  params
@@ -15712,7 +15712,7 @@ yy.Insert.prototype.compile = function (databaseid) {
15712
15712
  });
15713
15713
  } else {
15714
15714
 
15715
- // sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
15715
+ // 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]};';
15716
15716
  sw = JSONtoJS(values);
15717
15717
  }
15718
15718
  }
@@ -15791,7 +15791,7 @@ yy.Insert.prototype.compile = function (databaseid) {
15791
15791
  self.output.columns.forEach(function (col) {
15792
15792
  if (col.columnid === '*') {
15793
15793
  // For *, expand all properties
15794
- s += 'for(var key in r){ outputRow[key] = r[key]; }';
15794
+ s += 'for(var key in r){ if(/^__proto__$/.test(key))Object.defineProperty(outputRow,key,{writable:true,enumerable:true,configurable:true});outputRow[key] = r[key]; }';
15795
15795
  } else {
15796
15796
  var colname = col.as || col.columnid;
15797
15797
  // Direct property access for simple columns
@@ -15870,7 +15870,7 @@ yy.Insert.prototype.compile = function (databaseid) {
15870
15870
  if (col.columnid === '*') {
15871
15871
  // For *, expand all properties
15872
15872
  for (var key in r) {
15873
- outputRow[key] = r[key];
15873
+ if(/^__proto__$/.test(key))Object.defineProperty(outputRow,key,{writable:true,enumerable:true,configurable:true});outputRow[key] = r[key];
15874
15874
  }
15875
15875
  } else {
15876
15876
  var colname = col.as || col.columnid;
@@ -16221,7 +16221,7 @@ yy.Delete.prototype.compile = function (databaseid) {
16221
16221
  if (col.columnid === '*') {
16222
16222
  // For *, expand all properties
16223
16223
  for (var key in r) {
16224
- outputRow[key] = r[key];
16224
+ if(/^__proto__$/.test(key))Object.defineProperty(outputRow,key,{writable:true,enumerable:true,configurable:true});outputRow[key] = r[key];
16225
16225
  }
16226
16226
  } else {
16227
16227
  var colname = col.as || col.columnid;
@@ -16292,7 +16292,7 @@ yy.Delete.prototype.compile = function (databaseid) {
16292
16292
  if (col.columnid === '*') {
16293
16293
  // For *, expand all properties
16294
16294
  for (var key in r) {
16295
- outputRow[key] = r[key];
16295
+ if(/^__proto__$/.test(key))Object.defineProperty(outputRow,key,{writable:true,enumerable:true,configurable:true});outputRow[key] = r[key];
16296
16296
  }
16297
16297
  } else {
16298
16298
  var colname = col.as || col.columnid;
@@ -16462,7 +16462,7 @@ yy.Update.prototype.compile = function (databaseid) {
16462
16462
  if (col.columnid === '*') {
16463
16463
  // For *, use INSERTED values
16464
16464
  for (var key in inserted) {
16465
- outputRow[key] = inserted[key];
16465
+ if(/^__proto__$/.test(key))Object.defineProperty(outputRow,key,{writable:true,enumerable:true,configurable:true});outputRow[key] = inserted[key];
16466
16466
  }
16467
16467
  } else {
16468
16468
  var colname = col.as || col.columnid;
@@ -18900,8 +18900,8 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
18900
18900
  alasql.utils.extend(opt, opts);
18901
18901
  var res;
18902
18902
  var hs = [];
18903
- // Determine once whether to auto-convert: not raw mode and not SELECT INTO
18904
- const shouldAutoConvert = !opt.raw && !query?.intofns;
18903
+ // Determine once whether to auto-convert: not raw mode, not SELECT INTO, and csvStringToNumber option is set
18904
+ const shouldAutoConvert = !opt.raw && !query?.intofns && alasql.options.csvStringToNumber;
18905
18905
 
18906
18906
  function potentialAutoConvert(val) {
18907
18907
  if (shouldAutoConvert && val !== undefined && val.length !== 0 && val == +val) {