alasql 4.2.1 → 4.2.3

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/Untitled-1.js ADDED
@@ -0,0 +1 @@
1
+ ≤
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.2.0 build: develop-67d9f6dd | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.2.2 build: develop-a55b6500 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.2.0
4
+ @version 4.2.2
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.2.0 build: develop-67d9f6dd | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.2.2 build: develop-a55b6500 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.2.0
4
+ @version 4.2.2
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.2.0';
145
- alasql.build = 'develop-67d9f6dd';
144
+ alasql.version = '4.2.2';
145
+ alasql.build = 'develop-a55b6500';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -4393,7 +4393,7 @@ alasql.utils.uncomment = function (str) {
4393
4393
  }
4394
4394
  } else if (lineComment) {
4395
4395
  // One-line comments end with the line-break
4396
- if (str[i + 1] === '\n' || str[i + 1] === '\r') {
4396
+ if (str[i + 1] === '\n' || str[i + 1] === '\r' || str.length - 2 === i) {
4397
4397
  lineComment = false;
4398
4398
  }
4399
4399
  str[i] = '';
@@ -4404,9 +4404,9 @@ alasql.utils.uncomment = function (str) {
4404
4404
  } else if (str[i] === '[' && str[i - 1] !== '@') {
4405
4405
  quote = true;
4406
4406
  quoteSign = ']';
4407
- // } else if (str[i] === '-' && str[i + 1] === '-') {
4408
- // str[i] = '';
4409
- // lineComment = true;
4407
+ } else if (str[i] === '-' && str[i + 1] === '-') {
4408
+ str[i] = '';
4409
+ lineComment = true;
4410
4410
  } else if (str[i] === '/' && str[i + 1] === '*') {
4411
4411
  // Do not filter out conditional comments /*@ ... */
4412
4412
  // and comments marked as protected /*! ... */
@@ -6629,8 +6629,10 @@ function queryfn3(query) {
6629
6629
  var d = query.selectgfn(g, query.params, alasql);
6630
6630
 
6631
6631
  for (const key in query.groupColumns) {
6632
- if (query.groupColumns[key] !== key && d[query.groupColumns[key]])
6632
+ // ony remove columns where the alias is also not a column in the result
6633
+ if (query.groupColumns[key] !== key && d[query.groupColumns[key]] && !query.groupColumns[query.groupColumns[key]]){
6633
6634
  delete d[query.groupColumns[key]];
6635
+ }
6634
6636
  }
6635
6637
  query.data.push(d);
6636
6638
  }
@@ -10705,13 +10707,28 @@ yy.Over = class Over {
10705
10707
  s += '.indexOf(';
10706
10708
  s += 'alasql.utils.getValueOf(' + leftJS() + '))>-1)';
10707
10709
  } else if (Array.isArray(this.right)) {
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
- ')))';
10710
+ if (!alasql.options.cache || this.right.filter((value) => value instanceof yy.ParamValue).length > 0) {
10711
+ // When not using cache, or when the array contains parameters, we need to re-create the Set
10712
+ // leverage JS Set, which is faster for lookups than arrays
10713
+ s =
10714
+ '(new Set([' +
10715
+ this.right.map(ref).join(',') +
10716
+ ']).has(alasql.utils.getValueOf(' +
10717
+ leftJS() +
10718
+ ')))';
10719
+ } else {
10720
+ // Use a cache to not re-create the Set on every identitical query
10721
+ if (!alasql.sets) {
10722
+ alasql.sets = {};
10723
+ }
10724
+ const allValues = this.right.map((value) => value.value);
10725
+ const allValuesStr = allValues.join(",");
10726
+ if (!alasql.sets[allValuesStr]) {
10727
+ // leverage JS Set, which is faster for lookups than arrays
10728
+ alasql.sets[allValuesStr] = new Set(allValues);
10729
+ }
10730
+ s = 'alasql.sets["' + allValuesStr + '"].has(alasql.utils.getValueOf(' + leftJS() + '))';
10731
+ }
10715
10732
  } else {
10716
10733
  s = '(' + rightJS() + '.indexOf(' + leftJS() + ')>-1)';
10717
10734
 
@@ -10727,13 +10744,28 @@ yy.Over = class Over {
10727
10744
  s += '.indexOf(';
10728
10745
  s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
10729
10746
  } else if (Array.isArray(this.right)) {
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
- '))))';
10747
+ if (!alasql.options.cache || this.right.filter((value) => value instanceof yy.ParamValue).length > 0) {
10748
+ // When not using cache, or when the array contains parameters, we need to re-create the Set
10749
+ // leverage JS Set, which is faster for lookups than arrays
10750
+ s =
10751
+ '(!(new Set([' +
10752
+ this.right.map(ref).join(',') +
10753
+ ']).has(alasql.utils.getValueOf(' +
10754
+ leftJS() +
10755
+ '))))';
10756
+ } else {
10757
+ // Use a cache to not re-create the Set on every identitical query
10758
+ if (!alasql.sets) {
10759
+ alasql.sets = {};
10760
+ }
10761
+ const allValues = this.right.map((value) => value.value);
10762
+ const allValuesStr = allValues.join(",");
10763
+ if (!alasql.sets[allValuesStr]) {
10764
+ // leverage JS Set, which is faster for lookups than arrays
10765
+ alasql.sets[allValuesStr] = new Set(allValues);
10766
+ }
10767
+ s = '!alasql.sets["' + allValuesStr + '"].has(alasql.utils.getValueOf(' + leftJS() + '))';
10768
+ }
10737
10769
  } else {
10738
10770
  s = '(' + rightJS() + '.indexOf(';
10739
10771
  s += leftJS() + ')==-1)';
@@ -10976,7 +11008,7 @@ yy.Over = class Over {
10976
11008
 
10977
11009
  toString() {
10978
11010
  var s;
10979
- const {op, right} = this;
11011
+ const { op, right } = this;
10980
11012
  const res = right.toString();
10981
11013
 
10982
11014
  if (op === '~') {
package/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.2.0 build: develop-67d9f6dd | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.2.2 build: develop-a55b6500 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.2.0
4
+ @version 4.2.2
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.2.0';
145
- alasql.build = 'develop-67d9f6dd';
144
+ alasql.version = '4.2.2';
145
+ alasql.build = 'develop-a55b6500';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -4393,7 +4393,7 @@ alasql.utils.uncomment = function (str) {
4393
4393
  }
4394
4394
  } else if (lineComment) {
4395
4395
  // One-line comments end with the line-break
4396
- if (str[i + 1] === '\n' || str[i + 1] === '\r') {
4396
+ if (str[i + 1] === '\n' || str[i + 1] === '\r' || str.length - 2 === i) {
4397
4397
  lineComment = false;
4398
4398
  }
4399
4399
  str[i] = '';
@@ -4404,9 +4404,9 @@ alasql.utils.uncomment = function (str) {
4404
4404
  } else if (str[i] === '[' && str[i - 1] !== '@') {
4405
4405
  quote = true;
4406
4406
  quoteSign = ']';
4407
- // } else if (str[i] === '-' && str[i + 1] === '-') {
4408
- // str[i] = '';
4409
- // lineComment = true;
4407
+ } else if (str[i] === '-' && str[i + 1] === '-') {
4408
+ str[i] = '';
4409
+ lineComment = true;
4410
4410
  } else if (str[i] === '/' && str[i + 1] === '*') {
4411
4411
  // Do not filter out conditional comments /*@ ... */
4412
4412
  // and comments marked as protected /*! ... */
@@ -6629,8 +6629,10 @@ function queryfn3(query) {
6629
6629
  var d = query.selectgfn(g, query.params, alasql);
6630
6630
 
6631
6631
  for (const key in query.groupColumns) {
6632
- if (query.groupColumns[key] !== key && d[query.groupColumns[key]])
6632
+ // ony remove columns where the alias is also not a column in the result
6633
+ if (query.groupColumns[key] !== key && d[query.groupColumns[key]] && !query.groupColumns[query.groupColumns[key]]){
6633
6634
  delete d[query.groupColumns[key]];
6635
+ }
6634
6636
  }
6635
6637
  query.data.push(d);
6636
6638
  }
@@ -10705,13 +10707,28 @@ yy.Over = class Over {
10705
10707
  s += '.indexOf(';
10706
10708
  s += 'alasql.utils.getValueOf(' + leftJS() + '))>-1)';
10707
10709
  } else if (Array.isArray(this.right)) {
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
- ')))';
10710
+ if (!alasql.options.cache || this.right.filter((value) => value instanceof yy.ParamValue).length > 0) {
10711
+ // When not using cache, or when the array contains parameters, we need to re-create the Set
10712
+ // leverage JS Set, which is faster for lookups than arrays
10713
+ s =
10714
+ '(new Set([' +
10715
+ this.right.map(ref).join(',') +
10716
+ ']).has(alasql.utils.getValueOf(' +
10717
+ leftJS() +
10718
+ ')))';
10719
+ } else {
10720
+ // Use a cache to not re-create the Set on every identitical query
10721
+ if (!alasql.sets) {
10722
+ alasql.sets = {};
10723
+ }
10724
+ const allValues = this.right.map((value) => value.value);
10725
+ const allValuesStr = allValues.join(",");
10726
+ if (!alasql.sets[allValuesStr]) {
10727
+ // leverage JS Set, which is faster for lookups than arrays
10728
+ alasql.sets[allValuesStr] = new Set(allValues);
10729
+ }
10730
+ s = 'alasql.sets["' + allValuesStr + '"].has(alasql.utils.getValueOf(' + leftJS() + '))';
10731
+ }
10715
10732
  } else {
10716
10733
  s = '(' + rightJS() + '.indexOf(' + leftJS() + ')>-1)';
10717
10734
 
@@ -10727,13 +10744,28 @@ yy.Over = class Over {
10727
10744
  s += '.indexOf(';
10728
10745
  s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
10729
10746
  } else if (Array.isArray(this.right)) {
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
- '))))';
10747
+ if (!alasql.options.cache || this.right.filter((value) => value instanceof yy.ParamValue).length > 0) {
10748
+ // When not using cache, or when the array contains parameters, we need to re-create the Set
10749
+ // leverage JS Set, which is faster for lookups than arrays
10750
+ s =
10751
+ '(!(new Set([' +
10752
+ this.right.map(ref).join(',') +
10753
+ ']).has(alasql.utils.getValueOf(' +
10754
+ leftJS() +
10755
+ '))))';
10756
+ } else {
10757
+ // Use a cache to not re-create the Set on every identitical query
10758
+ if (!alasql.sets) {
10759
+ alasql.sets = {};
10760
+ }
10761
+ const allValues = this.right.map((value) => value.value);
10762
+ const allValuesStr = allValues.join(",");
10763
+ if (!alasql.sets[allValuesStr]) {
10764
+ // leverage JS Set, which is faster for lookups than arrays
10765
+ alasql.sets[allValuesStr] = new Set(allValues);
10766
+ }
10767
+ s = '!alasql.sets["' + allValuesStr + '"].has(alasql.utils.getValueOf(' + leftJS() + '))';
10768
+ }
10737
10769
  } else {
10738
10770
  s = '(' + rightJS() + '.indexOf(';
10739
10771
  s += leftJS() + ')==-1)';
@@ -10976,7 +11008,7 @@ yy.Over = class Over {
10976
11008
 
10977
11009
  toString() {
10978
11010
  var s;
10979
- const {op, right} = this;
11011
+ const { op, right } = this;
10980
11012
  const res = right.toString();
10981
11013
 
10982
11014
  if (op === '~') {