alasql 2.2.0 → 2.2.2

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.
@@ -1,7 +1,7 @@
1
- //! AlaSQL v2.1.8-develop-7e87d661 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.2.1-develop-86ee0810 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.1.8-develop-7e87d661
4
+ @version 2.2.1-develop-86ee0810
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -1,2 +1,2 @@
1
- //! AlaSQL v2.1.8-develop-7e87d661 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.2.1-develop-86ee0810 | © 2014-2022 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.1.8-develop-7e87d661 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.2.1-develop-86ee0810 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.1.8-develop-7e87d661
4
+ @version 2.2.1-develop-86ee0810
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -142,7 +142,7 @@ var alasql = function(sql, params, cb, scope) {
142
142
  Current version of alasql
143
143
  @constant {string}
144
144
  */
145
- alasql.version = '2.1.8-develop-7e87d661';
145
+ alasql.version = '2.2.1-develop-86ee0810';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -6593,10 +6593,8 @@ function queryfn3(query) {
6593
6593
  if (query.selectGroup.length > 0) {
6594
6594
 
6595
6595
  query.selectGroup.forEach(function (sg) {
6596
- if (sg.aggregatorid == 'COUNT') {
6596
+ if (sg.aggregatorid == 'COUNT' || sg.aggregatorid == 'SUM') {
6597
6597
  g[sg.nick] = 0;
6598
- } else if (sg.aggregatorid == 'SUM') {
6599
- g[sg.nick] = 'NULL';
6600
6598
  } else {
6601
6599
  g[sg.nick] = undefined;
6602
6600
  }
@@ -8722,9 +8720,9 @@ yy.Select.prototype.compileGroup = function (query) {
8722
8720
  if ('funcid' in col.expression) {
8723
8721
  let colexpression = col.expression.args[0];
8724
8722
  let colexp1 = colexpression.toJS('p', tableid, defcols);
8725
- return "'" + colas + "':(" + colexp1 + ')||null,';
8723
+ return `'${colas}':(${colexp1})|| typeof ${colexp1} == 'number' ? ${colexp1} : null,`;
8726
8724
  }
8727
- return "'" + colas + "':(" + colexp + ')||null,';
8725
+ return `'${colas}':(${colexp})|| typeof ${colexp} == 'number' ? ${colexp} : null,`;
8728
8726
  } else if (
8729
8727
  col.aggregatorid === 'FIRST' ||
8730
8728
  col.aggregatorid === 'LAST'
@@ -8736,76 +8734,20 @@ yy.Select.prototype.compileGroup = function (query) {
8736
8734
  if ('funcid' in col.expression) {
8737
8735
  let colexpression = col.expression.args[0];
8738
8736
  let colexp1 = colexpression.toJS('p', tableid, defcols);
8739
- return (
8740
- "'" +
8741
- colas +
8742
- "': (typeof " +
8743
- colexp1 +
8744
- " == 'number' ? " +
8745
- colexp1 +
8746
- ': typeof ' +
8747
- colexp1 +
8748
- " == 'object' ? typeof Number(" +
8749
- colexp1 +
8750
- ") == 'number' && " +
8751
- colexp1 +
8752
- '!== null? ' +
8753
- colexp1 +
8754
- ' : null : null),'
8755
- );
8737
+ return `'${colas}': (typeof ${colexp1} == 'number' ? ${colexp1} : typeof ${colexp1} == 'object' ?
8738
+ typeof Number(${colexp1}) == 'number' && ${colexp1}!== null? ${colexp1} : null : null),`;
8756
8739
  }
8757
- return (
8758
- "'" +
8759
- colas +
8760
- "': (typeof " +
8761
- colexp +
8762
- " == 'number' ? " +
8763
- colexp +
8764
- ': typeof ' +
8765
- colexp +
8766
- " == 'object' ? typeof Number(" +
8767
- colexp +
8768
- ") == 'number' && " +
8769
- colexp +
8770
- '!== null? ' +
8771
- colexp +
8772
- ' : null : null),'
8773
- );
8740
+ return `'${colas}': (typeof ${colexp} == 'number' ? ${colexp} : typeof ${colexp} == 'object' ?
8741
+ typeof Number(${colexp}) == 'number' && ${colexp}!== null? ${colexp} : null : null),`;
8774
8742
  } else if (col.aggregatorid === 'MAX') {
8775
8743
  if ('funcid' in col.expression) {
8776
8744
  let colexpression = col.expression.args[0];
8777
8745
  let colexp1 = colexpression.toJS('p', tableid, defcols);
8778
- return (
8779
- "'" +
8780
- colas +
8781
- "': (typeof " +
8782
- colexp1 +
8783
- " == 'number' ? " +
8784
- colexp1 +
8785
- ': typeof ' +
8786
- colexp1 +
8787
- " == 'object' ? typeof Number(" +
8788
- colexp1 +
8789
- ") == 'number' ? " +
8790
- colexp1 +
8791
- ' : null : null),'
8792
- );
8746
+ return `'${colas}' : (typeof ${colexp1} == 'number' ? ${colexp1} : typeof ${colexp1} == 'object' ?
8747
+ typeof Number(${colexp1}) == 'number' ? ${colexp1} : null : null),`;
8793
8748
  }
8794
- return (
8795
- "'" +
8796
- colas +
8797
- "': (typeof " +
8798
- colexp +
8799
- " == 'number' ? " +
8800
- colexp +
8801
- ': typeof ' +
8802
- colexp +
8803
- " == 'object' ? typeof Number(" +
8804
- colexp +
8805
- ") == 'number' ? " +
8806
- colexp +
8807
- ' : null : null),'
8808
- );
8749
+ return `'${colas}' : (typeof ${colexp} == 'number' ? ${colexp} : typeof ${colexp} == 'object' ?
8750
+ typeof Number(${colexp}) == 'number' ? ${colexp} : null : null),`;
8809
8751
  } else if (col.aggregatorid === 'ARRAY') {
8810
8752
  return "'" + colas + "':[" + colexp + '],';
8811
8753
  } else if (col.aggregatorid === 'COUNT') {
@@ -8904,121 +8846,27 @@ yy.Select.prototype.compileGroup = function (query) {
8904
8846
  let colexp1 = colexpression.toJS('p', tableid, defcols);
8905
8847
  return (
8906
8848
  pre +
8907
- "if(g['" +
8908
- colas +
8909
- "'] == null && " +
8910
- colexp1 +
8911
- " == null){g['" +
8912
- colas +
8913
- "'] = null} else if(typeof g['" +
8914
- colas +
8915
- "']!== 'object' && typeof g['" +
8916
- colas +
8917
- "'] !== 'number' && typeof " +
8918
- colexp1 +
8919
- "!== 'object' && typeof " +
8920
- colexp1 +
8921
- "!== 'number'){g['" +
8922
- colas +
8923
- "'] = null} else if(typeof g['" +
8924
- colas +
8925
- "'] !== 'object' && typeof g['" +
8926
- colas +
8927
- "'] !== 'number' && typeof " +
8928
- colexp1 +
8929
- " == 'number'){g['" +
8930
- colas +
8931
- "'] = " +
8932
- colexp1 +
8933
- "} else if(typeof g['" +
8934
- colas +
8935
- "'] == 'number' && typeof " +
8936
- colexp1 +
8937
- " !== 'number' && typeof " +
8938
- colexp1 +
8939
- " !== 'object'){g['" +
8940
- colas +
8941
- "'] = g['" +
8942
- colas +
8943
- "']} else if((g['" +
8944
- colas +
8945
- "'] == null || (typeof g['" +
8946
- colas +
8947
- "'] !== 'number' && typeof g['" +
8948
- colas +
8949
- "'] !== 'object')) && (" +
8950
- colexp1 +
8951
- ' == null || (typeof ' +
8952
- colexp1 +
8953
- " !== 'number' && typeof " +
8954
- colexp1 +
8955
- " !== 'object'))){g['" +
8956
- colas +
8957
- "'] = null} else {g['" +
8958
- colas +
8959
- "']+=(" +
8960
- colexp1 +
8961
- '||0);}' +
8849
+ `if(g['${colas}'] == null && ${colexp1} == null){g['${colas}'] = null}
8850
+ else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp1}!== 'object' && typeof ${colexp1}!== 'number'){g['${colas}'] = null}
8851
+ else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp1} == 'number'){g['${colas}'] = ${colexp1}}
8852
+ else if(typeof g['${colas}']!== 'number' && typeof ${colexp1}!== 'number' && typeof ${colexp1}!== 'object'){g['${colas}'] = g['${colas}']}
8853
+ else if((g['${colas}'] == null || (typeof g['${colas}']!== 'number' && typeof g['${colas}']!== 'object')) && (${colexp1} == null || (typeof ${colexp1}!== 'number' && typeof ${colexp1}!== 'object'))){g['${colas}'] = null}
8854
+ else if(typeof g['${colas}'] == 'number' && typeof ${colexp1} ==null){g['${colas}'] = g['${colas}']}
8855
+ else if(typeof g['${colas}'] == null && typeof ${colexp1} =='number'){g['${colas}'] = ${colexp1}}
8856
+ else{g['${colas}'] += ${colexp1}||0}` +
8962
8857
  post
8963
8858
  );
8964
8859
  }
8965
8860
  return (
8966
8861
  pre +
8967
- "if(g['" +
8968
- colas +
8969
- "'] == null && " +
8970
- colexp +
8971
- " == null){g['" +
8972
- colas +
8973
- "'] = null} else if(typeof g['" +
8974
- colas +
8975
- "']!== 'object' && typeof g['" +
8976
- colas +
8977
- "'] !== 'number' && typeof " +
8978
- colexp +
8979
- "!== 'object' && typeof " +
8980
- colexp +
8981
- "!== 'number'){g['" +
8982
- colas +
8983
- "'] = null} else if(typeof g['" +
8984
- colas +
8985
- "'] !== 'object' && typeof g['" +
8986
- colas +
8987
- "'] !== 'number' && typeof " +
8988
- colexp +
8989
- " == 'number'){g['" +
8990
- colas +
8991
- "'] = " +
8992
- colexp +
8993
- "} else if(typeof g['" +
8994
- colas +
8995
- "'] == 'number' && typeof " +
8996
- colexp +
8997
- " !== 'number' && typeof " +
8998
- colexp +
8999
- " !== 'object'){g['" +
9000
- colas +
9001
- "'] = g['" +
9002
- colas +
9003
- "']} else if((g['" +
9004
- colas +
9005
- "'] == null || (typeof g['" +
9006
- colas +
9007
- "'] !== 'number' && typeof g['" +
9008
- colas +
9009
- "'] !== 'object')) && (" +
9010
- colexp +
9011
- ' == null || (typeof ' +
9012
- colexp +
9013
- " !== 'number' && typeof " +
9014
- colexp +
9015
- " !== 'object'))){g['" +
9016
- colas +
9017
- "'] = null} else {g['" +
9018
- colas +
9019
- "']+=(" +
9020
- colexp +
9021
- '||0);}' +
8862
+ `if(g['${colas}'] == null && ${colexp} == null){g['${colas}'] = null}
8863
+ else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number'&& typeof ${colexp}!== 'object' && typeof ${colexp}!== 'number'){g['${colas}'] = null}
8864
+ else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp} == 'number'){g['${colas}'] = ${colexp}}
8865
+ else if(typeof g['${colas}']!== 'number' && typeof ${colexp}!== 'number' && typeof ${colexp}!== 'object'){g['${colas}'] = g['${colas}']}
8866
+ else if((g['${colas}'] == null || (typeof g['${colas}']!== 'number' && typeof g['${colas}']!== 'object')) && (${colexp} == null || (typeof ${colexp}!== 'number' && typeof ${colexp}!== 'object'))){g['${colas}'] = null}
8867
+ else if(typeof g['${colas}'] == 'number' && typeof ${colexp} ==null){g['${colas}'] = g['${colas}']}
8868
+ else if(typeof g['${colas}'] == null && typeof ${colexp} =='number'){g['${colas}'] = ${colexp}}
8869
+ else{g['${colas}'] += ${colexp}||0}` +
9022
8870
  post
9023
8871
  );
9024
8872
  } else if (col.aggregatorid === 'COUNT') {
@@ -9046,89 +8894,23 @@ yy.Select.prototype.compileGroup = function (query) {
9046
8894
  let colexp1 = colexpression.toJS('p', tableid, defcols);
9047
8895
  return (
9048
8896
  pre +
9049
- "if((g['" +
9050
- colas +
9051
- "'] == null && " +
9052
- colexp1 +
9053
- '!== null) ? y = ' +
9054
- colexp1 +
9055
- " : (g['" +
9056
- colas +
9057
- "'] !== null && " +
9058
- colexp1 +
9059
- " == null) ? y = g['" +
9060
- colas +
9061
- "'] : ((y=" +
9062
- colexp1 +
9063
- ") < g['" +
9064
- colas +
9065
- "'])){ if((typeof y == 'number')) {g['" +
9066
- colas +
9067
- "'] = y;} else if(typeof y == 'object' && y instanceof Date){g['" +
9068
- colas +
9069
- "'] = y;}else if(typeof y == 'object' && typeof Number(y) == 'number'){g['" +
9070
- colas +
9071
- "'] = Number(y);}}else if(g['" +
9072
- colas +
9073
- "']!== null && typeof g['" +
9074
- colas +
9075
- "'] == 'object' && y instanceof Date){g['" +
9076
- colas +
9077
- "'] = g['" +
9078
- colas +
9079
- "']}else if(g['" +
9080
- colas +
9081
- "']!== null && typeof g['" +
9082
- colas +
9083
- "'] == 'object'){g['" +
9084
- colas +
9085
- "'] = Number(g['" +
9086
- colas +
9087
- "'])}" +
8897
+ `if((g['${colas}'] == null && ${colexp1}!== null) ? y = ${colexp1} : (g['${colas}']!== null &&
8898
+ ${colexp1} == null) ? y = g['${colas}']:((y=${colexp1}) < g['${colas}'])){ if(typeof y == 'number')
8899
+ {g['${colas}'] = y;}else if(typeof y == 'object' && y instanceof Date){g['${colas}'] = y;}
8900
+ else if(typeof y == 'object' && typeof Number(y) == 'number'){g['${colas}'] = Number(y);}}
8901
+ else if(g['${colas}']!== null && typeof g['${colas}'] == 'object' && y instanceof Date){g['${colas}'] = g['${colas}']}
8902
+ else if(g['${colas}']!== null && typeof g['${colas}'] == 'object'){g['${colas}'] = Number(g['${colas}'])}` +
9088
8903
  post
9089
8904
  );
9090
8905
  }
9091
8906
  return (
9092
8907
  pre +
9093
- "if((g['" +
9094
- colas +
9095
- "'] == null && " +
9096
- colexp +
9097
- '!== null) ? y = ' +
9098
- colexp +
9099
- " : (g['" +
9100
- colas +
9101
- "'] !== null && " +
9102
- colexp +
9103
- " == null) ? y = g['" +
9104
- colas +
9105
- "'] : ((y=" +
9106
- colexp +
9107
- ") < g['" +
9108
- colas +
9109
- "'])){ if((typeof y == 'number')) {g['" +
9110
- colas +
9111
- "'] = y;} else if(typeof y == 'object' && y instanceof Date){g['" +
9112
- colas +
9113
- "'] = y;}else if(typeof y == 'object' && typeof Number(y) == 'number'){g['" +
9114
- colas +
9115
- "'] = Number(y);}}else if(g['" +
9116
- colas +
9117
- "']!== null && typeof g['" +
9118
- colas +
9119
- "'] == 'object' && y instanceof Date){g['" +
9120
- colas +
9121
- "'] = g['" +
9122
- colas +
9123
- "']}else if(g['" +
9124
- colas +
9125
- "']!== null && typeof g['" +
9126
- colas +
9127
- "'] == 'object'){g['" +
9128
- colas +
9129
- "'] = Number(g['" +
9130
- colas +
9131
- "'])}" +
8908
+ `if((g['${colas}'] == null && ${colexp}!== null) ? y = ${colexp} : (g['${colas}']!== null &&
8909
+ ${colexp} == null) ? y = g['${colas}']:((y=${colexp}) < g['${colas}'])){ if(typeof y == 'number')
8910
+ {g['${colas}'] = y;}else if(typeof y == 'object' && y instanceof Date){g['${colas}'] = y;}
8911
+ else if(typeof y == 'object' && typeof Number(y) == 'number'){g['${colas}'] = Number(y);}}
8912
+ else if(g['${colas}']!== null && typeof g['${colas}'] == 'object' && y instanceof Date){g['${colas}'] = g['${colas}']}
8913
+ else if(g['${colas}']!== null && typeof g['${colas}'] == 'object'){g['${colas}'] = Number(g['${colas}'])}` +
9132
8914
  post
9133
8915
  );
9134
8916
  } else if (col.aggregatorid === 'MAX') {
@@ -9137,33 +8919,17 @@ yy.Select.prototype.compileGroup = function (query) {
9137
8919
  let colexp1 = colexpression.toJS('p', tableid, defcols);
9138
8920
  return (
9139
8921
  pre +
9140
- 'if ((y=' +
9141
- colexp1 +
9142
- ") > g['" +
9143
- colas +
9144
- "']){ if((typeof y == 'number')) {g['" +
9145
- colas +
9146
- "'] = y;} else if(typeof y == 'object' && y instanceof Date){g['" +
9147
- colas +
9148
- "'] = y;} else if(typeof y == 'object' && typeof Number(y) == 'number'){g['" +
9149
- colas +
9150
- "'] = Number(y);}}" +
8922
+ `if((y=${colexp1}) > g['${colas}']){if(typeof y == 'number'){g['${colas}'] = y;}
8923
+ else if(typeof y == 'object' && y instanceof Date){g['${colas}'] = y;}
8924
+ else if(typeof y == 'object' && typeof Number(y) == 'number'){g['${colas}'] = Number(y);}}` +
9151
8925
  post
9152
8926
  );
9153
8927
  }
9154
8928
  return (
9155
8929
  pre +
9156
- 'if ((y=' +
9157
- colexp +
9158
- ") > g['" +
9159
- colas +
9160
- "']){ if((typeof y == 'number')) {g['" +
9161
- colas +
9162
- "'] = y;} else if(typeof y == 'object' && y instanceof Date){g['" +
9163
- colas +
9164
- "'] = y;} else if(typeof y == 'object' && typeof Number(y) == 'number'){g['" +
9165
- colas +
9166
- "'] = Number(y);}}" +
8930
+ `if((y=${colexp}) > g['${colas}']){if(typeof y == 'number'){g['${colas}'] = y;}
8931
+ else if(typeof y == 'object' && y instanceof Date){g['${colas}'] = y;}
8932
+ else if(typeof y == 'object' && typeof Number(y) == 'number'){g['${colas}'] = Number(y);}}` +
9167
8933
  post
9168
8934
  );
9169
8935
  } else if (col.aggregatorid === 'FIRST') {
@@ -9235,6 +9001,7 @@ yy.Select.prototype.compileGroup = function (query) {
9235
9001
  // s += 'group.count++;';
9236
9002
  s += '}';
9237
9003
  });
9004
+
9238
9005
  return new Function('p,params,alasql', 'var y;' + s);
9239
9006
  };
9240
9007