alasql 2.1.4 → 2.1.6
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 +1 -1
- package/bin/alasql-cli.js +28 -0
- package/dist/alasql-worker.js +2 -2
- package/dist/alasql-worker.min.js +1 -1
- package/dist/alasql.fs.js +64 -99
- package/dist/alasql.js +64 -99
- package/dist/alasql.min.js +14 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
- _AlaSQL is an unfunded open source project installed 95k time each month. [Please donate your time](https://github.com/AlaSQL/alasql/issues?q=is%3Aopen+label%3A%22Help+wanted%22+
|
|
1
|
+
- _AlaSQL is an unfunded open source project installed 95k time each month. [Please donate your time](https://github.com/AlaSQL/alasql/issues?q=is%3Aopen+label%3A%22Help+wanted%22+sort%3Acreated-desc). We appreciate any and all contributions we can get._
|
|
2
2
|
|
|
3
3
|
- _Have a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask?tags=AlaSQL) using the "alasql" tag._
|
|
4
4
|
|
package/bin/alasql-cli.js
CHANGED
|
@@ -44,6 +44,14 @@ let yargs = require('yargs')
|
|
|
44
44
|
.nargs('f', 1)
|
|
45
45
|
.normalize('f')
|
|
46
46
|
|
|
47
|
+
.boolean('ast')
|
|
48
|
+
.describe('ast', 'Print AST instead of result')
|
|
49
|
+
.normalize('ast')
|
|
50
|
+
|
|
51
|
+
/*.boolean('comp')
|
|
52
|
+
.describe('comp', 'Print compiled function instead of result')
|
|
53
|
+
.normalize('comp')*/
|
|
54
|
+
|
|
47
55
|
.help('h')
|
|
48
56
|
.alias('h', 'help')
|
|
49
57
|
|
|
@@ -115,6 +123,26 @@ function execute(sql, params) {
|
|
|
115
123
|
}
|
|
116
124
|
}
|
|
117
125
|
|
|
126
|
+
if (argv.ast) {
|
|
127
|
+
try {
|
|
128
|
+
console.log(formatOutput(alasql.parse(sql, params)));
|
|
129
|
+
process.exit(0);
|
|
130
|
+
} catch (e) {
|
|
131
|
+
console.error(e);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/*if (argv.comp) {
|
|
137
|
+
try {
|
|
138
|
+
console.log(alasql.compile(sql, params));
|
|
139
|
+
process.exit(0);
|
|
140
|
+
} catch (e) {
|
|
141
|
+
console.error(e);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
}*/
|
|
145
|
+
|
|
118
146
|
alasql
|
|
119
147
|
.promise(sql, params)
|
|
120
148
|
.then(function (res) {
|
package/dist/alasql-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v2.1.
|
|
1
|
+
//! AlaSQL v2.1.5-develop-eec33e2f | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 2.1.
|
|
4
|
+
@version 2.1.5-develop-eec33e2f
|
|
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.
|
|
1
|
+
//! AlaSQL v2.1.5-develop-eec33e2f | © 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.
|
|
1
|
+
//! AlaSQL v2.1.5-develop-eec33e2f | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 2.1.
|
|
4
|
+
@version 2.1.5-develop-eec33e2f
|
|
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.
|
|
145
|
+
alasql.version = '2.1.5-develop-eec33e2f';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -4551,6 +4551,10 @@ alasql.options.excel = {cellDates: true};
|
|
|
4551
4551
|
|
|
4552
4552
|
alasql.options.joinstar = 'overwrite'; // Option for SELECT * FROM a,b
|
|
4553
4553
|
|
|
4554
|
+
alasql.options.loopbreak = 100000;
|
|
4555
|
+
|
|
4556
|
+
alasql.options;
|
|
4557
|
+
|
|
4554
4558
|
//alasql.options.worker = false;
|
|
4555
4559
|
|
|
4556
4560
|
// Variables
|
|
@@ -5697,7 +5701,7 @@ function doSearch(databaseid, params, cb) {
|
|
|
5697
5701
|
// throw new Error('Selector "'+sel.srchid+'" not found');
|
|
5698
5702
|
// };
|
|
5699
5703
|
|
|
5700
|
-
var
|
|
5704
|
+
var INFINITE_LOOP_BREAK = alasql.options.loopbreak || 100000;
|
|
5701
5705
|
|
|
5702
5706
|
if (sel.selid) {
|
|
5703
5707
|
// TODO Process Selector
|
|
@@ -5928,8 +5932,8 @@ function doSearch(databaseid, params, cb) {
|
|
|
5928
5932
|
}
|
|
5929
5933
|
// Security brake
|
|
5930
5934
|
i++;
|
|
5931
|
-
if (i >
|
|
5932
|
-
throw new Error('
|
|
5935
|
+
if (i > INFINITE_LOOP_BREAK) {
|
|
5936
|
+
throw new Error('Infinite loop brake. Number of iterations = ' + i);
|
|
5933
5937
|
}
|
|
5934
5938
|
}
|
|
5935
5939
|
}
|
|
@@ -6109,8 +6113,8 @@ function doSearch(databaseid, params, cb) {
|
|
|
6109
6113
|
|
|
6110
6114
|
// Security brake
|
|
6111
6115
|
i++;
|
|
6112
|
-
if (i >
|
|
6113
|
-
throw new Error('
|
|
6116
|
+
if (i > INFINITE_LOOP_BREAK) {
|
|
6117
|
+
throw new Error('Infinite loop brake. Number of iterations = ' + i);
|
|
6114
6118
|
}
|
|
6115
6119
|
}
|
|
6116
6120
|
return retval;
|
|
@@ -6144,8 +6148,8 @@ function doSearch(databaseid, params, cb) {
|
|
|
6144
6148
|
|
|
6145
6149
|
// Security brake
|
|
6146
6150
|
i++;
|
|
6147
|
-
if (i >
|
|
6148
|
-
throw new Error('
|
|
6151
|
+
if (i > INFINITE_LOOP_BREAK) {
|
|
6152
|
+
throw new Error('Infinite loop brake. Number of iterations = ' + i);
|
|
6149
6153
|
}
|
|
6150
6154
|
}
|
|
6151
6155
|
|
|
@@ -10504,8 +10508,8 @@ yy.Over.prototype.toString = function () {
|
|
|
10504
10508
|
*/
|
|
10505
10509
|
|
|
10506
10510
|
/**
|
|
10507
|
-
|
|
10508
|
-
|
|
10511
|
+
Expression statement ( = 2*2; )
|
|
10512
|
+
@class
|
|
10509
10513
|
@param {object} params Initial parameters
|
|
10510
10514
|
*/
|
|
10511
10515
|
yy.ExpressionStatement = function (params) {
|
|
@@ -10629,8 +10633,7 @@ yy.JavaScript.prototype.toString = function () {
|
|
|
10629
10633
|
return s;
|
|
10630
10634
|
};
|
|
10631
10635
|
|
|
10632
|
-
yy.JavaScript.prototype.toJS = function (
|
|
10633
|
-
|
|
10636
|
+
yy.JavaScript.prototype.toJS = function () {
|
|
10634
10637
|
return '(' + this.value + ')';
|
|
10635
10638
|
};
|
|
10636
10639
|
yy.JavaScript.prototype.execute = function (databaseid, params, cb) {
|
|
@@ -10679,8 +10682,6 @@ yy.Join.prototype.toString = function () {
|
|
|
10679
10682
|
return s;
|
|
10680
10683
|
};
|
|
10681
10684
|
|
|
10682
|
-
// }
|
|
10683
|
-
|
|
10684
10685
|
/**
|
|
10685
10686
|
Table class
|
|
10686
10687
|
@class
|
|
@@ -10758,6 +10759,7 @@ yy.Op.prototype.toString = function () {
|
|
|
10758
10759
|
|
|
10759
10760
|
return s;
|
|
10760
10761
|
}
|
|
10762
|
+
|
|
10761
10763
|
return (
|
|
10762
10764
|
this.left.toString() +
|
|
10763
10765
|
' ' +
|
|
@@ -10769,7 +10771,6 @@ yy.Op.prototype.toString = function () {
|
|
|
10769
10771
|
};
|
|
10770
10772
|
|
|
10771
10773
|
yy.Op.prototype.findAggregator = function (query) {
|
|
10772
|
-
|
|
10773
10774
|
if (this.left && this.left.findAggregator) {
|
|
10774
10775
|
this.left.findAggregator(query);
|
|
10775
10776
|
}
|
|
@@ -10901,17 +10902,28 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10901
10902
|
}
|
|
10902
10903
|
|
|
10903
10904
|
if (this.op === 'IS') {
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
|
|
10905
|
+
const leftOperand = leftJS();
|
|
10906
|
+
const rightOperand = rightJS();
|
|
10907
|
+
if (
|
|
10908
|
+
this.right instanceof yy.NullValue ||
|
|
10909
|
+
(this.right.op === 'NOT' && this.right.right instanceof yy.NullValue)
|
|
10910
|
+
) {
|
|
10911
|
+
s = `(
|
|
10912
|
+
(${leftOperand}==null) // Cant be ===
|
|
10913
|
+
===
|
|
10914
|
+
(${rightOperand}==null) // Cant be ===
|
|
10915
|
+
)`;
|
|
10916
|
+
} else {
|
|
10917
|
+
s = `(
|
|
10918
|
+
(${leftOperand} == ${rightOperand})
|
|
10919
|
+
||
|
|
10920
|
+
(
|
|
10921
|
+
${leftOperand} < 0
|
|
10922
|
+
&&
|
|
10923
|
+
true == ${rightOperand}
|
|
10924
|
+
)
|
|
10925
|
+
)`;
|
|
10926
|
+
}
|
|
10915
10927
|
}
|
|
10916
10928
|
|
|
10917
10929
|
if (this.op === '==') {
|
|
@@ -10974,7 +10986,6 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10974
10986
|
')' +
|
|
10975
10987
|
')' +
|
|
10976
10988
|
')';
|
|
10977
|
-
|
|
10978
10989
|
}
|
|
10979
10990
|
|
|
10980
10991
|
if (this.op === 'IN') {
|
|
@@ -11010,13 +11021,10 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11010
11021
|
if (this.op === 'NOT IN') {
|
|
11011
11022
|
if (this.right instanceof yy.Select) {
|
|
11012
11023
|
s = '(';
|
|
11013
|
-
//this.query.queriesdata['+this.queriesidx+']
|
|
11014
|
-
// s += 'alasql.utils.flatArray(this.query.queriesfn['+(this.queriesidx)+'](params,null,p))';
|
|
11015
11024
|
s += 'alasql.utils.flatArray(this.queriesfn[' + this.queriesidx + '](params,null,p))';
|
|
11016
11025
|
s += '.indexOf(';
|
|
11017
11026
|
s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
|
|
11018
11027
|
} else if (Array.isArray(this.right)) {
|
|
11019
|
-
// if(this.right.length == 0) return 'true';
|
|
11020
11028
|
s = '([' + this.right.map(ref).join(',') + '].indexOf(';
|
|
11021
11029
|
s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
|
|
11022
11030
|
} else {
|
|
@@ -11030,7 +11038,6 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11030
11038
|
if (this.allsome === 'ALL') {
|
|
11031
11039
|
var s;
|
|
11032
11040
|
if (this.right instanceof yy.Select) {
|
|
11033
|
-
// var s = 'this.query.queriesdata['+this.queriesidx+']';
|
|
11034
11041
|
s = 'alasql.utils.flatArray(this.query.queriesfn[' + this.queriesidx + '](params,null,p))';
|
|
11035
11042
|
|
|
11036
11043
|
s += '.every(function(b){return (';
|
|
@@ -11049,7 +11056,6 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11049
11056
|
if (this.allsome === 'SOME' || this.allsome === 'ANY') {
|
|
11050
11057
|
var s;
|
|
11051
11058
|
if (this.right instanceof yy.Select) {
|
|
11052
|
-
// var s = 'this.query.queriesdata['+this.queriesidx+']';
|
|
11053
11059
|
s = 'alasql.utils.flatArray(this.query.queriesfn[' + this.queriesidx + '](params,null,p))';
|
|
11054
11060
|
s += '.some(function(b){return (';
|
|
11055
11061
|
s += leftJS() + ')' + op + 'b})';
|
|
@@ -11088,12 +11094,9 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11088
11094
|
// // + ')';
|
|
11089
11095
|
// }
|
|
11090
11096
|
|
|
11091
|
-
// Change names
|
|
11092
|
-
|
|
11093
11097
|
var expr = s || '(' + leftJS() + op + rightJS() + ')';
|
|
11094
11098
|
|
|
11095
11099
|
var declareRefs = 'y=[(' + refs.join('), (') + ')]';
|
|
11096
|
-
|
|
11097
11100
|
if (op === '&&' || op === '||' || op === 'IS' || op === 'IS NULL' || op === 'IS NOT NULL') {
|
|
11098
11101
|
return '(' + declareRefs + ', ' + expr + ')';
|
|
11099
11102
|
}
|
|
@@ -11145,8 +11148,6 @@ yy.StringValue.prototype.toType = function () {
|
|
|
11145
11148
|
};
|
|
11146
11149
|
|
|
11147
11150
|
yy.StringValue.prototype.toJS = function () {
|
|
11148
|
-
|
|
11149
|
-
// return "'"+doubleqq(this.value)+"'";
|
|
11150
11151
|
return "'" + escapeq(this.value) + "'";
|
|
11151
11152
|
};
|
|
11152
11153
|
|
|
@@ -11179,8 +11180,6 @@ yy.ArrayValue.prototype.toType = function () {
|
|
|
11179
11180
|
};
|
|
11180
11181
|
|
|
11181
11182
|
yy.ArrayValue.prototype.toJS = function (context, tableid, defcols) {
|
|
11182
|
-
|
|
11183
|
-
// return "'"+doubleqq(this.value)+"'";
|
|
11184
11183
|
return (
|
|
11185
11184
|
'[(' +
|
|
11186
11185
|
this.value
|
|
@@ -11328,7 +11327,6 @@ yy.Column = function (params) {
|
|
|
11328
11327
|
yy.Column.prototype.toString = function () {
|
|
11329
11328
|
var s;
|
|
11330
11329
|
if (this.columnid == +this.columnid) {
|
|
11331
|
-
// jshint ignore:line
|
|
11332
11330
|
s = '[' + this.columnid + ']';
|
|
11333
11331
|
} else {
|
|
11334
11332
|
s = this.columnid;
|
|
@@ -11347,7 +11345,6 @@ yy.Column.prototype.toString = function () {
|
|
|
11347
11345
|
};
|
|
11348
11346
|
|
|
11349
11347
|
yy.Column.prototype.toJS = function (context, tableid, defcols) {
|
|
11350
|
-
|
|
11351
11348
|
var s = '';
|
|
11352
11349
|
if (!this.tableid && tableid === '' && !defcols) {
|
|
11353
11350
|
if (this.columnid !== '_') {
|
|
@@ -11361,17 +11358,10 @@ yy.Column.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11361
11358
|
}
|
|
11362
11359
|
} else {
|
|
11363
11360
|
if (context === 'g') {
|
|
11364
|
-
// if(this.columnid == '_') {
|
|
11365
|
-
// } else {
|
|
11366
11361
|
s = "g['" + this.nick + "']";
|
|
11367
|
-
// }
|
|
11368
11362
|
} else if (this.tableid) {
|
|
11369
11363
|
if (this.columnid !== '_') {
|
|
11370
|
-
// if() {
|
|
11371
|
-
// s = context+'[\''+tableid + '\'][\''+this.tableid+'\'][\''+this.columnid+'\']';
|
|
11372
|
-
// } else {
|
|
11373
11364
|
s = context + "['" + this.tableid + "']['" + this.columnid + "']";
|
|
11374
|
-
// }
|
|
11375
11365
|
} else {
|
|
11376
11366
|
if (context === 'g') {
|
|
11377
11367
|
s = "g['_']";
|
|
@@ -11394,22 +11384,13 @@ yy.Column.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11394
11384
|
|
|
11395
11385
|
} else {
|
|
11396
11386
|
if (this.columnid !== '_') {
|
|
11397
|
-
// if(defcols['.'][this.tableid]) {
|
|
11398
|
-
|
|
11399
|
-
// s = context+'[\''+tableid + '\'][\''+this.tableid + '\'][\''+this.columnid+'\']';
|
|
11400
|
-
// } else {
|
|
11401
11387
|
s = context + "['" + (this.tableid || tableid) + "']['" + this.columnid + "']";
|
|
11402
|
-
// }
|
|
11403
11388
|
} else {
|
|
11404
11389
|
s = context + "['" + (this.tableid || tableid) + "']";
|
|
11405
11390
|
}
|
|
11406
11391
|
}
|
|
11407
11392
|
} else if (tableid === -1) {
|
|
11408
|
-
// if(this.columnid != '') {
|
|
11409
11393
|
s = context + "['" + this.columnid + "']";
|
|
11410
|
-
// } else {
|
|
11411
|
-
// s = context;
|
|
11412
|
-
// }
|
|
11413
11394
|
} else {
|
|
11414
11395
|
if (this.columnid !== '_') {
|
|
11415
11396
|
s = context + "['" + (this.tableid || tableid) + "']['" + this.columnid + "']";
|
|
@@ -11418,9 +11399,6 @@ yy.Column.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11418
11399
|
}
|
|
11419
11400
|
}
|
|
11420
11401
|
}
|
|
11421
|
-
|
|
11422
|
-
// console.trace(new Error());
|
|
11423
|
-
|
|
11424
11402
|
return s;
|
|
11425
11403
|
};
|
|
11426
11404
|
|
|
@@ -11452,16 +11430,8 @@ yy.AggrValue.prototype.toString = function () {
|
|
|
11452
11430
|
};
|
|
11453
11431
|
|
|
11454
11432
|
yy.AggrValue.prototype.findAggregator = function (query) {
|
|
11455
|
-
|
|
11456
|
-
// var colas = this.as || this.toString();
|
|
11457
|
-
|
|
11458
11433
|
var colas = escapeq(this.toString()) + ':' + query.selectGroup.length;
|
|
11459
|
-
|
|
11460
|
-
// if(!query.selectColumns[colas]) {
|
|
11461
|
-
// }
|
|
11462
|
-
|
|
11463
11434
|
var found = false;
|
|
11464
|
-
|
|
11465
11435
|
if (!found) {
|
|
11466
11436
|
if (!this.nick) {
|
|
11467
11437
|
this.nick = colas;
|
|
@@ -11478,8 +11448,6 @@ yy.AggrValue.prototype.findAggregator = function (query) {
|
|
|
11478
11448
|
}
|
|
11479
11449
|
query.selectGroup.push(this);
|
|
11480
11450
|
}
|
|
11481
|
-
|
|
11482
|
-
// this.reduced = true;
|
|
11483
11451
|
return;
|
|
11484
11452
|
};
|
|
11485
11453
|
|
|
@@ -11498,11 +11466,10 @@ yy.AggrValue.prototype.toType = function () {
|
|
|
11498
11466
|
return this.expression.toType();
|
|
11499
11467
|
}
|
|
11500
11468
|
|
|
11501
|
-
|
|
11469
|
+
return this.expression.toType();
|
|
11502
11470
|
};
|
|
11503
11471
|
|
|
11504
|
-
yy.AggrValue.prototype.toJS = function (
|
|
11505
|
-
|
|
11472
|
+
yy.AggrValue.prototype.toJS = function () {
|
|
11506
11473
|
var colas = this.nick;
|
|
11507
11474
|
if (colas === undefined) {
|
|
11508
11475
|
colas = this.toString();
|
|
@@ -11513,6 +11480,7 @@ yy.AggrValue.prototype.toJS = function (/*context, tableid, defcols*/) {
|
|
|
11513
11480
|
yy.OrderExpression = function (params) {
|
|
11514
11481
|
return yy.extend(this, params);
|
|
11515
11482
|
};
|
|
11483
|
+
|
|
11516
11484
|
yy.OrderExpression.prototype.toString = yy.Expression.prototype.toString;
|
|
11517
11485
|
|
|
11518
11486
|
yy.GroupExpression = function (params) {
|
|
@@ -11949,42 +11917,39 @@ alasql.aggr.GROUP_CONCAT = function (v, s, stage) {
|
|
|
11949
11917
|
return s;
|
|
11950
11918
|
};
|
|
11951
11919
|
|
|
11952
|
-
alasql.aggr.MEDIAN = function (v, s, stage) {
|
|
11920
|
+
alasql.aggr.median = alasql.aggr.MEDIAN = function (v, s, stage) {
|
|
11953
11921
|
if (stage === 2) {
|
|
11954
11922
|
if (v !== null) {
|
|
11955
11923
|
s.push(v);
|
|
11956
11924
|
}
|
|
11957
11925
|
return s;
|
|
11958
|
-
}
|
|
11926
|
+
}
|
|
11927
|
+
|
|
11928
|
+
if (stage === 1) {
|
|
11959
11929
|
if (v === null) {
|
|
11960
11930
|
return [];
|
|
11961
11931
|
}
|
|
11962
11932
|
return [v];
|
|
11963
|
-
}
|
|
11964
|
-
if (!s.length) {
|
|
11965
|
-
return s;
|
|
11966
|
-
}
|
|
11933
|
+
}
|
|
11967
11934
|
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
}
|
|
11972
|
-
if (a > b) {
|
|
11973
|
-
return 1;
|
|
11974
|
-
}
|
|
11975
|
-
return -1;
|
|
11976
|
-
});
|
|
11977
|
-
var p = (r.length + 1) / 2;
|
|
11978
|
-
if (Number.isInteger(p)) {
|
|
11979
|
-
return r[p - 1];
|
|
11980
|
-
}
|
|
11935
|
+
if (!s.length) {
|
|
11936
|
+
return null;
|
|
11937
|
+
}
|
|
11981
11938
|
|
|
11982
|
-
|
|
11983
|
-
if (
|
|
11984
|
-
|
|
11985
|
-
|
|
11939
|
+
var r = s.sort((a, b) => {
|
|
11940
|
+
if (a > b) return 1;
|
|
11941
|
+
if (a < b) return -1;
|
|
11942
|
+
return 0;
|
|
11943
|
+
});
|
|
11986
11944
|
|
|
11987
|
-
|
|
11945
|
+
var middle = (r.length + 1) / 2;
|
|
11946
|
+
var middleFloor = middle | 0;
|
|
11947
|
+
var el = r[middleFloor - 1];
|
|
11948
|
+
|
|
11949
|
+
if (middle === middleFloor || (typeof el !== 'number' && !(el instanceof Number))) {
|
|
11950
|
+
return el;
|
|
11951
|
+
} else {
|
|
11952
|
+
return (el + r[middleFloor]) / 2;
|
|
11988
11953
|
}
|
|
11989
11954
|
};
|
|
11990
11955
|
|