alasql 2.2.0 → 2.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.
@@ -1,7 +1,7 @@
1
- //! AlaSQL v2.1.8-develop-7e87d661 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.2.0-develop-6cec528a | © 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.0-develop-6cec528a
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.0-develop-6cec528a | © 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.0-develop-6cec528a | © 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.0-develop-6cec528a
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.0-develop-6cec528a';
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
  }
@@ -8719,93 +8717,16 @@ yy.Select.prototype.compileGroup = function (query) {
8719
8717
  ",g['$$_VALUES_" + colas + "']={},g['$$_VALUES_" + colas + "'][" + colexp + ']=true';
8720
8718
  }
8721
8719
  if (col.aggregatorid === 'SUM') {
8722
- if ('funcid' in col.expression) {
8723
- let colexpression = col.expression.args[0];
8724
- let colexp1 = colexpression.toJS('p', tableid, defcols);
8725
- return "'" + colas + "':(" + colexp1 + ')||null,';
8726
- }
8727
- return "'" + colas + "':(" + colexp + ')||null,';
8720
+ return "'" + colas + "':(" + colexp + ')||0,';
8728
8721
  } else if (
8722
+ col.aggregatorid === 'MIN' ||
8723
+ col.aggregatorid === 'MAX' ||
8729
8724
  col.aggregatorid === 'FIRST' ||
8730
8725
  col.aggregatorid === 'LAST'
8731
8726
  // || col.aggregatorid == 'AVG'
8732
8727
  // ) { return "'"+col.as+'\':r[\''+col.as+'\'],'; }//f.field.arguments[0].toJS();
8733
8728
  ) {
8734
8729
  return "'" + colas + "':" + colexp + ','; //f.field.arguments[0].toJS();
8735
- } else if (col.aggregatorid === 'MIN') {
8736
- if ('funcid' in col.expression) {
8737
- let colexpression = col.expression.args[0];
8738
- 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
- );
8756
- }
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
- );
8774
- } else if (col.aggregatorid === 'MAX') {
8775
- if ('funcid' in col.expression) {
8776
- let colexpression = col.expression.args[0];
8777
- 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
- );
8793
- }
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
- );
8809
8730
  } else if (col.aggregatorid === 'ARRAY') {
8810
8731
  return "'" + colas + "':[" + colexp + '],';
8811
8732
  } else if (col.aggregatorid === 'COUNT') {
@@ -8899,128 +8820,7 @@ yy.Select.prototype.compileGroup = function (query) {
8899
8820
  var post = "g['$$_VALUES_" + colas + "'][" + colexp + ']=true;}';
8900
8821
  }
8901
8822
  if (col.aggregatorid === 'SUM') {
8902
- if ('funcid' in col.expression) {
8903
- let colexpression = col.expression.args[0];
8904
- let colexp1 = colexpression.toJS('p', tableid, defcols);
8905
- return (
8906
- 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);}' +
8962
- post
8963
- );
8964
- }
8965
- return (
8966
- 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);}' +
9022
- post
9023
- );
8823
+ return pre + "g['" + colas + "']+=(" + colexp + '||0);' + post; //f.field.arguments[0].toJS();
9024
8824
  } else if (col.aggregatorid === 'COUNT') {
9025
8825
 
9026
8826
  if (col.expression.columnid === '*') {
@@ -9041,130 +8841,12 @@ yy.Select.prototype.compileGroup = function (query) {
9041
8841
  } else if (col.aggregatorid === 'ARRAY') {
9042
8842
  return pre + "g['" + colas + "'].push(" + colexp + ');' + post;
9043
8843
  } else if (col.aggregatorid === 'MIN') {
9044
- if ('funcid' in col.expression) {
9045
- let colexpression = col.expression.args[0];
9046
- let colexp1 = colexpression.toJS('p', tableid, defcols);
9047
- return (
9048
- 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
- "'])}" +
9088
- post
9089
- );
9090
- }
9091
8844
  return (
9092
- 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
- "'])}" +
9132
- post
8845
+ pre + 'if ((y=' + colexp + ") < g['" + colas + "']) g['" + colas + "'] = y;" + post
9133
8846
  );
9134
8847
  } else if (col.aggregatorid === 'MAX') {
9135
- if ('funcid' in col.expression) {
9136
- let colexpression = col.expression.args[0];
9137
- let colexp1 = colexpression.toJS('p', tableid, defcols);
9138
- return (
9139
- 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);}}" +
9151
- post
9152
- );
9153
- }
9154
8848
  return (
9155
- 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);}}" +
9167
- post
8849
+ pre + 'if ((y=' + colexp + ") > g['" + colas + "']) g['" + colas + "'] = y;" + post
9168
8850
  );
9169
8851
  } else if (col.aggregatorid === 'FIRST') {
9170
8852
  return '';
@@ -9235,6 +8917,7 @@ yy.Select.prototype.compileGroup = function (query) {
9235
8917
  // s += 'group.count++;';
9236
8918
  s += '}';
9237
8919
  });
8920
+
9238
8921
  return new Function('p,params,alasql', 'var y;' + s);
9239
8922
  };
9240
8923