alasql 2.2.4 → 2.3.0

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/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v2.2.3-develop-21117291 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.2.5-develop-63c84c04 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.2.3-develop-21117291
4
+ @version 2.2.5-develop-63c84c04
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -63,7 +63,7 @@ SOFTWARE.
63
63
  /**
64
64
  AlaSQL - Main Alasql class
65
65
  @function
66
- @param {string|function|object} sql - SQL-statement or data object for fuent interface
66
+ @param {string|function|object} sql - SQL-statement or data object for fluent interface
67
67
  @param {object} params - SQL parameters
68
68
  @param {function} cb - callback function
69
69
  @param {object} scope - Scope for nested queries
@@ -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.2.3-develop-21117291';
145
+ alasql.version = '2.2.5-develop-63c84c04';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -151,7 +151,7 @@ alasql.version = '2.2.3-develop-21117291';
151
151
  alasql.debug = undefined; // Initial debug variable
152
152
 
153
153
  //*only-for-browser/*
154
- var require = function(){return null}; // as alasqlparser.js is generated, we can not "remove" referenses to
154
+ var require = function(){return null}; // as alasqlparser.js is generated, we can not "remove" references to
155
155
  var __dirname = '';
156
156
  //*/
157
157
 
@@ -3484,19 +3484,7 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
3484
3484
  });
3485
3485
  } else {
3486
3486
  if (/^[a-z]+:\/\//i.test(path)) {
3487
- var fetch = require('node-fetch');
3488
- fetch(path)
3489
- .then((response) => response.arrayBuffer())
3490
- .then((buf) => {
3491
- var a = new Uint8Array(buf);
3492
- var b = [...a].map((e) => String.fromCharCode(e)).join('');
3493
- success(cutbom(b));
3494
- })
3495
- .catch((e) => {
3496
- if (error) return error(e);
3497
- console.error(e);
3498
- throw e;
3499
- });
3487
+ fetchData(path, (x) => success(cutbom(x)), error, asy);
3500
3488
  } else {
3501
3489
  //If async callthen call async
3502
3490
  if (asy) {
@@ -3559,21 +3547,7 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
3559
3547
  Simply read file from HTTP request, like:
3560
3548
  SELECT * FROM TXT('http://alasql.org/README.md');
3561
3549
  */
3562
- var xhr = new XMLHttpRequest();
3563
- xhr.onreadystatechange = function () {
3564
- if (xhr.readyState === 4) {
3565
- if (xhr.status === 200) {
3566
- if (success) {
3567
- success(cutbom(xhr.responseText));
3568
- }
3569
- } else if (error) {
3570
- return error(xhr);
3571
- }
3572
- // Todo: else...?
3573
- }
3574
- };
3575
- xhr.open('GET', path, asy); // Async
3576
- xhr.send();
3550
+ fetchData(path, (x) => success(cutbom(x)), error, asy);
3577
3551
  }
3578
3552
  } else if (path instanceof Event) {
3579
3553
  /*
@@ -3600,6 +3574,33 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
3600
3574
  }
3601
3575
  });
3602
3576
 
3577
+ let _fetch = typeof fetch !== 'undefined' ? fetch : null;
3578
+ /*not-for-browser/*
3579
+ _fetch = typeof fetch !== 'undefined' ? fetch : require('cross-fetch');
3580
+ //*/
3581
+
3582
+ async function fetchData(path, success, error, async) {
3583
+ if (async) {
3584
+ return getData(path, success, error);
3585
+ }
3586
+ return await getData(path, success, error);
3587
+ }
3588
+
3589
+ function getData(path, success, error) {
3590
+ return _fetch(path)
3591
+ .then((response) => response.arrayBuffer())
3592
+ .then((buf) => {
3593
+ var a = new Uint8Array(buf);
3594
+ var b = [...a].map((e) => String.fromCharCode(e)).join('');
3595
+ success(b);
3596
+ })
3597
+ .catch((e) => {
3598
+ if (error) return error(e);
3599
+ console.error(e);
3600
+ throw e;
3601
+ });
3602
+ }
3603
+
3603
3604
  /**
3604
3605
  @function Load binary file from anywhere
3605
3606
  @param {string} path File path
@@ -3625,19 +3626,7 @@ var loadBinaryFile = (utils.loadBinaryFile = function (
3625
3626
  fs = require('fs');
3626
3627
 
3627
3628
  if (/^[a-z]+:\/\//i.test(path)) {
3628
- var fetch = require('node-fetch');
3629
- fetch(path)
3630
- .then((response) => response.arrayBuffer())
3631
- .then((buf) => {
3632
- var a = new Uint8Array(buf);
3633
- var b = [...a].map((e) => String.fromCharCode(e)).join('');
3634
- success(b);
3635
- })
3636
- .catch((e) => {
3637
- if (error) return error(e);
3638
- console.error(e);
3639
- throw e;
3640
- });
3629
+ fetchData(path, success, error, runAsync);
3641
3630
  } else {
3642
3631
  if (runAsync) {
3643
3632
  fs.readFile(path, function (err, data) {
@@ -3870,30 +3859,14 @@ var saveFile = (utils.saveFile = function (path, data, cb, opts) {
3870
3859
  // });
3871
3860
  // });
3872
3861
  } else {
3873
- if (isIE() === 9) {
3874
- // Solution was taken from
3875
- // http://megatuto.com/formation-JAVASCRIPT.php?JAVASCRIPT_Example=Javascript+Save+CSV+file+in+IE+8/IE+9+without+using+window.open()+Categorie+javascript+internet-explorer-8&category=&article=7993
3876
- // var URI = 'data:text/plain;charset=utf-8,';
3877
-
3878
- // Prepare data
3879
- var ndata = data.replace(/\r\n/g, '&#A;&#D;');
3880
- ndata = ndata.replace(/\n/g, '&#D;');
3881
- ndata = ndata.replace(/\t/g, '	');
3882
- var testlink = utils.global.open('about:blank', '_blank');
3883
- testlink.document.write(ndata); //fileData has contents for the file
3884
- testlink.document.close();
3885
- testlink.document.execCommand('SaveAs', false, path);
3886
- testlink.close();
3887
- } else {
3888
- var opt = {
3889
- disableAutoBom: false,
3890
- };
3891
- alasql.utils.extend(opt, opts);
3892
- var blob = new Blob([data], {type: 'text/plain;charset=utf-8'});
3893
- saveAs(blob, path, opt.disableAutoBom);
3894
- if (cb) {
3895
- res = cb(res);
3896
- }
3862
+ var opt = {
3863
+ disableAutoBom: false,
3864
+ };
3865
+ alasql.utils.extend(opt, opts);
3866
+ var blob = new Blob([data], {type: 'text/plain;charset=utf-8'});
3867
+ saveAs(blob, path, opt.disableAutoBom);
3868
+ if (cb) {
3869
+ res = cb(res);
3897
3870
  }
3898
3871
  }
3899
3872
  }
@@ -3901,17 +3874,6 @@ var saveFile = (utils.saveFile = function (path, data, cb, opts) {
3901
3874
  return res;
3902
3875
  });
3903
3876
 
3904
- /**
3905
- @function Is this IE9
3906
- @return {boolean} True for IE9 and false for other browsers
3907
-
3908
- For IE9 compatibility issues
3909
- */
3910
- function isIE() {
3911
- var myNav = navigator.userAgent.toLowerCase();
3912
- return myNav.indexOf('msie') !== -1 ? parseInt(myNav.split('msie')[1]) : false;
3913
- }
3914
-
3915
3877
  /**
3916
3878
  @function Hash a string to signed integer
3917
3879
  @param {string} source string
@@ -4054,7 +4016,7 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
4054
4016
  return +obj;
4055
4017
  }
4056
4018
 
4057
- var temp = obj.constructor(); // changed
4019
+ var temp = new obj.constructor(); // changed
4058
4020
 
4059
4021
  for (var key in obj) {
4060
4022
  if (obj.hasOwnProperty(key)) {
@@ -6551,7 +6513,7 @@ function queryfn3(query) {
6551
6513
 
6552
6514
  doJoin(query, scope, h);
6553
6515
 
6554
- // If groupping, then filter groups with HAVING function
6516
+ // If grouping, then filter groups with HAVING function
6555
6517
 
6556
6518
  if (query.groupfn) {
6557
6519
  query.data = [];
@@ -7036,7 +6998,7 @@ function doJoin(query, scope, h) {
7036
6998
 
7037
6999
  // var res = query.selectfn(scope, query.params, alasql);
7038
7000
 
7039
- // If there is a GROUP BY then pipe to groupping function
7001
+ // If there is a GROUP BY then pipe to grouping function
7040
7002
  if (query.groupfn) {
7041
7003
  query.groupfn(scope, query.params, alasql);
7042
7004
  } else {
@@ -8619,7 +8581,7 @@ yy.Select.prototype.compileGroup = function (query) {
8619
8581
  var coljs = col2.split('\t')[1];
8620
8582
  // Check, if aggregator exists but GROUP BY is not exists
8621
8583
  if (columnid === '') {
8622
- return '1'; // Create fictive groupping column for fictive GROUP BY
8584
+ return '1'; // Create fictive grouping column for fictive GROUP BY
8623
8585
  }
8624
8586
  // else return "r['"+columnid+"']";
8625
8587
  query.ingroup.push(columnid);
@@ -9538,6 +9500,11 @@ yy.Select.prototype.compileOrder = function (query, params) {
9538
9500
  this.order.forEach(function (ord, idx) {
9539
9501
 
9540
9502
  if (ord.expression instanceof yy.NumValue) {
9503
+ if (ord.expression.value > self.columns.length) {
9504
+ throw new Error(
9505
+ `You are trying to order by column number ${ord.expression.value} but you have only selected ${self.columns.length} columns.`
9506
+ );
9507
+ }
9541
9508
  var v = self.columns[ord.expression.value - 1];
9542
9509
  } else {
9543
9510
  var v = ord.expression;
@@ -10157,416 +10124,402 @@ yy.Over.prototype.toString = function () {
10157
10124
  //
10158
10125
  */
10159
10126
 
10160
- var assign = Object.assign;
10127
+ {
10128
+ const assign = Object.assign;
10161
10129
 
10162
- /**
10163
- Expression statement ( = 2*2; )
10164
- @class
10165
- @param {object} params Initial parameters
10166
- */
10167
- yy.ExpressionStatement = function (params) {
10168
- return assign(this, params);
10169
- };
10130
+ class ExpressionStatement {
10131
+ /** @param {object} params Initial parameters */
10132
+ constructor(params) {
10133
+ assign(this, params);
10134
+ }
10170
10135
 
10171
- /**
10172
- Convert AST to string
10173
- @this ExpressionStatement
10174
- @return {string}
10175
- */
10176
- yy.ExpressionStatement.prototype.toString = function () {
10177
- return this.expression.toString();
10178
- };
10179
- /**
10180
- Execute statement
10181
- @param {string} databaseid Database identificatro
10182
- @param {object} params Statement parameters
10183
- @param {statement-callback} cb Callback
10184
- @return {object} Result value
10185
- */
10186
- yy.ExpressionStatement.prototype.execute = function (databaseid, params, cb) {
10187
- if (this.expression) {
10136
+ /**
10137
+ Convert AST to string
10138
+ @return {string}
10139
+ */
10140
+ toString() {
10141
+ return this.expression.toString();
10142
+ }
10188
10143
 
10189
- alasql.precompile(this, databaseid, params); // Precompile queries
10190
- var exprfn = new Function(
10191
- 'params,alasql,p',
10192
- 'var y;return ' + this.expression.toJS('({})', '', null)
10193
- ).bind(this);
10194
- var res = exprfn(params, alasql);
10195
- if (cb) {
10196
- res = cb(res);
10144
+ /**
10145
+ Execute statement
10146
+ @param {string} databaseid Database identificatro
10147
+ @param {object} params Statement parameters
10148
+ @param {statement-callback} cb Callback
10149
+ @return {object} Result value
10150
+ */
10151
+ execute(databaseid, params, cb) {
10152
+ if (this.expression) {
10153
+
10154
+ alasql.precompile(this, databaseid, params); // Precompile queries
10155
+ var exprfn = new Function(
10156
+ 'params,alasql,p',
10157
+ 'var y;return ' + this.expression.toJS('({})', '', null)
10158
+ ).bind(this);
10159
+ var res = exprfn(params, alasql);
10160
+ if (cb) {
10161
+ res = cb(res);
10162
+ }
10163
+ return res;
10164
+ }
10197
10165
  }
10198
- return res;
10199
10166
  }
10200
- };
10201
10167
 
10202
- /**
10203
- Expression class
10204
- @class
10205
- @param {object} params Initial parameters
10206
- */
10168
+ class Expression {
10169
+ constructor(params) {
10170
+ assign(this, params);
10171
+ }
10207
10172
 
10208
- yy.Expression = function (params) {
10209
- return assign(this, params);
10210
- };
10173
+ /**
10174
+ Convert AST to string
10175
+ @return {string}
10176
+ */
10177
+ toString() {
10178
+ var s = this.expression.toString();
10179
+ if (this.order) {
10180
+ s += ' ' + this.order.toString();
10181
+ }
10182
+ if (this.nocase) {
10183
+ s += ' COLLATE NOCASE';
10184
+ }
10185
+ if (this.direction) {
10186
+ s += ' ' + this.direction;
10187
+ }
10188
+ return s;
10189
+ }
10211
10190
 
10212
- /**
10213
- Convert AST to string
10214
- @this ExpressionStatement
10215
- @return {string}
10216
- */
10217
- yy.Expression.prototype.toString = function () {
10218
- var s = this.expression.toString();
10219
- if (this.order) {
10220
- s += ' ' + this.order.toString();
10221
- }
10222
- if (this.nocase) {
10223
- s += ' COLLATE NOCASE';
10224
- }
10225
- if (this.direction) {
10226
- s += ' ' + this.direction;
10227
- }
10228
- return s;
10229
- };
10191
+ /**
10192
+ Find aggregator in AST subtree
10193
+ @param {object} query Query object
10194
+ */
10195
+ findAggregator(query) {
10196
+ if (this.expression.findAggregator) {
10197
+ this.expression.findAggregator(query);
10198
+ }
10199
+ }
10230
10200
 
10231
- /**
10232
- Find aggregator in AST subtree
10233
- @this ExpressionStatement
10234
- @param {object} query Query object
10235
- */
10236
- yy.Expression.prototype.findAggregator = function (query) {
10237
- if (this.expression.findAggregator) {
10238
- this.expression.findAggregator(query);
10239
- }
10240
- };
10201
+ /**
10202
+ Convert AST to JavaScript expression
10203
+ @param {string} context Context string, e.g. 'p','g', or 'x'
10204
+ @param {string} tableid Default table name
10205
+ @param {object} defcols Default columns dictionary
10206
+ @return {string} JavaScript expression
10207
+ */
10208
+ toJS(context, tableid, defcols) {
10241
10209
 
10242
- /**
10243
- Convert AST to JavaScript expression
10244
- @this ExpressionStatement
10245
- @param {string} context Context string, e.g. 'p','g', or 'x'
10246
- @param {string} tableid Default table name
10247
- @param {object} defcols Default columns dictionary
10248
- @return {string} JavaScript expression
10249
- */
10210
+ if (this.expression.reduced) {
10211
+ return 'true';
10212
+ }
10213
+ return this.expression.toJS(context, tableid, defcols);
10214
+ }
10250
10215
 
10251
- yy.Expression.prototype.toJS = function (context, tableid, defcols) {
10216
+ /**
10217
+ Compile AST to JavaScript expression
10218
+ @param {string} context Context string, e.g. 'p','g', or 'x'
10219
+ @param {string} tableid Default table name
10220
+ @param {object} defcols Default columns dictionary
10221
+ @return {string} JavaScript expression
10222
+ */
10223
+ compile(context, tableid, defcols) {
10252
10224
 
10253
- if (this.expression.reduced) {
10254
- return 'true';
10225
+ if (this.reduced) {
10226
+ return returnTrue();
10227
+ }
10228
+ return new Function('p', 'var y;return ' + this.toJS(context, tableid, defcols));
10229
+ }
10255
10230
  }
10256
- return this.expression.toJS(context, tableid, defcols);
10257
- };
10258
-
10259
- /**
10260
- Compile AST to JavaScript expression
10261
- @this ExpressionStatement
10262
- @param {string} context Context string, e.g. 'p','g', or 'x'
10263
- @param {string} tableid Default table name
10264
- @param {object} defcols Default columns dictionary
10265
- @return {string} JavaScript expression
10266
- */
10267
10231
 
10268
- yy.Expression.prototype.compile = function (context, tableid, defcols) {
10232
+ class JavaScript {
10233
+ constructor(params) {
10234
+ assign(this, params);
10235
+ }
10269
10236
 
10270
- if (this.reduced) {
10271
- return returnTrue();
10272
- }
10273
- return new Function('p', 'var y;return ' + this.toJS(context, tableid, defcols));
10274
- };
10237
+ toString() {
10238
+ var s = '``' + this.value + '``';
10239
+ return s;
10240
+ }
10275
10241
 
10276
- /**
10277
- JavaScript class
10278
- @class
10279
- */
10280
- yy.JavaScript = function (params) {
10281
- return assign(this, params);
10282
- };
10283
- yy.JavaScript.prototype.toString = function () {
10284
- var s = '``' + this.value + '``';
10285
- return s;
10286
- };
10242
+ toJS() {
10243
+ return '(' + this.value + ')';
10244
+ }
10287
10245
 
10288
- yy.JavaScript.prototype.toJS = function () {
10289
- return '(' + this.value + ')';
10290
- };
10291
- yy.JavaScript.prototype.execute = function (databaseid, params, cb) {
10292
- var res = 1;
10293
- var expr = new Function('params,alasql,p', this.value);
10294
- expr(params, alasql);
10295
- if (cb) {
10296
- res = cb(res);
10246
+ execute(databaseid, params, cb) {
10247
+ var res = 1;
10248
+ var expr = new Function('params,alasql,p', this.value);
10249
+ expr(params, alasql);
10250
+ if (cb) {
10251
+ res = cb(res);
10252
+ }
10253
+ return res;
10254
+ }
10297
10255
  }
10298
- return res;
10299
- };
10300
10256
 
10301
- /**
10302
- Literal class
10303
- @class
10304
- @example
10305
- MyVar, [My vairable], `MySQL variable`
10306
- */
10257
+ class Literal {
10258
+ constructor(params) {
10259
+ assign(this, params);
10260
+ }
10307
10261
 
10308
- yy.Literal = function (params) {
10309
- return assign(this, params);
10310
- };
10311
- yy.Literal.prototype.toString = function () {
10312
- var s = this.value;
10313
- if (this.value1) {
10314
- s = this.value1 + '.' + s;
10262
+ toString() {
10263
+ var s = this.value;
10264
+ if (this.value1) {
10265
+ s = this.value1 + '.' + s;
10266
+ }
10267
+ // else s = tableid+'.'+s;
10268
+ return s;
10269
+ }
10315
10270
  }
10316
- // else s = tableid+'.'+s;
10317
- return s;
10318
- };
10319
10271
 
10320
- /**
10321
- Join class
10322
- @class
10323
- */
10272
+ class Join {
10273
+ constructor(params) {
10274
+ assign(this, params);
10275
+ }
10324
10276
 
10325
- yy.Join = function (params) {
10326
- return assign(this, params);
10327
- };
10328
- yy.Join.prototype.toString = function () {
10329
- var s = ' ';
10330
- if (this.joinmode) {
10331
- s += this.joinmode + ' ';
10277
+ toString() {
10278
+ var s = ' ';
10279
+ if (this.joinmode) {
10280
+ s += this.joinmode + ' ';
10281
+ }
10282
+ s += 'JOIN ' + this.table.toString();
10283
+ return s;
10284
+ }
10332
10285
  }
10333
- s += 'JOIN ' + this.table.toString();
10334
- return s;
10335
- };
10336
10286
 
10337
- /**
10338
- Table class
10339
- @class
10340
- */
10287
+ class Table {
10288
+ constructor(params) {
10289
+ assign(this, params);
10290
+ }
10341
10291
 
10342
- yy.Table = function (params) {
10343
- return assign(this, params);
10344
- };
10345
- yy.Table.prototype.toString = function () {
10346
- var s = this.tableid;
10347
- // if(this.joinmode)
10348
- if (this.databaseid) {
10349
- s = this.databaseid + '.' + s;
10292
+ toString() {
10293
+ var s = this.tableid;
10294
+ // if(this.joinmode)
10295
+ if (this.databaseid) {
10296
+ s = this.databaseid + '.' + s;
10297
+ }
10298
+ return s;
10299
+ }
10350
10300
  }
10351
- return s;
10352
- };
10353
-
10354
- /**
10355
- View class
10356
- @class
10357
- */
10358
10301
 
10359
- yy.View = function (params) {
10360
- return assign(this, params);
10361
- };
10362
- yy.View.prototype.toString = function () {
10363
- var s = this.viewid;
10364
- // if(this.joinmode)
10365
- if (this.databaseid) {
10366
- s = this.databaseid + '.' + s;
10367
- }
10368
- return s;
10369
- };
10302
+ class View {
10303
+ constructor(params) {
10304
+ assign(this, params);
10305
+ }
10370
10306
 
10371
- /**
10372
- Binary operation class
10373
- @class
10374
- */
10375
- yy.Op = function (params) {
10376
- return assign(this, params);
10377
- };
10378
- yy.Op.prototype.toString = function () {
10379
- if (this.op === 'IN' || this.op === 'NOT IN') {
10380
- return this.left.toString() + ' ' + this.op + ' (' + this.right.toString() + ')';
10381
- }
10382
- if (this.allsome) {
10383
- return (
10384
- this.left.toString() + ' ' + this.op + ' ' + this.allsome + ' (' + this.right.toString() + ')'
10385
- );
10307
+ toString() {
10308
+ var s = this.viewid;
10309
+ // if(this.joinmode)
10310
+ if (this.databaseid) {
10311
+ s = this.databaseid + '.' + s;
10312
+ }
10313
+ return s;
10314
+ }
10386
10315
  }
10387
- if (this.op === '->' || this.op === '!') {
10388
- var s = this.left.toString() + this.op;
10389
10316
 
10390
- if (typeof this.right !== 'string' && typeof this.right !== 'number') {
10391
- s += '(';
10317
+ class Op {
10318
+ constructor(params) {
10319
+ assign(this, params);
10392
10320
  }
10393
10321
 
10394
- s += this.right.toString();
10322
+ toString() {
10323
+ if (this.op === 'IN' || this.op === 'NOT IN') {
10324
+ return this.left.toString() + ' ' + this.op + ' (' + this.right.toString() + ')';
10325
+ }
10326
+ if (this.allsome) {
10327
+ return (
10328
+ this.left.toString() +
10329
+ ' ' +
10330
+ this.op +
10331
+ ' ' +
10332
+ this.allsome +
10333
+ ' (' +
10334
+ this.right.toString() +
10335
+ ')'
10336
+ );
10337
+ }
10338
+ if (this.op === '->' || this.op === '!') {
10339
+ var s = this.left.toString() + this.op;
10395
10340
 
10396
- if (typeof this.right !== 'string' && typeof this.right !== 'number') {
10397
- s += ')';
10398
- }
10341
+ if (typeof this.right !== 'string' && typeof this.right !== 'number') {
10342
+ s += '(';
10343
+ }
10399
10344
 
10400
- return s;
10401
- }
10402
- if (this.op === 'BETWEEN' || this.op === 'NOT BETWEEN') {
10403
- var s =
10404
- this.left.toString() +
10405
- ' ' +
10406
- this.op +
10407
- ' ' +
10408
- this.right1.toString() +
10409
- ' AND ' +
10410
- this.right2.toString();
10345
+ s += this.right.toString();
10411
10346
 
10412
- return s;
10413
- }
10347
+ if (typeof this.right !== 'string' && typeof this.right !== 'number') {
10348
+ s += ')';
10349
+ }
10414
10350
 
10415
- return (
10416
- this.left.toString() +
10417
- ' ' +
10418
- this.op +
10419
- ' ' +
10420
- (this.allsome ? this.allsome + ' ' : '') +
10421
- this.right.toString()
10422
- );
10423
- };
10351
+ return s;
10352
+ }
10353
+ if (this.op === 'BETWEEN' || this.op === 'NOT BETWEEN') {
10354
+ var s =
10355
+ this.left.toString() +
10356
+ ' ' +
10357
+ this.op +
10358
+ ' ' +
10359
+ this.right1.toString() +
10360
+ ' AND ' +
10361
+ this.right2.toString();
10424
10362
 
10425
- yy.Op.prototype.findAggregator = function (query) {
10426
- if (this.left && this.left.findAggregator) {
10427
- this.left.findAggregator(query);
10428
- }
10429
- // Do not go in > ALL
10430
- if (this.right && this.right.findAggregator && !this.allsome) {
10431
- this.right.findAggregator(query);
10432
- }
10433
- };
10363
+ return s;
10364
+ }
10434
10365
 
10435
- yy.Op.prototype.toType = function (tableid) {
10436
- if (['-', '*', '/', '%', '^'].indexOf(this.op) > -1) {
10437
- return 'number';
10438
- }
10439
- if (['||'].indexOf(this.op) > -1) {
10440
- return 'string';
10441
- }
10442
- if (this.op === '+') {
10443
- if (this.left.toType(tableid) === 'string' || this.right.toType(tableid) === 'string') {
10444
- return 'string';
10366
+ return (
10367
+ this.left.toString() +
10368
+ ' ' +
10369
+ this.op +
10370
+ ' ' +
10371
+ (this.allsome ? this.allsome + ' ' : '') +
10372
+ this.right.toString()
10373
+ );
10445
10374
  }
10446
- if (this.left.toType(tableid) === 'number' || this.right.toType(tableid) === 'number') {
10447
- return 'number';
10375
+
10376
+ findAggregator(query) {
10377
+ if (this.left && this.left.findAggregator) {
10378
+ this.left.findAggregator(query);
10379
+ }
10380
+ // Do not go in > ALL
10381
+ if (this.right && this.right.findAggregator && !this.allsome) {
10382
+ this.right.findAggregator(query);
10383
+ }
10448
10384
  }
10449
- }
10450
10385
 
10451
- if (
10452
- [
10453
- 'AND',
10454
- 'OR',
10455
- 'NOT',
10456
- '=',
10457
- '==',
10458
- '===',
10459
- '!=',
10460
- '!==',
10461
- '!===',
10462
- '>',
10463
- '>=',
10464
- '<',
10465
- '<=',
10466
- 'IN',
10467
- 'NOT IN',
10468
- 'LIKE',
10469
- 'NOT LIKE',
10470
- 'REGEXP',
10471
- 'GLOB',
10472
- ].indexOf(this.op) > -1
10473
- ) {
10474
- return 'boolean';
10475
- }
10386
+ toType(tableid) {
10387
+ if (['-', '*', '/', '%', '^'].indexOf(this.op) > -1) {
10388
+ return 'number';
10389
+ }
10476
10390
 
10477
- if (
10478
- this.op === 'BETWEEN' ||
10479
- this.op === 'NOT BETWEEN' ||
10480
- this.op === 'IS NULL' ||
10481
- this.op === 'IS NOT NULL'
10482
- ) {
10483
- return 'boolean';
10484
- }
10391
+ if (['||'].indexOf(this.op) > -1) {
10392
+ return 'string';
10393
+ }
10485
10394
 
10486
- if (this.allsome) {
10487
- return 'boolean';
10488
- }
10395
+ if (this.op === '+') {
10396
+ if (this.left.toType(tableid) === 'string' || this.right.toType(tableid) === 'string') {
10397
+ return 'string';
10398
+ }
10399
+ if (this.left.toType(tableid) === 'number' || this.right.toType(tableid) === 'number') {
10400
+ return 'number';
10401
+ }
10402
+ }
10489
10403
 
10490
- if (!this.op) {
10491
- return this.left.toType();
10492
- }
10404
+ if (
10405
+ [
10406
+ 'AND',
10407
+ 'OR',
10408
+ 'NOT',
10409
+ '=',
10410
+ '==',
10411
+ '===',
10412
+ '!=',
10413
+ '!==',
10414
+ '!===',
10415
+ '>',
10416
+ '>=',
10417
+ '<',
10418
+ '<=',
10419
+ 'IN',
10420
+ 'NOT IN',
10421
+ 'LIKE',
10422
+ 'NOT LIKE',
10423
+ 'REGEXP',
10424
+ 'GLOB',
10425
+ ].indexOf(this.op) > -1
10426
+ ) {
10427
+ return 'boolean';
10428
+ }
10493
10429
 
10494
- return 'unknown';
10495
- };
10430
+ if (
10431
+ this.op === 'BETWEEN' ||
10432
+ this.op === 'NOT BETWEEN' ||
10433
+ this.op === 'IS NULL' ||
10434
+ this.op === 'IS NOT NULL'
10435
+ ) {
10436
+ return 'boolean';
10437
+ }
10496
10438
 
10497
- yy.Op.prototype.toJS = function (context, tableid, defcols) {
10439
+ if (this.allsome) {
10440
+ return 'boolean';
10441
+ }
10498
10442
 
10499
- var s;
10500
- var refs = [];
10501
- var op = this.op;
10502
- var _this = this;
10503
- //var leftJS = function(){return _this.left.toJS(context,tableid, defcols)};
10504
- //var rightJS = function(){return _this.right.toJS(context,tableid, defcols)};
10505
- var accessedLeft = false,
10506
- accessedRight = false;
10507
- var ref = function (expr) {
10508
- if (expr.toJS) {
10509
- expr = expr.toJS(context, tableid, defcols);
10510
- }
10511
- var i = refs.push(expr) - 1;
10512
- return 'y[' + i + ']';
10513
- };
10514
- var leftJS = function () {
10515
- return ref(_this.left);
10516
- };
10517
- var rightJS = function () {
10518
- return ref(_this.right);
10519
- };
10443
+ if (!this.op) {
10444
+ return this.left.toType();
10445
+ }
10520
10446
 
10521
- if (this.op === '=') {
10522
- op = '===';
10523
- } else if (this.op === '<>') {
10524
- op = '!=';
10525
- } else if (this.op === 'OR') {
10526
- op = '||';
10527
- }
10447
+ return 'unknown';
10448
+ }
10528
10449
 
10529
- // Arrow operator
10530
- if (this.op === '->') {
10531
- // Expression to prevent error if object is empty (#344)
10532
- var ljs = '(' + leftJS() + '||{})';
10450
+ toJS(context, tableid, defcols) {
10533
10451
 
10534
- if (typeof this.right === 'string') {
10535
- s = ljs + '["' + this.right + '"]';
10536
- } else if (typeof this.right === 'number') {
10537
- s = ljs + '[' + this.right + ']';
10538
- } else if (this.right instanceof yy.FuncValue) {
10539
- var ss = [];
10540
- if (!(!this.right.args || 0 === this.right.args.length)) {
10541
- var ss = this.right.args.map(ref);
10452
+ var s;
10453
+ var refs = [];
10454
+ var op = this.op;
10455
+ var _this = this;
10456
+ //var leftJS = function(){return _this.left.toJS(context,tableid, defcols)};
10457
+ //var rightJS = function(){return _this.right.toJS(context,tableid, defcols)};
10458
+ var accessedLeft = false,
10459
+ accessedRight = false;
10460
+ var ref = function (expr) {
10461
+ if (expr.toJS) {
10462
+ expr = expr.toJS(context, tableid, defcols);
10463
+ }
10464
+ var i = refs.push(expr) - 1;
10465
+ return 'y[' + i + ']';
10466
+ };
10467
+ var leftJS = function () {
10468
+ return ref(_this.left);
10469
+ };
10470
+ var rightJS = function () {
10471
+ return ref(_this.right);
10472
+ };
10473
+
10474
+ if (this.op === '=') {
10475
+ op = '===';
10476
+ } else if (this.op === '<>') {
10477
+ op = '!=';
10478
+ } else if (this.op === 'OR') {
10479
+ op = '||';
10542
10480
  }
10543
- s = '' + ljs + '[' + JSON.stringify(this.right.funcid) + '](' + ss.join(',') + ')';
10544
- } else {
10545
- s = '' + ljs + '[' + rightJS() + ']';
10546
- }
10547
- }
10548
10481
 
10549
- if (this.op === '!') {
10550
- if (typeof this.right === 'string') {
10551
- s = '' + 'alasql.databases[alasql.useid].objects[' + leftJS() + ']["' + this.right + '"]';
10552
- }
10553
- // TODO - add other cases
10554
- }
10482
+ // Arrow operator
10483
+ if (this.op === '->') {
10484
+ // Expression to prevent error if object is empty (#344)
10485
+ var ljs = '(' + leftJS() + '||{})';
10486
+
10487
+ if (typeof this.right === 'string') {
10488
+ s = ljs + '["' + this.right + '"]';
10489
+ } else if (typeof this.right === 'number') {
10490
+ s = ljs + '[' + this.right + ']';
10491
+ } else if (this.right instanceof yy.FuncValue) {
10492
+ var ss = [];
10493
+ if (!(!this.right.args || 0 === this.right.args.length)) {
10494
+ var ss = this.right.args.map(ref);
10495
+ }
10496
+ s = '' + ljs + '[' + JSON.stringify(this.right.funcid) + '](' + ss.join(',') + ')';
10497
+ } else {
10498
+ s = '' + ljs + '[' + rightJS() + ']';
10499
+ }
10500
+ }
10555
10501
 
10556
- if (this.op === 'IS') {
10557
- const leftOperand = leftJS();
10558
- const rightOperand = rightJS();
10559
- if (
10560
- this.right instanceof yy.NullValue ||
10561
- (this.right.op === 'NOT' && this.right.right instanceof yy.NullValue)
10562
- ) {
10563
- s = `(
10502
+ if (this.op === '!') {
10503
+ if (typeof this.right === 'string') {
10504
+ s = '' + 'alasql.databases[alasql.useid].objects[' + leftJS() + ']["' + this.right + '"]';
10505
+ }
10506
+ // TODO - add other cases
10507
+ }
10508
+
10509
+ if (this.op === 'IS') {
10510
+ const leftOperand = leftJS();
10511
+ const rightOperand = rightJS();
10512
+ if (
10513
+ this.right instanceof yy.NullValue ||
10514
+ (this.right.op === 'NOT' && this.right.right instanceof yy.NullValue)
10515
+ ) {
10516
+ s = `(
10564
10517
  (${leftOperand}==null) // Cant be ===
10565
10518
  ===
10566
10519
  (${rightOperand}==null) // Cant be ===
10567
10520
  )`;
10568
- } else {
10569
- s = `(
10521
+ } else {
10522
+ s = `(
10570
10523
  (${leftOperand} == ${rightOperand})
10571
10524
  ||
10572
10525
  (
@@ -10575,572 +10528,650 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
10575
10528
  true == ${rightOperand}
10576
10529
  )
10577
10530
  )`;
10578
- }
10579
- }
10531
+ }
10532
+ }
10580
10533
 
10581
- if (this.op === '==') {
10582
- s = '' + 'alasql.utils.deepEqual(' + leftJS() + ',' + rightJS() + ')';
10583
- }
10534
+ if (this.op === '==') {
10535
+ s = '' + 'alasql.utils.deepEqual(' + leftJS() + ',' + rightJS() + ')';
10536
+ }
10584
10537
 
10585
- if (this.op === '===' || this.op === '!===') {
10586
- s =
10587
- '' +
10588
- '(' +
10589
- (this.op === '!===' ? '!' : '') +
10590
- '(' +
10591
- '(' +
10592
- leftJS() +
10593
- ').valueOf()' +
10594
- '===' +
10595
- '(' +
10596
- rightJS() +
10597
- ').valueOf()' +
10598
- ')' +
10599
- ')';
10600
- }
10538
+ if (this.op === '===' || this.op === '!===') {
10539
+ s =
10540
+ '' +
10541
+ '(' +
10542
+ (this.op === '!===' ? '!' : '') +
10543
+ '(' +
10544
+ '(' +
10545
+ leftJS() +
10546
+ ').valueOf()' +
10547
+ '===' +
10548
+ '(' +
10549
+ rightJS() +
10550
+ ').valueOf()' +
10551
+ ')' +
10552
+ ')';
10553
+ }
10601
10554
 
10602
- if (this.op === '!==') {
10603
- s = '' + '(!alasql.utils.deepEqual(' + leftJS() + ',' + rightJS() + '))';
10604
- }
10605
- if (this.op === '||') {
10606
- s = '' + "(''+(" + leftJS() + "||'')+(" + rightJS() + '||""))';
10607
- }
10608
- if (this.op === 'LIKE' || this.op === 'NOT LIKE') {
10609
- var s =
10610
- '(' + (this.op === 'NOT LIKE' ? '!' : '') + 'alasql.utils.like(' + rightJS() + ',' + leftJS();
10611
- if (this.escape) {
10612
- s += ',' + ref(this.escape);
10613
- }
10614
- s += '))';
10615
- }
10616
- if (this.op === 'REGEXP') {
10617
- s = 'alasql.stdfn.REGEXP_LIKE(' + leftJS() + ',' + rightJS() + ')';
10618
- }
10619
- if (this.op === 'GLOB') {
10620
- s = 'alasql.utils.glob(' + leftJS() + ',' + rightJS() + ')';
10621
- }
10555
+ if (this.op === '!==') {
10556
+ s = '' + '(!alasql.utils.deepEqual(' + leftJS() + ',' + rightJS() + '))';
10557
+ }
10558
+ if (this.op === '||') {
10559
+ s = '' + "(''+(" + leftJS() + "||'')+(" + rightJS() + '||""))';
10560
+ }
10561
+ if (this.op === 'LIKE' || this.op === 'NOT LIKE') {
10562
+ var s =
10563
+ '(' +
10564
+ (this.op === 'NOT LIKE' ? '!' : '') +
10565
+ 'alasql.utils.like(' +
10566
+ rightJS() +
10567
+ ',' +
10568
+ leftJS();
10569
+ if (this.escape) {
10570
+ s += ',' + ref(this.escape);
10571
+ }
10572
+ s += '))';
10573
+ }
10574
+ if (this.op === 'REGEXP') {
10575
+ s = 'alasql.stdfn.REGEXP_LIKE(' + leftJS() + ',' + rightJS() + ')';
10576
+ }
10577
+ if (this.op === 'GLOB') {
10578
+ s = 'alasql.utils.glob(' + leftJS() + ',' + rightJS() + ')';
10579
+ }
10622
10580
 
10623
- if (this.op === 'BETWEEN' || this.op === 'NOT BETWEEN') {
10624
- var left = leftJS();
10625
- s =
10626
- '' +
10627
- '(' +
10628
- (this.op === 'NOT BETWEEN' ? '!' : '') +
10629
- '(' +
10630
- '(' +
10631
- ref(this.right1) +
10632
- '<=' +
10633
- left +
10634
- ') && (' +
10635
- left +
10636
- '<=' +
10637
- ref(this.right2) +
10638
- ')' +
10639
- ')' +
10640
- ')';
10641
- }
10581
+ if (this.op === 'BETWEEN' || this.op === 'NOT BETWEEN') {
10582
+ var left = leftJS();
10583
+ s =
10584
+ '' +
10585
+ '(' +
10586
+ (this.op === 'NOT BETWEEN' ? '!' : '') +
10587
+ '(' +
10588
+ '(' +
10589
+ ref(this.right1) +
10590
+ '<=' +
10591
+ left +
10592
+ ') && (' +
10593
+ left +
10594
+ '<=' +
10595
+ ref(this.right2) +
10596
+ ')' +
10597
+ ')' +
10598
+ ')';
10599
+ }
10642
10600
 
10643
- if (this.op === 'IN') {
10644
- if (this.right instanceof yy.Select) {
10645
- s = '(';
10646
- // s += 'this.query.queriesdata['+this.queriesidx+']';
10647
- // s += 'alasql.utils.flatArray(this.query.queriesfn['+(this.queriesidx)+'](params,null,context))';
10648
- s +=
10649
- 'alasql.utils.flatArray(this.queriesfn[' +
10650
- this.queriesidx +
10651
- '](params,null,' +
10652
- context +
10653
- '))';
10654
- s += '.indexOf(';
10655
- s += 'alasql.utils.getValueOf(' + leftJS() + '))>-1)';
10656
- } else if (Array.isArray(this.right)) {
10657
- // if(this.right.length == 0) return 'false';
10658
- s =
10659
- '([' +
10660
- this.right.map(ref).join(',') +
10661
- '].indexOf(alasql.utils.getValueOf(' +
10662
- leftJS() +
10663
- '))>-1)';
10601
+ if (this.op === 'IN') {
10602
+ if (this.right instanceof yy.Select) {
10603
+ s = '(';
10604
+ // s += 'this.query.queriesdata['+this.queriesidx+']';
10605
+ // s += 'alasql.utils.flatArray(this.query.queriesfn['+(this.queriesidx)+'](params,null,context))';
10606
+ s +=
10607
+ 'alasql.utils.flatArray(this.queriesfn[' +
10608
+ this.queriesidx +
10609
+ '](params,null,' +
10610
+ context +
10611
+ '))';
10612
+ s += '.indexOf(';
10613
+ s += 'alasql.utils.getValueOf(' + leftJS() + '))>-1)';
10614
+ } else if (Array.isArray(this.right)) {
10615
+ // if(this.right.length == 0) return 'false';
10616
+ s =
10617
+ '([' +
10618
+ this.right.map(ref).join(',') +
10619
+ '].indexOf(alasql.utils.getValueOf(' +
10620
+ leftJS() +
10621
+ '))>-1)';
10664
10622
 
10665
- } else {
10666
- s = '(' + rightJS() + '.indexOf(' + leftJS() + ')>-1)';
10623
+ } else {
10624
+ s = '(' + rightJS() + '.indexOf(' + leftJS() + ')>-1)';
10667
10625
 
10668
- // } else {
10669
- // throw new Error('Wrong IN operator without SELECT part');
10670
- }
10671
- }
10626
+ // } else {
10627
+ // throw new Error('Wrong IN operator without SELECT part');
10628
+ }
10629
+ }
10672
10630
 
10673
- if (this.op === 'NOT IN') {
10674
- if (this.right instanceof yy.Select) {
10675
- s = '(';
10676
- s += 'alasql.utils.flatArray(this.queriesfn[' + this.queriesidx + '](params,null,p))';
10677
- s += '.indexOf(';
10678
- s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
10679
- } else if (Array.isArray(this.right)) {
10680
- s = '([' + this.right.map(ref).join(',') + '].indexOf(';
10681
- s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
10682
- } else {
10683
- s = '(' + rightJS() + '.indexOf(';
10684
- s += leftJS() + ')==-1)';
10631
+ if (this.op === 'NOT IN') {
10632
+ if (this.right instanceof yy.Select) {
10633
+ s = '(';
10634
+ s += 'alasql.utils.flatArray(this.queriesfn[' + this.queriesidx + '](params,null,p))';
10635
+ s += '.indexOf(';
10636
+ s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
10637
+ } else if (Array.isArray(this.right)) {
10638
+ s = '([' + this.right.map(ref).join(',') + '].indexOf(';
10639
+ s += 'alasql.utils.getValueOf(' + leftJS() + '))<0)';
10640
+ } else {
10641
+ s = '(' + rightJS() + '.indexOf(';
10642
+ s += leftJS() + ')==-1)';
10643
+
10644
+ // throw new Error('Wrong NOT IN operator without SELECT part');
10645
+ }
10646
+ }
10647
+
10648
+ if (this.allsome === 'ALL') {
10649
+ var s;
10650
+ if (this.right instanceof yy.Select) {
10651
+ s =
10652
+ 'alasql.utils.flatArray(this.query.queriesfn[' + this.queriesidx + '](params,null,p))';
10653
+
10654
+ s += '.every(function(b){return (';
10655
+ s += leftJS() + ')' + op + 'b})';
10656
+ } else if (Array.isArray(this.right)) {
10657
+ s =
10658
+ '' +
10659
+ (this.right.length == 1
10660
+ ? ref(this.right[0])
10661
+ : '[' + this.right.map(ref).join(',') + ']');
10662
+ s += '.every(function(b){return (';
10663
+ s += leftJS() + ')' + op + 'b})';
10664
+ } else {
10665
+ throw new Error('NOT IN operator without SELECT');
10666
+ }
10667
+ }
10668
+
10669
+ if (this.allsome === 'SOME' || this.allsome === 'ANY') {
10670
+ var s;
10671
+ if (this.right instanceof yy.Select) {
10672
+ s =
10673
+ 'alasql.utils.flatArray(this.query.queriesfn[' + this.queriesidx + '](params,null,p))';
10674
+ s += '.some(function(b){return (';
10675
+ s += leftJS() + ')' + op + 'b})';
10676
+ } else if (Array.isArray(this.right)) {
10677
+ s =
10678
+ '' +
10679
+ (this.right.length == 1
10680
+ ? ref(this.right[0])
10681
+ : '[' + this.right.map(ref).join(',') + ']');
10682
+ s += '.some(function(b){return (';
10683
+ s += leftJS() + ')' + op + 'b})';
10684
+ } else {
10685
+ throw new Error('SOME/ANY operator without SELECT');
10686
+ }
10687
+ }
10688
+
10689
+ // Special case for AND optimization (if reduced)
10690
+ if (this.op === 'AND') {
10691
+ if (this.left.reduced) {
10692
+ if (this.right.reduced) {
10693
+ return 'true';
10694
+ } else {
10695
+ s = rightJS();
10696
+ }
10697
+ } else if (this.right.reduced) {
10698
+ s = leftJS();
10699
+ }
10685
10700
 
10686
- // throw new Error('Wrong NOT IN operator without SELECT part');
10701
+ // Otherwise process as regular operation (see below)
10702
+ op = '&&';
10703
+ }
10704
+
10705
+ // if(this.op === '^') {
10706
+ // // return 'Math.pow('
10707
+ // // + leftJS()
10708
+ // // + ','
10709
+ // // + rightJS()
10710
+ // // + ')';
10711
+ // }
10712
+ var expr = s || '(' + leftJS() + op + rightJS() + ')';
10713
+
10714
+ var declareRefs = 'y=[(' + refs.join('), (') + ')]';
10715
+ if (op === '&&' || op === '||' || op === 'IS' || op === 'IS NULL' || op === 'IS NOT NULL') {
10716
+ return '(' + declareRefs + ', ' + expr + ')';
10717
+ }
10718
+
10719
+ return (
10720
+ '(' + declareRefs + ', ' + 'y.some(function(e){return e == null}) ? void 0 : ' + expr + ')'
10721
+ );
10687
10722
  }
10688
10723
  }
10689
10724
 
10690
- if (this.allsome === 'ALL') {
10691
- var s;
10692
- if (this.right instanceof yy.Select) {
10693
- s = 'alasql.utils.flatArray(this.query.queriesfn[' + this.queriesidx + '](params,null,p))';
10725
+ class VarValue {
10726
+ constructor(params) {
10727
+ assign(this, params);
10728
+ }
10694
10729
 
10695
- s += '.every(function(b){return (';
10696
- s += leftJS() + ')' + op + 'b})';
10697
- } else if (Array.isArray(this.right)) {
10698
- s =
10699
- '' +
10700
- (this.right.length == 1 ? ref(this.right[0]) : '[' + this.right.map(ref).join(',') + ']');
10701
- s += '.every(function(b){return (';
10702
- s += leftJS() + ')' + op + 'b})';
10703
- } else {
10704
- throw new Error('NOT IN operator without SELECT');
10705
- }
10706
- }
10707
-
10708
- if (this.allsome === 'SOME' || this.allsome === 'ANY') {
10709
- var s;
10710
- if (this.right instanceof yy.Select) {
10711
- s = 'alasql.utils.flatArray(this.query.queriesfn[' + this.queriesidx + '](params,null,p))';
10712
- s += '.some(function(b){return (';
10713
- s += leftJS() + ')' + op + 'b})';
10714
- } else if (Array.isArray(this.right)) {
10715
- s =
10716
- '' +
10717
- (this.right.length == 1 ? ref(this.right[0]) : '[' + this.right.map(ref).join(',') + ']');
10718
- s += '.some(function(b){return (';
10719
- s += leftJS() + ')' + op + 'b})';
10720
- } else {
10721
- throw new Error('SOME/ANY operator without SELECT');
10730
+ toString() {
10731
+ return '@' + this.variable;
10722
10732
  }
10723
- }
10724
10733
 
10725
- // Special case for AND optimization (if reduced)
10726
- if (this.op === 'AND') {
10727
- if (this.left.reduced) {
10728
- if (this.right.reduced) {
10729
- return 'true';
10730
- } else {
10731
- s = rightJS();
10732
- }
10733
- } else if (this.right.reduced) {
10734
- s = leftJS();
10734
+ toType() {
10735
+ return 'unknown';
10735
10736
  }
10736
10737
 
10737
- // Otherwise process as regular operation (see below)
10738
- op = '&&';
10738
+ toJS() {
10739
+ return "alasql.vars['" + this.variable + "']";
10740
+ }
10739
10741
  }
10740
10742
 
10741
- // if(this.op === '^') {
10742
- // // return 'Math.pow('
10743
- // // + leftJS()
10744
- // // + ','
10745
- // // + rightJS()
10746
- // // + ')';
10747
- // }
10748
-
10749
- var expr = s || '(' + leftJS() + op + rightJS() + ')';
10743
+ class NumValue {
10744
+ constructor(params) {
10745
+ assign(this, params);
10746
+ }
10750
10747
 
10751
- var declareRefs = 'y=[(' + refs.join('), (') + ')]';
10752
- if (op === '&&' || op === '||' || op === 'IS' || op === 'IS NULL' || op === 'IS NOT NULL') {
10753
- return '(' + declareRefs + ', ' + expr + ')';
10754
- }
10748
+ toString() {
10749
+ return this.value.toString();
10750
+ }
10755
10751
 
10756
- return (
10757
- '(' + declareRefs + ', ' + 'y.some(function(e){return e == null}) ? void 0 : ' + expr + ')'
10758
- );
10759
- };
10752
+ toType() {
10753
+ return 'number';
10754
+ }
10760
10755
 
10761
- yy.VarValue = function (params) {
10762
- return assign(this, params);
10763
- };
10764
- yy.VarValue.prototype.toString = function () {
10765
- return '@' + this.variable;
10766
- };
10756
+ toJS() {
10757
+ return '' + this.value;
10758
+ }
10759
+ }
10767
10760
 
10768
- yy.VarValue.prototype.toType = function () {
10769
- return 'unknown';
10770
- };
10761
+ class StringValue {
10762
+ constructor(params) {
10763
+ assign(this, params);
10764
+ }
10771
10765
 
10772
- yy.VarValue.prototype.toJS = function () {
10773
- return "alasql.vars['" + this.variable + "']";
10774
- };
10766
+ toString() {
10767
+ return "'" + this.value.toString() + "'";
10768
+ }
10775
10769
 
10776
- yy.NumValue = function (params) {
10777
- return assign(this, params);
10778
- };
10779
- yy.NumValue.prototype.toString = function () {
10780
- return this.value.toString();
10781
- };
10770
+ toType() {
10771
+ return 'string';
10772
+ }
10782
10773
 
10783
- yy.NumValue.prototype.toType = function () {
10784
- return 'number';
10785
- };
10774
+ toJS() {
10775
+ return "'" + escapeq(this.value) + "'";
10776
+ }
10777
+ }
10786
10778
 
10787
- yy.NumValue.prototype.toJS = function () {
10788
- return '' + this.value;
10789
- };
10779
+ class DomainValueValue {
10780
+ constructor(params) {
10781
+ assign(this, params);
10782
+ }
10790
10783
 
10791
- yy.StringValue = function (params) {
10792
- return assign(this, params);
10793
- };
10794
- yy.StringValue.prototype.toString = function () {
10795
- return "'" + this.value.toString() + "'";
10796
- };
10784
+ toString() {
10785
+ return 'VALUE';
10786
+ }
10797
10787
 
10798
- yy.StringValue.prototype.toType = function () {
10799
- return 'string';
10800
- };
10788
+ toType() {
10789
+ return 'object';
10790
+ }
10801
10791
 
10802
- yy.StringValue.prototype.toJS = function () {
10803
- return "'" + escapeq(this.value) + "'";
10804
- };
10792
+ toJS(context, tableid, defcols) {
10805
10793
 
10806
- yy.DomainValueValue = function (params) {
10807
- return assign(this, params);
10808
- };
10809
- yy.DomainValueValue.prototype.toString = function () {
10810
- return 'VALUE';
10811
- };
10794
+ // return "'"+doubleqq(this.value)+"'";
10795
+ return context;
10796
+ }
10797
+ }
10812
10798
 
10813
- yy.DomainValueValue.prototype.toType = function () {
10814
- return 'object';
10815
- };
10799
+ class ArrayValue {
10800
+ constructor(params) {
10801
+ assign(this, params);
10802
+ }
10816
10803
 
10817
- yy.DomainValueValue.prototype.toJS = function (context, tableid, defcols) {
10804
+ toString() {
10805
+ return 'ARRAY[]';
10806
+ }
10818
10807
 
10819
- // return "'"+doubleqq(this.value)+"'";
10820
- return context;
10821
- };
10808
+ toType() {
10809
+ return 'object';
10810
+ }
10822
10811
 
10823
- yy.ArrayValue = function (params) {
10824
- return assign(this, params);
10825
- };
10826
- yy.ArrayValue.prototype.toString = function () {
10827
- return 'ARRAY[]';
10828
- };
10812
+ toJS(context, tableid, defcols) {
10813
+ return (
10814
+ '[(' +
10815
+ this.value
10816
+ .map(function (el) {
10817
+ return el.toJS(context, tableid, defcols);
10818
+ })
10819
+ .join('), (') +
10820
+ ')]'
10821
+ );
10822
+ }
10823
+ }
10829
10824
 
10830
- yy.ArrayValue.prototype.toType = function () {
10831
- return 'object';
10832
- };
10825
+ class LogicValue {
10826
+ constructor(params) {
10827
+ assign(this, params);
10828
+ }
10833
10829
 
10834
- yy.ArrayValue.prototype.toJS = function (context, tableid, defcols) {
10835
- return (
10836
- '[(' +
10837
- this.value
10838
- .map(function (el) {
10839
- return el.toJS(context, tableid, defcols);
10840
- })
10841
- .join('), (') +
10842
- ')]'
10843
- );
10844
- };
10830
+ toString() {
10831
+ return this.value ? 'TRUE' : 'FALSE';
10832
+ }
10845
10833
 
10846
- yy.LogicValue = function (params) {
10847
- return assign(this, params);
10848
- };
10849
- yy.LogicValue.prototype.toString = function () {
10850
- return this.value ? 'TRUE' : 'FALSE';
10851
- };
10834
+ toType() {
10835
+ return 'boolean';
10836
+ }
10852
10837
 
10853
- yy.LogicValue.prototype.toType = function () {
10854
- return 'boolean';
10855
- };
10838
+ toJS() {
10839
+ return this.value ? 'true' : 'false';
10840
+ }
10841
+ }
10856
10842
 
10857
- yy.LogicValue.prototype.toJS = function () {
10858
- return this.value ? 'true' : 'false';
10859
- };
10843
+ class NullValue {
10844
+ constructor(params) {
10845
+ assign(this, params);
10846
+ }
10860
10847
 
10861
- yy.NullValue = function (params) {
10862
- return assign(this, params);
10863
- };
10864
- yy.NullValue.prototype.toString = function () {
10865
- return 'NULL';
10866
- };
10867
- yy.NullValue.prototype.toJS = function () {
10868
- return 'undefined';
10869
- // return 'undefined';
10870
- };
10848
+ toString() {
10849
+ return 'NULL';
10850
+ }
10871
10851
 
10872
- yy.ParamValue = function (params) {
10873
- return assign(this, params);
10874
- };
10875
- yy.ParamValue.prototype.toString = function () {
10876
- return '$' + this.param;
10877
- };
10878
- yy.ParamValue.prototype.toJS = function () {
10879
- if (typeof this.param === 'string') {
10880
- return "params['" + this.param + "']";
10852
+ toJS() {
10853
+ return 'undefined';
10854
+ }
10881
10855
  }
10882
10856
 
10883
- return 'params[' + this.param + ']';
10884
- };
10857
+ class ParamValue {
10858
+ constructor(params) {
10859
+ assign(this, params);
10860
+ }
10885
10861
 
10886
- yy.UniOp = function (params) {
10887
- return assign(this, params);
10888
- };
10889
- yy.UniOp.prototype.toString = function () {
10890
- var s;
10891
- s = void 0;
10892
- if (this.op === '~') {
10893
- s = this.op + this.right.toString();
10894
- }
10895
- if (this.op === '-') {
10896
- s = this.op + this.right.toString();
10897
- }
10898
- if (this.op === '+') {
10899
- s = this.op + this.right.toString();
10900
- }
10901
- if (this.op === '#') {
10902
- s = this.op + this.right.toString();
10903
- }
10904
- if (this.op === 'NOT') {
10905
- s = this.op + '(' + this.right.toString() + ')';
10906
- }
10907
- if (this.op === null) {
10908
- s = '(' + this.right.toString() + ')';
10909
- }
10910
- if (!s) {
10911
- s = '(' + this.right.toString() + ')';
10912
- }
10913
- return s;
10914
- };
10862
+ toString() {
10863
+ return '$' + this.param;
10864
+ }
10915
10865
 
10916
- yy.UniOp.prototype.findAggregator = function (query) {
10917
- if (this.right.findAggregator) {
10918
- this.right.findAggregator(query);
10919
- }
10920
- };
10866
+ toJS() {
10867
+ if (typeof this.param === 'string') {
10868
+ return "params['" + this.param + "']";
10869
+ }
10921
10870
 
10922
- yy.UniOp.prototype.toType = function () {
10923
- if (this.op === '-') {
10924
- return 'number';
10871
+ return 'params[' + this.param + ']';
10872
+ }
10925
10873
  }
10926
10874
 
10927
- if (this.op === '+') {
10928
- return 'number';
10929
- }
10875
+ class UniOp {
10876
+ constructor(params) {
10877
+ assign(this, params);
10878
+ }
10930
10879
 
10931
- if (this.op === 'NOT') {
10932
- return 'boolean';
10933
- }
10880
+ toString() {
10881
+ var s;
10882
+ const {op, right} = this;
10883
+ const res = right.toString();
10934
10884
 
10935
- // Todo: implement default case
10936
- };
10885
+ if (op === '~') {
10886
+ s = op + res;
10887
+ }
10888
+ if (op === '-') {
10889
+ s = op + res;
10890
+ }
10891
+ if (op === '+') {
10892
+ s = op + res;
10893
+ }
10894
+ if (op === '#') {
10895
+ s = op + res;
10896
+ }
10897
+ if (op === 'NOT') {
10898
+ s = op + '(' + res + ')';
10899
+ }
10900
+ if (op === null) {
10901
+ s = '(' + res + ')';
10902
+ }
10903
+ if (!s) {
10904
+ s = '(' + res + ')';
10905
+ }
10906
+ return s;
10907
+ }
10937
10908
 
10938
- yy.UniOp.prototype.toJS = function (context, tableid, defcols) {
10939
- if (this.op === '~') {
10940
- return '(~(' + this.right.toJS(context, tableid, defcols) + '))';
10941
- }
10909
+ findAggregator(query) {
10910
+ if (this.right.findAggregator) {
10911
+ this.right.findAggregator(query);
10912
+ }
10913
+ }
10942
10914
 
10943
- if (this.op === '-') {
10944
- return '(-(' + this.right.toJS(context, tableid, defcols) + '))';
10945
- }
10915
+ toType() {
10916
+ if (this.op === '-') {
10917
+ return 'number';
10918
+ }
10946
10919
 
10947
- if (this.op === '+') {
10948
- return '(' + this.right.toJS(context, tableid, defcols) + ')';
10949
- }
10920
+ if (this.op === '+') {
10921
+ return 'number';
10922
+ }
10950
10923
 
10951
- if (this.op === 'NOT') {
10952
- return '!(' + this.right.toJS(context, tableid, defcols) + ')';
10953
- }
10924
+ if (this.op === 'NOT') {
10925
+ return 'boolean';
10926
+ }
10954
10927
 
10955
- if (this.op === '#') {
10956
- if (this.right instanceof yy.Column) {
10957
- return "(alasql.databases[alasql.useid].objects['" + this.right.columnid + "'])";
10958
- } else {
10959
- return (
10960
- '(alasql.databases[alasql.useid].objects[' +
10961
- this.right.toJS(context, tableid, defcols) +
10962
- '])'
10963
- );
10928
+ // Todo: implement default case
10964
10929
  }
10965
- }
10966
10930
 
10967
- // Please avoid === here
10968
- if (this.op == null) {
10969
- // jshint ignore:line
10970
- return '(' + this.right.toJS(context, tableid, defcols) + ')';
10971
- }
10931
+ toJS(context, tableid, defcols) {
10932
+ if (this.op === '~') {
10933
+ return '(~(' + this.right.toJS(context, tableid, defcols) + '))';
10934
+ }
10972
10935
 
10973
- // Todo: implement default case.
10974
- };
10936
+ if (this.op === '-') {
10937
+ return '(-(' + this.right.toJS(context, tableid, defcols) + '))';
10938
+ }
10975
10939
 
10976
- yy.Column = function (params) {
10977
- return assign(this, params);
10978
- };
10979
- yy.Column.prototype.toString = function () {
10980
- var s;
10981
- if (this.columnid == +this.columnid) {
10982
- s = '[' + this.columnid + ']';
10983
- } else {
10984
- s = this.columnid;
10985
- }
10986
- if (this.tableid) {
10987
- if (+this.columnid === this.columnid) {
10988
- s = this.tableid + s;
10989
- } else {
10990
- s = this.tableid + '.' + s;
10991
- }
10992
- if (this.databaseid) {
10993
- s = this.databaseid + '.' + s;
10940
+ if (this.op === '+') {
10941
+ return '(' + this.right.toJS(context, tableid, defcols) + ')';
10942
+ }
10943
+
10944
+ if (this.op === 'NOT') {
10945
+ return '!(' + this.right.toJS(context, tableid, defcols) + ')';
10946
+ }
10947
+
10948
+ if (this.op === '#') {
10949
+ if (this.right instanceof Column) {
10950
+ return "(alasql.databases[alasql.useid].objects['" + this.right.columnid + "'])";
10951
+ } else {
10952
+ return (
10953
+ '(alasql.databases[alasql.useid].objects[' +
10954
+ this.right.toJS(context, tableid, defcols) +
10955
+ '])'
10956
+ );
10957
+ }
10958
+ }
10959
+
10960
+ // Please avoid === here
10961
+ if (this.op == null) {
10962
+ // jshint ignore:line
10963
+ return '(' + this.right.toJS(context, tableid, defcols) + ')';
10964
+ }
10965
+
10966
+ // Todo: implement default case.
10994
10967
  }
10995
10968
  }
10996
- return s;
10997
- };
10998
10969
 
10999
- yy.Column.prototype.toJS = function (context, tableid, defcols) {
11000
- var s = '';
11001
- if (!this.tableid && tableid === '' && !defcols) {
11002
- if (this.columnid !== '_') {
11003
- s = context + "['" + this.columnid + "']";
11004
- } else {
11005
- if (context === 'g') {
11006
- s = "g['_']";
11007
- } else {
11008
- s = context;
11009
- }
10970
+ class Column {
10971
+ constructor(params) {
10972
+ assign(this, params);
11010
10973
  }
11011
- } else {
11012
- if (context === 'g') {
11013
- s = "g['" + this.nick + "']";
11014
- } else if (this.tableid) {
11015
- if (this.columnid !== '_') {
11016
- s = context + "['" + this.tableid + "']['" + this.columnid + "']";
10974
+
10975
+ toString() {
10976
+ var s;
10977
+ if (this.columnid == +this.columnid) {
10978
+ s = '[' + this.columnid + ']';
11017
10979
  } else {
11018
- if (context === 'g') {
11019
- s = "g['_']";
10980
+ s = this.columnid;
10981
+ }
10982
+ if (this.tableid) {
10983
+ if (+this.columnid === this.columnid) {
10984
+ s = this.tableid + s;
11020
10985
  } else {
11021
- s = context + "['" + this.tableid + "']";
10986
+ s = this.tableid + '.' + s;
10987
+ }
10988
+ if (this.databaseid) {
10989
+ s = this.databaseid + '.' + s;
11022
10990
  }
11023
10991
  }
11024
- } else if (defcols) {
11025
- var tbid = defcols[this.columnid];
11026
- if (tbid === '-') {
11027
- throw new Error(
11028
- 'Cannot resolve column "' + this.columnid + '" because it exists in two source tables'
11029
- );
11030
- } else if (tbid) {
10992
+ return s;
10993
+ }
10994
+
10995
+ toJS(context, tableid, defcols) {
10996
+ var s = '';
10997
+ if (!this.tableid && tableid === '' && !defcols) {
11031
10998
  if (this.columnid !== '_') {
11032
- s = context + "['" + tbid + "']['" + this.columnid + "']";
10999
+ s = context + "['" + this.columnid + "']";
11033
11000
  } else {
11034
- s = context + "['" + tbid + "']";
11001
+ if (context === 'g') {
11002
+ s = "g['_']";
11003
+ } else {
11004
+ s = context;
11005
+ }
11035
11006
  }
11036
-
11037
11007
  } else {
11038
- if (this.columnid !== '_') {
11039
- s = context + "['" + (this.tableid || tableid) + "']['" + this.columnid + "']";
11008
+ if (context === 'g') {
11009
+ s = "g['" + this.nick + "']";
11010
+ } else if (this.tableid) {
11011
+ if (this.columnid !== '_') {
11012
+ s = context + "['" + this.tableid + "']['" + this.columnid + "']";
11013
+ } else {
11014
+ if (context === 'g') {
11015
+ s = "g['_']";
11016
+ } else {
11017
+ s = context + "['" + this.tableid + "']";
11018
+ }
11019
+ }
11020
+ } else if (defcols) {
11021
+ var tbid = defcols[this.columnid];
11022
+ if (tbid === '-') {
11023
+ throw new Error(
11024
+ 'Cannot resolve column "' + this.columnid + '" because it exists in two source tables'
11025
+ );
11026
+ } else if (tbid) {
11027
+ if (this.columnid !== '_') {
11028
+ s = context + "['" + tbid + "']['" + this.columnid + "']";
11029
+ } else {
11030
+ s = context + "['" + tbid + "']";
11031
+ }
11032
+
11033
+ } else {
11034
+ if (this.columnid !== '_') {
11035
+ s = context + "['" + (this.tableid || tableid) + "']['" + this.columnid + "']";
11036
+ } else {
11037
+ s = context + "['" + (this.tableid || tableid) + "']";
11038
+ }
11039
+ }
11040
+ } else if (tableid === -1) {
11041
+ s = context + "['" + this.columnid + "']";
11040
11042
  } else {
11041
- s = context + "['" + (this.tableid || tableid) + "']";
11043
+ if (this.columnid !== '_') {
11044
+ s = context + "['" + (this.tableid || tableid) + "']['" + this.columnid + "']";
11045
+ } else {
11046
+ s = context + "['" + (this.tableid || tableid) + "']";
11047
+ }
11042
11048
  }
11043
11049
  }
11044
- } else if (tableid === -1) {
11045
- s = context + "['" + this.columnid + "']";
11046
- } else {
11047
- if (this.columnid !== '_') {
11048
- s = context + "['" + (this.tableid || tableid) + "']['" + this.columnid + "']";
11049
- } else {
11050
- s = context + "['" + (this.tableid || tableid) + "']";
11051
- }
11050
+ return s;
11052
11051
  }
11053
11052
  }
11054
- return s;
11055
- };
11056
11053
 
11057
- yy.AggrValue = function (params) {
11058
- return assign(this, params);
11059
- };
11060
- yy.AggrValue.prototype.toString = function () {
11061
- var s = '';
11062
- if (this.aggregatorid === 'REDUCE') {
11063
- s += this.funcid.replace(re_invalidFnNameChars, '') + '(';
11064
- } else {
11065
- s += this.aggregatorid + '(';
11066
- }
11054
+ class AggrValue {
11055
+ constructor(params) {
11056
+ assign(this, params);
11057
+ }
11067
11058
 
11068
- if (this.distinct) {
11069
- s += 'DISTINCT ';
11070
- }
11059
+ toString() {
11060
+ var s = '';
11061
+ if (this.aggregatorid === 'REDUCE') {
11062
+ s += this.funcid.replace(re_invalidFnNameChars, '') + '(';
11063
+ } else {
11064
+ s += this.aggregatorid + '(';
11065
+ }
11071
11066
 
11072
- if (this.expression) {
11073
- s += this.expression.toString();
11074
- }
11067
+ if (this.distinct) {
11068
+ s += 'DISTINCT ';
11069
+ }
11075
11070
 
11076
- s += ')';
11071
+ if (this.expression) {
11072
+ s += this.expression.toString();
11073
+ }
11077
11074
 
11078
- if (this.over) {
11079
- s += ' ' + this.over.toString();
11080
- }
11081
- return s;
11082
- };
11075
+ s += ')';
11083
11076
 
11084
- yy.AggrValue.prototype.findAggregator = function (query) {
11085
- var colas = escapeq(this.toString()) + ':' + query.selectGroup.length;
11086
- var found = false;
11087
- if (!found) {
11088
- if (!this.nick) {
11089
- this.nick = colas;
11077
+ if (this.over) {
11078
+ s += ' ' + this.over.toString();
11079
+ }
11080
+ return s;
11081
+ }
11082
+
11083
+ findAggregator(query) {
11084
+ var colas = escapeq(this.toString()) + ':' + query.selectGroup.length;
11090
11085
  var found = false;
11091
- for (var i = 0; i < query.removeKeys.length; i++) {
11092
- if (query.removeKeys[i] === colas) {
11093
- found = true;
11094
- break;
11086
+ if (!found) {
11087
+ if (!this.nick) {
11088
+ this.nick = colas;
11089
+ var found = false;
11090
+ for (var i = 0; i < query.removeKeys.length; i++) {
11091
+ if (query.removeKeys[i] === colas) {
11092
+ found = true;
11093
+ break;
11094
+ }
11095
+ }
11096
+ if (!found) {
11097
+ query.removeKeys.push(colas);
11098
+ }
11095
11099
  }
11100
+ query.selectGroup.push(this);
11096
11101
  }
11097
- if (!found) {
11098
- query.removeKeys.push(colas);
11102
+ return;
11103
+ }
11104
+
11105
+ toType() {
11106
+ if (
11107
+ ['SUM', 'COUNT', 'AVG', 'MIN', 'MAX', 'AGGR', 'VAR', 'STDDEV'].indexOf(this.aggregatorid) >
11108
+ -1
11109
+ ) {
11110
+ return 'number';
11099
11111
  }
11112
+
11113
+ if (['ARRAY'].indexOf(this.aggregatorid) > -1) {
11114
+ return 'array';
11115
+ }
11116
+
11117
+ if (['FIRST', 'LAST'].indexOf(this.aggregatorid) > -1) {
11118
+ return this.expression.toType();
11119
+ }
11120
+
11121
+ return this.expression.toType();
11100
11122
  }
11101
- query.selectGroup.push(this);
11102
- }
11103
- return;
11104
- };
11105
11123
 
11106
- yy.AggrValue.prototype.toType = function () {
11107
- if (
11108
- ['SUM', 'COUNT', 'AVG', 'MIN', 'MAX', 'AGGR', 'VAR', 'STDDEV'].indexOf(this.aggregatorid) > -1
11109
- ) {
11110
- return 'number';
11124
+ toJS() {
11125
+ var colas = this.nick;
11126
+ if (colas === undefined) {
11127
+ colas = this.toString();
11128
+ }
11129
+ return "g['" + colas + "']";
11130
+ }
11111
11131
  }
11112
11132
 
11113
- if (['ARRAY'].indexOf(this.aggregatorid) > -1) {
11114
- return 'array';
11133
+ class OrderExpression {
11134
+ constructor(params) {
11135
+ assign(this, params);
11136
+ }
11115
11137
  }
11116
11138
 
11117
- if (['FIRST', 'LAST'].indexOf(this.aggregatorid) > -1) {
11118
- return this.expression.toType();
11119
- }
11139
+ OrderExpression.prototype.toString = Expression.prototype.toString;
11120
11140
 
11121
- return this.expression.toType();
11122
- };
11141
+ class GroupExpression {
11142
+ constructor(params) {
11143
+ assign(this, params);
11144
+ }
11123
11145
 
11124
- yy.AggrValue.prototype.toJS = function () {
11125
- var colas = this.nick;
11126
- if (colas === undefined) {
11127
- colas = this.toString();
11146
+ toString() {
11147
+ return this.type + '(' + this.group.toString() + ')';
11148
+ }
11128
11149
  }
11129
- return "g['" + colas + "']";
11130
- };
11131
-
11132
- yy.OrderExpression = function (params) {
11133
- return assign(this, params);
11134
- };
11135
-
11136
- yy.OrderExpression.prototype.toString = yy.Expression.prototype.toString;
11137
11150
 
11138
- yy.GroupExpression = function (params) {
11139
- return assign(this, params);
11140
- };
11141
- yy.GroupExpression.prototype.toString = function () {
11142
- return this.type + '(' + this.group.toString() + ')';
11143
- };
11151
+ assign(yy, {
11152
+ AggrValue,
11153
+ ArrayValue,
11154
+ Column,
11155
+ DomainValueValue,
11156
+ Expression,
11157
+ ExpressionStatement,
11158
+ GroupExpression,
11159
+ JavaScript,
11160
+ Join,
11161
+ Literal,
11162
+ LogicValue,
11163
+ NullValue,
11164
+ NumValue,
11165
+ Op,
11166
+ OrderExpression,
11167
+ ParamValue,
11168
+ StringValue,
11169
+ Table,
11170
+ UniOp,
11171
+ VarValue,
11172
+ View,
11173
+ });
11174
+ }
11144
11175
 
11145
11176
  // Alasql Linq library
11146
11177
 
@@ -11320,9 +11351,9 @@ yy.FuncValue = function (params) {
11320
11351
  return Object.assign(this, params);
11321
11352
  };
11322
11353
 
11323
- var re_invalidFnNameChars = /[^0-9A-Z_$]+/i;
11354
+ let re_invalidFnNameChars = /[^0-9A-Z_$]+/i;
11324
11355
  yy.FuncValue.prototype.toString = function () {
11325
- var s = '';
11356
+ let s = '';
11326
11357
 
11327
11358
  if (alasql.fn[this.funcid]) s += this.funcid;
11328
11359
  else if (alasql.aggr[this.funcid]) s += this.funcid;
@@ -11344,10 +11375,10 @@ yy.FuncValue.prototype.toString = function () {
11344
11375
  };
11345
11376
 
11346
11377
  yy.FuncValue.prototype.execute = function (databaseid, params, cb) {
11347
- var res = 1;
11378
+ let res = 1;
11348
11379
  alasql.precompile(this, databaseid, params); // Precompile queries
11349
11380
 
11350
- var expr = new Function('params,alasql', 'var y;return ' + this.toJS('', '', null));
11381
+ let expr = new Function('params,alasql', 'var y;return ' + this.toJS('', '', null));
11351
11382
  expr(params, alasql);
11352
11383
  if (cb) res = cb(res);
11353
11384
  return res;
@@ -11426,7 +11457,7 @@ stdlib.EXP = function (a) {
11426
11457
  };
11427
11458
 
11428
11459
  stdlib.IIF = function (a, b, c) {
11429
- if (arguments.length == 3) {
11460
+ if (arguments.length === 3) {
11430
11461
  return '((' + a + ')?(' + b + '):(' + c + '))';
11431
11462
  } else {
11432
11463
  throw new Error('Number of arguments of IFF is not equals to 3');
@@ -16925,16 +16956,7 @@ alasql.into.XLSX = function (filename, opts, data, columns, cb) {
16925
16956
  // saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), '"'+filename+'"')
16926
16957
  // saveAs(new Blob([s2ab(wbout)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}), filename)
16927
16958
  // saveAs(new Blob([s2ab(wbout)],{type:"application/vnd.ms-excel"}), '"'+filename+'"');
16928
- if (isIE() == 9) {
16929
- throw new Error('Cannot save XLSX files in IE9. Please use XLS() export function');
16930
- // var URI = 'data:text/plain;charset=utf-8,';
16931
-
16932
- /** @todo Check if this code is required */
16933
-
16934
- // alert('ie9');
16935
- } else {
16936
- saveAs(new Blob([s2ab(wbout)], {type: 'application/octet-stream'}), filename);
16937
- }
16959
+ saveAs(new Blob([s2ab(wbout)], {type: 'application/octet-stream'}), filename);
16938
16960
  }
16939
16961
  }
16940
16962