alasql 4.2.0 → 4.2.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.
package/README.md CHANGED
@@ -97,10 +97,13 @@ var res = alasql("SELECT * FROM example1 ORDER BY b DESC");
97
97
  console.log(res); // [{a:2,b:6},{a:1,b:5},{a:3,b:4}]
98
98
  ```
99
99
 
100
-
101
100
  __If you are familiar with SQL, it should be no surprise that proper use of indexes on your tables is essential for good performance.__
102
101
 
102
+ #### Options
103
+
104
+ AlaSQL has several [configuration options](https://github.com/AlaSQL/alasql/wiki/AlaSQL-Options) which change the behavior. It can be set via SQL statements or via the options object before using `alasql`.
103
105
 
106
+ If you're using `NOW()` in queries often, setting `alasql.options.dateAsString` to `false` speed things up. It will just return a JS Date object instead of a string representation of a date.
104
107
 
105
108
  ## Installation
106
109
 
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.11 build: develop-6870c00d | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.2.0 build: develop-67d9f6dd | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.11
4
+ @version 4.2.0
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.11 build: develop-6870c00d | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.2.0 build: develop-67d9f6dd | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.11
4
+ @version 4.2.0
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.11';
145
- alasql.build = 'develop-6870c00d';
144
+ alasql.version = '4.2.0';
145
+ alasql.build = 'develop-67d9f6dd';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -3227,7 +3227,7 @@ function returnTrue() {
3227
3227
  @function
3228
3228
  @return {undefined} Always undefined
3229
3229
  */
3230
- function returnUndefined() { }
3230
+ function returnUndefined() {}
3231
3231
 
3232
3232
  /**
3233
3233
  Escape string
@@ -3522,7 +3522,7 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
3522
3522
  } else if (utils.isCordova) {
3523
3523
  /* If Cordova */
3524
3524
  utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
3525
- fileSystem.root.getFile(path, { create: false }, function (fileEntry) {
3525
+ fileSystem.root.getFile(path, {create: false}, function (fileEntry) {
3526
3526
  fileEntry.file(function (file) {
3527
3527
  var fileReader = new FileReader();
3528
3528
  fileReader.onloadend = function (e) {
@@ -3711,7 +3711,7 @@ var removeFile = (utils.removeFile = function (path, cb) {
3711
3711
  utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
3712
3712
  fileSystem.root.getFile(
3713
3713
  path,
3714
- { create: false },
3714
+ {create: false},
3715
3715
  function (fileEntry) {
3716
3716
  fileEntry.remove(cb);
3717
3717
  cb && cb(); // jshint ignore:line
@@ -3779,7 +3779,7 @@ var fileExists = (utils.fileExists = function (path, cb) {
3779
3779
  utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
3780
3780
  fileSystem.root.getFile(
3781
3781
  path,
3782
- { create: false },
3782
+ {create: false},
3783
3783
  function (fileEntry) {
3784
3784
  cb(true);
3785
3785
  },
@@ -3845,7 +3845,7 @@ var saveFile = (utils.saveFile = function (path, data, cb, opts) {
3845
3845
  } else if (utils.isCordova) {
3846
3846
  utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
3847
3847
  // alasql.utils.removeFile(path,function(){
3848
- fileSystem.root.getFile(path, { create: true }, function (fileEntry) {
3848
+ fileSystem.root.getFile(path, {create: true}, function (fileEntry) {
3849
3849
  fileEntry.createWriter(function (fileWriter) {
3850
3850
  fileWriter.onwriteend = function () {
3851
3851
  if (cb) {
@@ -3866,7 +3866,7 @@ var saveFile = (utils.saveFile = function (path, data, cb, opts) {
3866
3866
  disableAutoBom: false,
3867
3867
  };
3868
3868
  alasql.utils.extend(opt, opts);
3869
- var blob = new Blob([data], { type: 'text/plain;charset=utf-8' });
3869
+ var blob = new Blob([data], {type: 'text/plain;charset=utf-8'});
3870
3870
  saveAs(blob, path, opt.disableAutoBom);
3871
3871
  if (cb) {
3872
3872
  res = cb(res);
@@ -4543,7 +4543,7 @@ alasql.options = {
4543
4543
  /** Check for NaN and convert it to undefined */
4544
4544
  nan: false,
4545
4545
 
4546
- excel: { cellDates: true },
4546
+ excel: {cellDates: true},
4547
4547
 
4548
4548
  /** Option for SELECT * FROM a,b */
4549
4549
  joinstar: 'overwrite',
@@ -4634,7 +4634,7 @@ alasql.autoval = function (tablename, colname, getNext, databaseid) {
4634
4634
 
4635
4635
  return (
4636
4636
  db.tables[tablename].identities[colname].value -
4637
- db.tables[tablename].identities[colname].step || null
4637
+ db.tables[tablename].identities[colname].step || null
4638
4638
  );
4639
4639
  };
4640
4640
 
@@ -10705,17 +10705,13 @@ yy.Over = class Over {
10705
10705
  s += '.indexOf(';
10706
10706
  s += 'alasql.utils.getValueOf(' + leftJS() + '))>-1)';
10707
10707
  } else if (Array.isArray(this.right)) {
10708
- // Added patch to have a better performance for when you have a lot of entries in an IN statement
10709
- if (!alasql.sets) {
10710
- alasql.sets = {};
10711
- }
10712
- const allValues = this.right.map((value) => value.value);
10713
- const allValuesStr = allValues.join(",");
10714
- if (!alasql.sets[allValuesStr]) {
10715
- // leverage JS Set, which is faster for lookups than arrays
10716
- alasql.sets[allValuesStr] = new Set(allValues);
10717
- }
10718
- s = 'alasql.sets["' + allValuesStr + '"].has(alasql.utils.getValueOf(' + leftJS() + '))';
10708
+ // leverage JS Set, which is faster for lookups than arrays
10709
+ s =
10710
+ '(new Set([' +
10711
+ this.right.map(ref).join(',') +
10712
+ ']).has(alasql.utils.getValueOf(' +
10713
+ leftJS() +
10714
+ ')))';
10719
10715
  } else {
10720
10716
  s = '(' + rightJS() + '.indexOf(' + leftJS() + ')>-1)';
10721
10717
 
@@ -10731,17 +10727,13 @@ yy.Over = class Over {
10731
10727
  s += '.indexOf(';
10732
10728
  s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
10733
10729
  } else if (Array.isArray(this.right)) {
10734
- // Added patch to have a better performance for when you have a lot of entries in a NOT IN statement
10735
- if (!alasql.sets) {
10736
- alasql.sets = {};
10737
- }
10738
- const allValues = this.right.map((value) => value.value);
10739
- const allValuesStr = allValues.join(",");
10740
- if (!alasql.sets[allValuesStr]) {
10741
- // leverage JS Set, which is faster for lookups than arrays
10742
- alasql.sets[allValuesStr] = new Set(allValues);
10743
- }
10744
- s = '!alasql.sets["' + allValuesStr + '"].has(alasql.utils.getValueOf(' + leftJS() + '))';
10730
+ // leverage JS Set, which is faster for lookups than arrays
10731
+ s =
10732
+ '(!(new Set([' +
10733
+ this.right.map(ref).join(',') +
10734
+ ']).has(alasql.utils.getValueOf(' +
10735
+ leftJS() +
10736
+ '))))';
10745
10737
  } else {
10746
10738
  s = '(' + rightJS() + '.indexOf(';
10747
10739
  s += leftJS() + ')==-1)';
@@ -10984,7 +10976,7 @@ yy.Over = class Over {
10984
10976
 
10985
10977
  toString() {
10986
10978
  var s;
10987
- const { op, right } = this;
10979
+ const {op, right} = this;
10988
10980
  const res = right.toString();
10989
10981
 
10990
10982
  if (op === '~') {
@@ -13019,7 +13011,8 @@ stdfn.OBJECT_ID = function (objid) {
13019
13011
  };
13020
13012
 
13021
13013
  stdfn.DATE = function (d) {
13022
- if (!isNaN(d) && d.length === 8) return new Date(+d.substr(0, 4), +d.substr(4, 2) - 1, +d.substr(6, 2));
13014
+ if (!isNaN(d) && d.length === 8)
13015
+ return new Date(+d.substr(0, 4), +d.substr(4, 2) - 1, +d.substr(6, 2));
13023
13016
  return newDate(d);
13024
13017
  };
13025
13018
 
package/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.11 build: develop-6870c00d | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.2.0 build: develop-67d9f6dd | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.11
4
+ @version 4.2.0
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.11';
145
- alasql.build = 'develop-6870c00d';
144
+ alasql.version = '4.2.0';
145
+ alasql.build = 'develop-67d9f6dd';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -3227,7 +3227,7 @@ function returnTrue() {
3227
3227
  @function
3228
3228
  @return {undefined} Always undefined
3229
3229
  */
3230
- function returnUndefined() { }
3230
+ function returnUndefined() {}
3231
3231
 
3232
3232
  /**
3233
3233
  Escape string
@@ -3522,7 +3522,7 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
3522
3522
  } else if (utils.isCordova) {
3523
3523
  /* If Cordova */
3524
3524
  utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
3525
- fileSystem.root.getFile(path, { create: false }, function (fileEntry) {
3525
+ fileSystem.root.getFile(path, {create: false}, function (fileEntry) {
3526
3526
  fileEntry.file(function (file) {
3527
3527
  var fileReader = new FileReader();
3528
3528
  fileReader.onloadend = function (e) {
@@ -3711,7 +3711,7 @@ var removeFile = (utils.removeFile = function (path, cb) {
3711
3711
  utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
3712
3712
  fileSystem.root.getFile(
3713
3713
  path,
3714
- { create: false },
3714
+ {create: false},
3715
3715
  function (fileEntry) {
3716
3716
  fileEntry.remove(cb);
3717
3717
  cb && cb(); // jshint ignore:line
@@ -3779,7 +3779,7 @@ var fileExists = (utils.fileExists = function (path, cb) {
3779
3779
  utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
3780
3780
  fileSystem.root.getFile(
3781
3781
  path,
3782
- { create: false },
3782
+ {create: false},
3783
3783
  function (fileEntry) {
3784
3784
  cb(true);
3785
3785
  },
@@ -3845,7 +3845,7 @@ var saveFile = (utils.saveFile = function (path, data, cb, opts) {
3845
3845
  } else if (utils.isCordova) {
3846
3846
  utils.global.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
3847
3847
  // alasql.utils.removeFile(path,function(){
3848
- fileSystem.root.getFile(path, { create: true }, function (fileEntry) {
3848
+ fileSystem.root.getFile(path, {create: true}, function (fileEntry) {
3849
3849
  fileEntry.createWriter(function (fileWriter) {
3850
3850
  fileWriter.onwriteend = function () {
3851
3851
  if (cb) {
@@ -3866,7 +3866,7 @@ var saveFile = (utils.saveFile = function (path, data, cb, opts) {
3866
3866
  disableAutoBom: false,
3867
3867
  };
3868
3868
  alasql.utils.extend(opt, opts);
3869
- var blob = new Blob([data], { type: 'text/plain;charset=utf-8' });
3869
+ var blob = new Blob([data], {type: 'text/plain;charset=utf-8'});
3870
3870
  saveAs(blob, path, opt.disableAutoBom);
3871
3871
  if (cb) {
3872
3872
  res = cb(res);
@@ -4543,7 +4543,7 @@ alasql.options = {
4543
4543
  /** Check for NaN and convert it to undefined */
4544
4544
  nan: false,
4545
4545
 
4546
- excel: { cellDates: true },
4546
+ excel: {cellDates: true},
4547
4547
 
4548
4548
  /** Option for SELECT * FROM a,b */
4549
4549
  joinstar: 'overwrite',
@@ -4634,7 +4634,7 @@ alasql.autoval = function (tablename, colname, getNext, databaseid) {
4634
4634
 
4635
4635
  return (
4636
4636
  db.tables[tablename].identities[colname].value -
4637
- db.tables[tablename].identities[colname].step || null
4637
+ db.tables[tablename].identities[colname].step || null
4638
4638
  );
4639
4639
  };
4640
4640
 
@@ -10705,17 +10705,13 @@ yy.Over = class Over {
10705
10705
  s += '.indexOf(';
10706
10706
  s += 'alasql.utils.getValueOf(' + leftJS() + '))>-1)';
10707
10707
  } else if (Array.isArray(this.right)) {
10708
- // Added patch to have a better performance for when you have a lot of entries in an IN statement
10709
- if (!alasql.sets) {
10710
- alasql.sets = {};
10711
- }
10712
- const allValues = this.right.map((value) => value.value);
10713
- const allValuesStr = allValues.join(",");
10714
- if (!alasql.sets[allValuesStr]) {
10715
- // leverage JS Set, which is faster for lookups than arrays
10716
- alasql.sets[allValuesStr] = new Set(allValues);
10717
- }
10718
- s = 'alasql.sets["' + allValuesStr + '"].has(alasql.utils.getValueOf(' + leftJS() + '))';
10708
+ // leverage JS Set, which is faster for lookups than arrays
10709
+ s =
10710
+ '(new Set([' +
10711
+ this.right.map(ref).join(',') +
10712
+ ']).has(alasql.utils.getValueOf(' +
10713
+ leftJS() +
10714
+ ')))';
10719
10715
  } else {
10720
10716
  s = '(' + rightJS() + '.indexOf(' + leftJS() + ')>-1)';
10721
10717
 
@@ -10731,17 +10727,13 @@ yy.Over = class Over {
10731
10727
  s += '.indexOf(';
10732
10728
  s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
10733
10729
  } else if (Array.isArray(this.right)) {
10734
- // Added patch to have a better performance for when you have a lot of entries in a NOT IN statement
10735
- if (!alasql.sets) {
10736
- alasql.sets = {};
10737
- }
10738
- const allValues = this.right.map((value) => value.value);
10739
- const allValuesStr = allValues.join(",");
10740
- if (!alasql.sets[allValuesStr]) {
10741
- // leverage JS Set, which is faster for lookups than arrays
10742
- alasql.sets[allValuesStr] = new Set(allValues);
10743
- }
10744
- s = '!alasql.sets["' + allValuesStr + '"].has(alasql.utils.getValueOf(' + leftJS() + '))';
10730
+ // leverage JS Set, which is faster for lookups than arrays
10731
+ s =
10732
+ '(!(new Set([' +
10733
+ this.right.map(ref).join(',') +
10734
+ ']).has(alasql.utils.getValueOf(' +
10735
+ leftJS() +
10736
+ '))))';
10745
10737
  } else {
10746
10738
  s = '(' + rightJS() + '.indexOf(';
10747
10739
  s += leftJS() + ')==-1)';
@@ -10984,7 +10976,7 @@ yy.Over = class Over {
10984
10976
 
10985
10977
  toString() {
10986
10978
  var s;
10987
- const { op, right } = this;
10979
+ const {op, right} = this;
10988
10980
  const res = right.toString();
10989
10981
 
10990
10982
  if (op === '~') {
@@ -13019,7 +13011,8 @@ stdfn.OBJECT_ID = function (objid) {
13019
13011
  };
13020
13012
 
13021
13013
  stdfn.DATE = function (d) {
13022
- if (!isNaN(d) && d.length === 8) return new Date(+d.substr(0, 4), +d.substr(4, 2) - 1, +d.substr(6, 2));
13014
+ if (!isNaN(d) && d.length === 8)
13015
+ return new Date(+d.substr(0, 4), +d.substr(4, 2) - 1, +d.substr(6, 2));
13023
13016
  return newDate(d);
13024
13017
  };
13025
13018