alasql 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/alasql-echo.js +1 -1
- package/dist/alasql-prolog.js +2 -2
- package/dist/alasql-worker.js +2 -2
- package/dist/alasql-worker.min.js +1 -1
- package/dist/alasql.fs.js +1389 -1451
- package/dist/alasql.js +1667 -1721
- package/dist/alasql.min.js +40 -8
- package/package.json +7 -13
package/dist/alasql.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v2.2.
|
|
1
|
+
//! AlaSQL v2.2.2-develop-18f2d048 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 2.2.
|
|
4
|
+
@version 2.2.2-develop-18f2d048
|
|
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.2.
|
|
145
|
+
alasql.version = '2.2.2-develop-18f2d048';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -240,8 +240,8 @@ var $0 = $$.length - 1;
|
|
|
240
240
|
switch (yystate) {
|
|
241
241
|
case 1:
|
|
242
242
|
|
|
243
|
-
if (alasql.options.casesensitive) this.$ = $$[$0];
|
|
244
|
-
else this.$ = $$[$0].toLowerCase();
|
|
243
|
+
if (alasql.options.casesensitive) this.$ = $$[$0];
|
|
244
|
+
else this.$ = $$[$0].toLowerCase();
|
|
245
245
|
|
|
246
246
|
break;
|
|
247
247
|
case 2:
|
|
@@ -273,13 +273,13 @@ case 11:
|
|
|
273
273
|
break;
|
|
274
274
|
case 12:
|
|
275
275
|
|
|
276
|
-
this.$ = $$[$0];
|
|
276
|
+
this.$ = $$[$0];
|
|
277
277
|
|
|
278
|
-
// TODO combine exists and queries
|
|
279
|
-
if(yy.exists) this.$.exists = yy.exists;
|
|
280
|
-
delete yy.exists;
|
|
281
|
-
if(yy.queries) this.$.queries = yy.queries;
|
|
282
|
-
delete yy.queries;
|
|
278
|
+
// TODO combine exists and queries
|
|
279
|
+
if(yy.exists) this.$.exists = yy.exists;
|
|
280
|
+
delete yy.exists;
|
|
281
|
+
if(yy.queries) this.$.queries = yy.queries;
|
|
282
|
+
delete yy.queries;
|
|
283
283
|
|
|
284
284
|
break;
|
|
285
285
|
case 13: case 162: case 172: case 237: case 238: case 240: case 248: case 250: case 259: case 270: case 273: case 379: case 495: case 505: case 507: case 519: case 525: case 526: case 571:
|
|
@@ -296,20 +296,20 @@ case 71:
|
|
|
296
296
|
break;
|
|
297
297
|
case 72:
|
|
298
298
|
|
|
299
|
-
yy.extend(this.$,$$[$0-9]); yy.extend(this.$,$$[$0-8]); yy.extend(this.$,$$[$0-7]); yy.extend(this.$,$$[$0-6]);
|
|
300
|
-
yy.extend(this.$,$$[$0-5]); yy.extend(this.$,$$[$0-4]);yy.extend(this.$,$$[$0-3]);
|
|
301
|
-
yy.extend(this.$,$$[$0-2]); yy.extend(this.$,$$[$0-1]); yy.extend(this.$,$$[$0]);
|
|
302
|
-
this.$ = $$[$0-9];
|
|
303
|
-
/* if(yy.exists) this.$.exists = yy.exists;
|
|
304
|
-
delete yy.exists;
|
|
305
|
-
if(yy.queries) this.$.queries = yy.queries;
|
|
306
|
-
delete yy.queries;
|
|
299
|
+
yy.extend(this.$,$$[$0-9]); yy.extend(this.$,$$[$0-8]); yy.extend(this.$,$$[$0-7]); yy.extend(this.$,$$[$0-6]);
|
|
300
|
+
yy.extend(this.$,$$[$0-5]); yy.extend(this.$,$$[$0-4]);yy.extend(this.$,$$[$0-3]);
|
|
301
|
+
yy.extend(this.$,$$[$0-2]); yy.extend(this.$,$$[$0-1]); yy.extend(this.$,$$[$0]);
|
|
302
|
+
this.$ = $$[$0-9];
|
|
303
|
+
/* if(yy.exists) this.$.exists = yy.exists;
|
|
304
|
+
delete yy.exists;
|
|
305
|
+
if(yy.queries) this.$.queries = yy.queries;
|
|
306
|
+
delete yy.queries;
|
|
307
307
|
*/
|
|
308
308
|
break;
|
|
309
309
|
case 73:
|
|
310
310
|
|
|
311
|
-
this.$ = new yy.Search({selectors:$$[$0-2], from:$$[$0]});
|
|
312
|
-
yy.extend(this.$,$$[$0-1]);
|
|
311
|
+
this.$ = new yy.Search({selectors:$$[$0-2], from:$$[$0]});
|
|
312
|
+
yy.extend(this.$,$$[$0-1]);
|
|
313
313
|
|
|
314
314
|
break;
|
|
315
315
|
case 74:
|
|
@@ -347,9 +347,9 @@ case 91:
|
|
|
347
347
|
break;
|
|
348
348
|
case 92:
|
|
349
349
|
|
|
350
|
-
var dir = $$[$0-1];
|
|
351
|
-
if(!dir) dir = 'ASC';
|
|
352
|
-
this.$ = {srchid:"ORDERBY", args: [{expression: new yy.Column({columnid:'_'}), direction:dir}]};
|
|
350
|
+
var dir = $$[$0-1];
|
|
351
|
+
if(!dir) dir = 'ASC';
|
|
352
|
+
this.$ = {srchid:"ORDERBY", args: [{expression: new yy.Column({columnid:'_'}), direction:dir}]};
|
|
353
353
|
|
|
354
354
|
break;
|
|
355
355
|
case 93:
|
|
@@ -516,11 +516,11 @@ case 150:
|
|
|
516
516
|
break;
|
|
517
517
|
case 151:
|
|
518
518
|
|
|
519
|
-
if(!$$[$0]) {
|
|
520
|
-
this.$ = new yy.Select({columns:[new yy.Column({columnid:'_',})], modifier:'COLUMN'});
|
|
521
|
-
} else {
|
|
522
|
-
this.$ = new yy.Select({ columns:$$[$0] }); yy.extend(this.$, $$[$0-2]);yy.extend(this.$, $$[$0-1]);
|
|
523
|
-
}
|
|
519
|
+
if(!$$[$0]) {
|
|
520
|
+
this.$ = new yy.Select({columns:[new yy.Column({columnid:'_',})], modifier:'COLUMN'});
|
|
521
|
+
} else {
|
|
522
|
+
this.$ = new yy.Select({ columns:$$[$0] }); yy.extend(this.$, $$[$0-2]);yy.extend(this.$, $$[$0-1]);
|
|
523
|
+
}
|
|
524
524
|
|
|
525
525
|
break;
|
|
526
526
|
case 152:
|
|
@@ -561,17 +561,17 @@ this.$ = {into: $$[$0]}
|
|
|
561
561
|
break;
|
|
562
562
|
case 168:
|
|
563
563
|
|
|
564
|
-
var s = $$[$0];
|
|
565
|
-
s = s.substr(1,s.length-2);
|
|
566
|
-
var x3 = s.substr(-3).toUpperCase();
|
|
567
|
-
var x4 = s.substr(-4).toUpperCase();
|
|
568
|
-
if(s[0] == '#') {
|
|
569
|
-
this.$ = {into: new yy.FuncValue({funcid: 'HTML', args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]})};
|
|
570
|
-
} else if(x3=='XLS' || x3 == 'CSV' || x3=='TAB') {
|
|
571
|
-
this.$ = {into: new yy.FuncValue({funcid: x3, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]})};
|
|
572
|
-
} else if(x4=='XLSX' || x4 == 'JSON') {
|
|
573
|
-
this.$ = {into: new yy.FuncValue({funcid: x4, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]})};
|
|
574
|
-
}
|
|
564
|
+
var s = $$[$0];
|
|
565
|
+
s = s.substr(1,s.length-2);
|
|
566
|
+
var x3 = s.substr(-3).toUpperCase();
|
|
567
|
+
var x4 = s.substr(-4).toUpperCase();
|
|
568
|
+
if(s[0] == '#') {
|
|
569
|
+
this.$ = {into: new yy.FuncValue({funcid: 'HTML', args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]})};
|
|
570
|
+
} else if(x3=='XLS' || x3 == 'CSV' || x3=='TAB') {
|
|
571
|
+
this.$ = {into: new yy.FuncValue({funcid: x3, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]})};
|
|
572
|
+
} else if(x4=='XLSX' || x4 == 'JSON') {
|
|
573
|
+
this.$ = {into: new yy.FuncValue({funcid: x4, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]})};
|
|
574
|
+
}
|
|
575
575
|
|
|
576
576
|
break;
|
|
577
577
|
case 169:
|
|
@@ -633,30 +633,30 @@ case 193:
|
|
|
633
633
|
break;
|
|
634
634
|
case 200:
|
|
635
635
|
|
|
636
|
-
var s = $$[$0];
|
|
637
|
-
s = s.substr(1,s.length-2);
|
|
638
|
-
var x3 = s.substr(-3).toUpperCase();
|
|
639
|
-
var x4 = s.substr(-4).toUpperCase();
|
|
640
|
-
var r;
|
|
641
|
-
if(s[0] == '#') {
|
|
642
|
-
r = new yy.FuncValue({funcid: 'HTML', args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]});
|
|
643
|
-
} else if(x3=='XLS' || x3 == 'CSV' || x3=='TAB') {
|
|
644
|
-
r = new yy.FuncValue({funcid: x3, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]});
|
|
645
|
-
} else if(x4=='XLSX' || x4 == 'JSON') {
|
|
646
|
-
r = new yy.FuncValue({funcid: x4, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]});
|
|
647
|
-
} else {
|
|
648
|
-
throw new Error('Unknown string in FROM clause');
|
|
649
|
-
};
|
|
650
|
-
this.$ = r;
|
|
636
|
+
var s = $$[$0];
|
|
637
|
+
s = s.substr(1,s.length-2);
|
|
638
|
+
var x3 = s.substr(-3).toUpperCase();
|
|
639
|
+
var x4 = s.substr(-4).toUpperCase();
|
|
640
|
+
var r;
|
|
641
|
+
if(s[0] == '#') {
|
|
642
|
+
r = new yy.FuncValue({funcid: 'HTML', args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]});
|
|
643
|
+
} else if(x3=='XLS' || x3 == 'CSV' || x3=='TAB') {
|
|
644
|
+
r = new yy.FuncValue({funcid: x3, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]});
|
|
645
|
+
} else if(x4=='XLSX' || x4 == 'JSON') {
|
|
646
|
+
r = new yy.FuncValue({funcid: x4, args:[new yy.StringValue({value: s}), new yy.Json({value:{headers:true}})]});
|
|
647
|
+
} else {
|
|
648
|
+
throw new Error('Unknown string in FROM clause');
|
|
649
|
+
};
|
|
650
|
+
this.$ = r;
|
|
651
651
|
|
|
652
652
|
break;
|
|
653
653
|
case 201:
|
|
654
654
|
|
|
655
|
-
if($$[$0-2] == 'INFORMATION_SCHEMA') {
|
|
656
|
-
this.$ = new yy.FuncValue({funcid: $$[$0-2], args:[new yy.StringValue({value:$$[$0]})]});
|
|
657
|
-
} else {
|
|
658
|
-
this.$ = new yy.Table({databaseid: $$[$0-2], tableid:$$[$0]});
|
|
659
|
-
}
|
|
655
|
+
if($$[$0-2] == 'INFORMATION_SCHEMA') {
|
|
656
|
+
this.$ = new yy.FuncValue({funcid: $$[$0-2], args:[new yy.StringValue({value:$$[$0]})]});
|
|
657
|
+
} else {
|
|
658
|
+
this.$ = new yy.Table({databaseid: $$[$0-2], tableid:$$[$0]});
|
|
659
|
+
}
|
|
660
660
|
|
|
661
661
|
break;
|
|
662
662
|
case 202:
|
|
@@ -856,10 +856,10 @@ case 306:
|
|
|
856
856
|
break;
|
|
857
857
|
case 309: case 310: case 311:
|
|
858
858
|
|
|
859
|
-
if(!yy.queries) yy.queries = [];
|
|
860
|
-
yy.queries.push($$[$0-1]);
|
|
861
|
-
$$[$0-1].queriesidx = yy.queries.length;
|
|
862
|
-
this.$ = $$[$0-1];
|
|
859
|
+
if(!yy.queries) yy.queries = [];
|
|
860
|
+
yy.queries.push($$[$0-1]);
|
|
861
|
+
$$[$0-1].queriesidx = yy.queries.length;
|
|
862
|
+
this.$ = $$[$0-1];
|
|
863
863
|
|
|
864
864
|
break;
|
|
865
865
|
case 312:
|
|
@@ -900,18 +900,18 @@ case 329:
|
|
|
900
900
|
break;
|
|
901
901
|
case 330:
|
|
902
902
|
|
|
903
|
-
if($$[$0-2].length > 1 && ($$[$0-4].toUpperCase() == 'MAX' || $$[$0-4].toUpperCase() == 'MIN')) {
|
|
904
|
-
this.$ = new yy.FuncValue({funcid:$$[$0-4],args:$$[$0-2]});
|
|
905
|
-
} else {
|
|
906
|
-
this.$ = new yy.AggrValue({aggregatorid: $$[$0-4].toUpperCase(), expression: $$[$0-2].pop(), over:$$[$0]});
|
|
907
|
-
}
|
|
903
|
+
if($$[$0-2].length > 1 && ($$[$0-4].toUpperCase() == 'MAX' || $$[$0-4].toUpperCase() == 'MIN')) {
|
|
904
|
+
this.$ = new yy.FuncValue({funcid:$$[$0-4],args:$$[$0-2]});
|
|
905
|
+
} else {
|
|
906
|
+
this.$ = new yy.AggrValue({aggregatorid: $$[$0-4].toUpperCase(), expression: $$[$0-2].pop(), over:$$[$0]});
|
|
907
|
+
}
|
|
908
908
|
|
|
909
909
|
break;
|
|
910
910
|
case 331:
|
|
911
911
|
this.$ = new yy.AggrValue({aggregatorid: $$[$0-5].toUpperCase(), expression: $$[$0-2], distinct:true, over:$$[$0]});
|
|
912
912
|
break;
|
|
913
913
|
case 332:
|
|
914
|
-
this.$ = new yy.AggrValue({aggregatorid: $$[$0-5].toUpperCase(), expression: $$[$0-2],
|
|
914
|
+
this.$ = new yy.AggrValue({aggregatorid: $$[$0-5].toUpperCase(), expression: $$[$0-2],
|
|
915
915
|
over:$$[$0]});
|
|
916
916
|
break;
|
|
917
917
|
case 334: case 335:
|
|
@@ -955,16 +955,16 @@ case 347:
|
|
|
955
955
|
break;
|
|
956
956
|
case 348:
|
|
957
957
|
|
|
958
|
-
var funcid = $$[$0-4];
|
|
959
|
-
var exprlist = $$[$0-1];
|
|
960
|
-
if(exprlist.length > 1 && (funcid.toUpperCase() == 'MIN' || funcid.toUpperCase() == 'MAX')) {
|
|
961
|
-
this.$ = new yy.FuncValue({funcid: funcid, args: exprlist});
|
|
962
|
-
} else if(alasql.aggr[$$[$0-4]]) {
|
|
963
|
-
this.$ = new yy.AggrValue({aggregatorid: 'REDUCE',
|
|
964
|
-
funcid: funcid, expression: exprlist.pop(),distinct:($$[$0-2]=='DISTINCT') });
|
|
965
|
-
} else {
|
|
966
|
-
this.$ = new yy.FuncValue({funcid: funcid, args: exprlist});
|
|
967
|
-
};
|
|
958
|
+
var funcid = $$[$0-4];
|
|
959
|
+
var exprlist = $$[$0-1];
|
|
960
|
+
if(exprlist.length > 1 && (funcid.toUpperCase() == 'MIN' || funcid.toUpperCase() == 'MAX')) {
|
|
961
|
+
this.$ = new yy.FuncValue({funcid: funcid, args: exprlist});
|
|
962
|
+
} else if(alasql.aggr[$$[$0-4]]) {
|
|
963
|
+
this.$ = new yy.AggrValue({aggregatorid: 'REDUCE',
|
|
964
|
+
funcid: funcid, expression: exprlist.pop(),distinct:($$[$0-2]=='DISTINCT') });
|
|
965
|
+
} else {
|
|
966
|
+
this.$ = new yy.FuncValue({funcid: funcid, args: exprlist});
|
|
967
|
+
};
|
|
968
968
|
|
|
969
969
|
break;
|
|
970
970
|
case 349:
|
|
@@ -1020,9 +1020,9 @@ case 366:
|
|
|
1020
1020
|
break;
|
|
1021
1021
|
case 367:
|
|
1022
1022
|
|
|
1023
|
-
if(!yy.exists) yy.exists = [];
|
|
1024
|
-
this.$ = new yy.ExistsValue({value:$$[$0-1], existsidx:yy.exists.length});
|
|
1025
|
-
yy.exists.push($$[$0-1]);
|
|
1023
|
+
if(!yy.exists) yy.exists = [];
|
|
1024
|
+
this.$ = new yy.ExistsValue({value:$$[$0-1], existsidx:yy.exists.length});
|
|
1025
|
+
yy.exists.push($$[$0-1]);
|
|
1026
1026
|
|
|
1027
1027
|
break;
|
|
1028
1028
|
case 368:
|
|
@@ -1033,14 +1033,14 @@ case 369: case 370:
|
|
|
1033
1033
|
break;
|
|
1034
1034
|
case 371:
|
|
1035
1035
|
|
|
1036
|
-
if(typeof yy.question == 'undefined') yy.question = 0;
|
|
1037
|
-
this.$ = new yy.ParamValue({param: yy.question++});
|
|
1036
|
+
if(typeof yy.question == 'undefined') yy.question = 0;
|
|
1037
|
+
this.$ = new yy.ParamValue({param: yy.question++});
|
|
1038
1038
|
|
|
1039
1039
|
break;
|
|
1040
1040
|
case 372:
|
|
1041
1041
|
|
|
1042
|
-
if(typeof yy.question == 'undefined') yy.question = 0;
|
|
1043
|
-
this.$ = new yy.ParamValue({param: yy.question++, array:true});
|
|
1042
|
+
if(typeof yy.question == 'undefined') yy.question = 0;
|
|
1043
|
+
this.$ = new yy.ParamValue({param: yy.question++, array:true});
|
|
1044
1044
|
|
|
1045
1045
|
break;
|
|
1046
1046
|
case 373:
|
|
@@ -1150,43 +1150,43 @@ case 415:
|
|
|
1150
1150
|
break;
|
|
1151
1151
|
case 416:
|
|
1152
1152
|
|
|
1153
|
-
if(!yy.queries) yy.queries = [];
|
|
1154
|
-
this.$ = new yy.Op({left:$$[$0-5], op:$$[$0-4] , allsome:$$[$0-3], right:$$[$0-1], queriesidx: yy.queries.length});
|
|
1155
|
-
yy.queries.push($$[$0-1]);
|
|
1153
|
+
if(!yy.queries) yy.queries = [];
|
|
1154
|
+
this.$ = new yy.Op({left:$$[$0-5], op:$$[$0-4] , allsome:$$[$0-3], right:$$[$0-1], queriesidx: yy.queries.length});
|
|
1155
|
+
yy.queries.push($$[$0-1]);
|
|
1156
1156
|
|
|
1157
1157
|
break;
|
|
1158
1158
|
case 417:
|
|
1159
1159
|
|
|
1160
|
-
this.$ = new yy.Op({left:$$[$0-5], op:$$[$0-4] , allsome:$$[$0-3], right:$$[$0-1]});
|
|
1160
|
+
this.$ = new yy.Op({left:$$[$0-5], op:$$[$0-4] , allsome:$$[$0-3], right:$$[$0-1]});
|
|
1161
1161
|
|
|
1162
1162
|
break;
|
|
1163
1163
|
case 418:
|
|
1164
1164
|
|
|
1165
|
-
if($$[$0-2].op == 'BETWEEN1') {
|
|
1166
|
-
|
|
1167
|
-
if($$[$0-2].left.op == 'AND') {
|
|
1168
|
-
this.$ = new yy.Op({left:$$[$0-2].left.left,op:'AND',right:
|
|
1169
|
-
new yy.Op({left:$$[$0-2].left.right, op:'BETWEEN',
|
|
1170
|
-
right1:$$[$0-2].right, right2:$$[$0]})
|
|
1171
|
-
});
|
|
1172
|
-
} else {
|
|
1173
|
-
this.$ = new yy.Op({left:$$[$0-2].left, op:'BETWEEN',
|
|
1174
|
-
right1:$$[$0-2].right, right2:$$[$0]});
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
} else if($$[$0-2].op == 'NOT BETWEEN1') {
|
|
1178
|
-
if($$[$0-2].left.op == 'AND') {
|
|
1179
|
-
this.$ = new yy.Op({left:$$[$0-2].left.left,op:'AND',right:
|
|
1180
|
-
new yy.Op({left:$$[$0-2].left.right, op:'NOT BETWEEN',
|
|
1181
|
-
right1:$$[$0-2].right, right2:$$[$0]})
|
|
1182
|
-
});
|
|
1183
|
-
} else {
|
|
1184
|
-
this.$ = new yy.Op({left:$$[$0-2].left, op:'NOT BETWEEN',
|
|
1185
|
-
right1:$$[$0-2].right, right2:$$[$0]});
|
|
1186
|
-
}
|
|
1187
|
-
} else {
|
|
1188
|
-
this.$ = new yy.Op({left:$$[$0-2], op:'AND', right:$$[$0]});
|
|
1189
|
-
}
|
|
1165
|
+
if($$[$0-2].op == 'BETWEEN1') {
|
|
1166
|
+
|
|
1167
|
+
if($$[$0-2].left.op == 'AND') {
|
|
1168
|
+
this.$ = new yy.Op({left:$$[$0-2].left.left,op:'AND',right:
|
|
1169
|
+
new yy.Op({left:$$[$0-2].left.right, op:'BETWEEN',
|
|
1170
|
+
right1:$$[$0-2].right, right2:$$[$0]})
|
|
1171
|
+
});
|
|
1172
|
+
} else {
|
|
1173
|
+
this.$ = new yy.Op({left:$$[$0-2].left, op:'BETWEEN',
|
|
1174
|
+
right1:$$[$0-2].right, right2:$$[$0]});
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
} else if($$[$0-2].op == 'NOT BETWEEN1') {
|
|
1178
|
+
if($$[$0-2].left.op == 'AND') {
|
|
1179
|
+
this.$ = new yy.Op({left:$$[$0-2].left.left,op:'AND',right:
|
|
1180
|
+
new yy.Op({left:$$[$0-2].left.right, op:'NOT BETWEEN',
|
|
1181
|
+
right1:$$[$0-2].right, right2:$$[$0]})
|
|
1182
|
+
});
|
|
1183
|
+
} else {
|
|
1184
|
+
this.$ = new yy.Op({left:$$[$0-2].left, op:'NOT BETWEEN',
|
|
1185
|
+
right1:$$[$0-2].right, right2:$$[$0]});
|
|
1186
|
+
}
|
|
1187
|
+
} else {
|
|
1188
|
+
this.$ = new yy.Op({left:$$[$0-2], op:'AND', right:$$[$0]});
|
|
1189
|
+
}
|
|
1190
1190
|
|
|
1191
1191
|
break;
|
|
1192
1192
|
case 419:
|
|
@@ -1212,16 +1212,16 @@ case 425:
|
|
|
1212
1212
|
break;
|
|
1213
1213
|
case 426:
|
|
1214
1214
|
|
|
1215
|
-
if(!yy.queries) yy.queries = [];
|
|
1216
|
-
this.$ = new yy.Op({left: $$[$0-4], op:'IN', right:$$[$0-1], queriesidx: yy.queries.length});
|
|
1217
|
-
yy.queries.push($$[$0-1]);
|
|
1215
|
+
if(!yy.queries) yy.queries = [];
|
|
1216
|
+
this.$ = new yy.Op({left: $$[$0-4], op:'IN', right:$$[$0-1], queriesidx: yy.queries.length});
|
|
1217
|
+
yy.queries.push($$[$0-1]);
|
|
1218
1218
|
|
|
1219
1219
|
break;
|
|
1220
1220
|
case 427:
|
|
1221
1221
|
|
|
1222
|
-
if(!yy.queries) yy.queries = [];
|
|
1223
|
-
this.$ = new yy.Op({left: $$[$0-5], op:'NOT IN', right:$$[$0-1], queriesidx: yy.queries.length});
|
|
1224
|
-
yy.queries.push($$[$0-1]);
|
|
1222
|
+
if(!yy.queries) yy.queries = [];
|
|
1223
|
+
this.$ = new yy.Op({left: $$[$0-5], op:'NOT IN', right:$$[$0-1], queriesidx: yy.queries.length});
|
|
1224
|
+
yy.queries.push($$[$0-1]);
|
|
1225
1225
|
|
|
1226
1226
|
break;
|
|
1227
1227
|
case 428:
|
|
@@ -1244,17 +1244,17 @@ case 433: case 435:
|
|
|
1244
1244
|
break;
|
|
1245
1245
|
case 436:
|
|
1246
1246
|
|
|
1247
|
-
/* var expr = $$[$0];
|
|
1248
|
-
if(expr.left && expr.left.op == 'AND') {
|
|
1249
|
-
this.$ = new yy.Op({left:new yy.Op({left:$$[$0-2], op:'BETWEEN', right:expr.left}), op:'AND', right:expr.right });
|
|
1250
|
-
} else {
|
|
1251
|
-
*/
|
|
1252
|
-
this.$ = new yy.Op({left:$$[$0-2], op:'BETWEEN1', right:$$[$0] });
|
|
1247
|
+
/* var expr = $$[$0];
|
|
1248
|
+
if(expr.left && expr.left.op == 'AND') {
|
|
1249
|
+
this.$ = new yy.Op({left:new yy.Op({left:$$[$0-2], op:'BETWEEN', right:expr.left}), op:'AND', right:expr.right });
|
|
1250
|
+
} else {
|
|
1251
|
+
*/
|
|
1252
|
+
this.$ = new yy.Op({left:$$[$0-2], op:'BETWEEN1', right:$$[$0] });
|
|
1253
1253
|
|
|
1254
1254
|
break;
|
|
1255
1255
|
case 437:
|
|
1256
1256
|
|
|
1257
|
-
this.$ = new yy.Op({left:$$[$0-2], op:'NOT BETWEEN1', right:$$[$0] });
|
|
1257
|
+
this.$ = new yy.Op({left:$$[$0-2], op:'NOT BETWEEN1', right:$$[$0] });
|
|
1258
1258
|
|
|
1259
1259
|
break;
|
|
1260
1260
|
case 438:
|
|
@@ -1262,14 +1262,14 @@ case 438:
|
|
|
1262
1262
|
break;
|
|
1263
1263
|
case 439:
|
|
1264
1264
|
|
|
1265
|
-
this.$ = new yy.Op({
|
|
1266
|
-
op:'IS',
|
|
1267
|
-
left:$$[$0-2],
|
|
1268
|
-
right: new yy.UniOp({
|
|
1269
|
-
op:'NOT',
|
|
1270
|
-
right:new yy.NullValue({value:undefined})
|
|
1271
|
-
})
|
|
1272
|
-
});
|
|
1265
|
+
this.$ = new yy.Op({
|
|
1266
|
+
op:'IS',
|
|
1267
|
+
left:$$[$0-2],
|
|
1268
|
+
right: new yy.UniOp({
|
|
1269
|
+
op:'NOT',
|
|
1270
|
+
right:new yy.NullValue({value:undefined})
|
|
1271
|
+
})
|
|
1272
|
+
});
|
|
1273
1273
|
|
|
1274
1274
|
break;
|
|
1275
1275
|
case 440:
|
|
@@ -1349,24 +1349,24 @@ this.$ = $$[$0-2]; $$[$0-2].push($$[$0])
|
|
|
1349
1349
|
break;
|
|
1350
1350
|
case 493:
|
|
1351
1351
|
|
|
1352
|
-
this.$ = new yy.CreateTable({table:$$[$0-4]});
|
|
1353
|
-
yy.extend(this.$,$$[$0-7]);
|
|
1354
|
-
yy.extend(this.$,$$[$0-6]);
|
|
1355
|
-
yy.extend(this.$,$$[$0-5]);
|
|
1356
|
-
yy.extend(this.$,$$[$0-2]);
|
|
1357
|
-
yy.extend(this.$,$$[$0]);
|
|
1352
|
+
this.$ = new yy.CreateTable({table:$$[$0-4]});
|
|
1353
|
+
yy.extend(this.$,$$[$0-7]);
|
|
1354
|
+
yy.extend(this.$,$$[$0-6]);
|
|
1355
|
+
yy.extend(this.$,$$[$0-5]);
|
|
1356
|
+
yy.extend(this.$,$$[$0-2]);
|
|
1357
|
+
yy.extend(this.$,$$[$0]);
|
|
1358
1358
|
|
|
1359
1359
|
break;
|
|
1360
1360
|
case 494:
|
|
1361
1361
|
|
|
1362
|
-
this.$ = new yy.CreateTable({table:$$[$0]});
|
|
1363
|
-
yy.extend(this.$,$$[$0-3]);
|
|
1364
|
-
yy.extend(this.$,$$[$0-2]);
|
|
1365
|
-
yy.extend(this.$,$$[$0-1]);
|
|
1362
|
+
this.$ = new yy.CreateTable({table:$$[$0]});
|
|
1363
|
+
yy.extend(this.$,$$[$0-3]);
|
|
1364
|
+
yy.extend(this.$,$$[$0-2]);
|
|
1365
|
+
yy.extend(this.$,$$[$0-1]);
|
|
1366
1366
|
|
|
1367
1367
|
break;
|
|
1368
1368
|
case 496:
|
|
1369
|
-
this.$ = {
|
|
1369
|
+
this.$ = {class:true};
|
|
1370
1370
|
break;
|
|
1371
1371
|
case 506:
|
|
1372
1372
|
this.$ = {temporary:true};
|
|
@@ -1400,7 +1400,7 @@ case 523:
|
|
|
1400
1400
|
break;
|
|
1401
1401
|
case 529:
|
|
1402
1402
|
|
|
1403
|
-
this.$ = {type: 'UNIQUE', columns: $$[$0-1], clustered:($$[$0-3]+'').toUpperCase()};
|
|
1403
|
+
this.$ = {type: 'UNIQUE', columns: $$[$0-1], clustered:($$[$0-3]+'').toUpperCase()};
|
|
1404
1404
|
|
|
1405
1405
|
break;
|
|
1406
1406
|
case 538:
|
|
@@ -1435,7 +1435,7 @@ this.$ = undefined
|
|
|
1435
1435
|
break;
|
|
1436
1436
|
case 551:
|
|
1437
1437
|
|
|
1438
|
-
yy.extend($$[$0-1],$$[$0]); this.$ = $$[$0-1];
|
|
1438
|
+
yy.extend($$[$0-1],$$[$0]); this.$ = $$[$0-1];
|
|
1439
1439
|
|
|
1440
1440
|
break;
|
|
1441
1441
|
case 554:
|
|
@@ -1457,7 +1457,7 @@ case 560:
|
|
|
1457
1457
|
this.$ = {"default":$$[$0-1]};
|
|
1458
1458
|
break;
|
|
1459
1459
|
case 562:
|
|
1460
|
-
this.$ = {
|
|
1460
|
+
this.$ = {null:true};
|
|
1461
1461
|
break;
|
|
1462
1462
|
case 563:
|
|
1463
1463
|
this.$ = {notnull:true};
|
|
@@ -1523,7 +1523,7 @@ case 586:
|
|
|
1523
1523
|
this.$ = new yy.CreateDatabase({engineid:$$[$0-7].toUpperCase(), databaseid:$$[$0-4], args:$$[$0-2], as:$$[$0] }); yy.extend(this.$,$$[$0-5]);
|
|
1524
1524
|
break;
|
|
1525
1525
|
case 587:
|
|
1526
|
-
this.$ = new yy.CreateDatabase({engineid:$$[$0-4].toUpperCase(),
|
|
1526
|
+
this.$ = new yy.CreateDatabase({engineid:$$[$0-4].toUpperCase(),
|
|
1527
1527
|
as:$$[$0], args:[$$[$0-1]] }); yy.extend(this.$,$$[$0-2]);
|
|
1528
1528
|
break;
|
|
1529
1529
|
case 588:
|
|
@@ -1591,16 +1591,16 @@ case 611:
|
|
|
1591
1591
|
break;
|
|
1592
1592
|
case 612:
|
|
1593
1593
|
|
|
1594
|
-
this.$ = new yy.CreateTable({table:$$[$0-6],view:true,select:$$[$0-1],viewcolumns:$$[$0-4]});
|
|
1595
|
-
yy.extend(this.$,$$[$0-9]);
|
|
1596
|
-
yy.extend(this.$,$$[$0-7]);
|
|
1594
|
+
this.$ = new yy.CreateTable({table:$$[$0-6],view:true,select:$$[$0-1],viewcolumns:$$[$0-4]});
|
|
1595
|
+
yy.extend(this.$,$$[$0-9]);
|
|
1596
|
+
yy.extend(this.$,$$[$0-7]);
|
|
1597
1597
|
|
|
1598
1598
|
break;
|
|
1599
1599
|
case 613:
|
|
1600
1600
|
|
|
1601
|
-
this.$ = new yy.CreateTable({table:$$[$0-3],view:true,select:$$[$0-1]});
|
|
1602
|
-
yy.extend(this.$,$$[$0-6]);
|
|
1603
|
-
yy.extend(this.$,$$[$0-4]);
|
|
1601
|
+
this.$ = new yy.CreateTable({table:$$[$0-3],view:true,select:$$[$0-1]});
|
|
1602
|
+
yy.extend(this.$,$$[$0-6]);
|
|
1603
|
+
yy.extend(this.$,$$[$0-4]);
|
|
1604
1604
|
|
|
1605
1605
|
break;
|
|
1606
1606
|
case 617:
|
|
@@ -1688,25 +1688,25 @@ case 671:
|
|
|
1688
1688
|
this.$ = new yy.BeginTransaction();
|
|
1689
1689
|
break;
|
|
1690
1690
|
case 672:
|
|
1691
|
-
this.$ = new yy.If({expression:$$[$0-2],thenstat:$$[$0-1], elsestat:$$[$0]});
|
|
1692
|
-
if($$[$0-1].exists) this.$.exists = $$[$0-1].exists;
|
|
1693
|
-
if($$[$0-1].queries) this.$.queries = $$[$0-1].queries;
|
|
1691
|
+
this.$ = new yy.If({expression:$$[$0-2],thenstat:$$[$0-1], elsestat:$$[$0]});
|
|
1692
|
+
if($$[$0-1].exists) this.$.exists = $$[$0-1].exists;
|
|
1693
|
+
if($$[$0-1].queries) this.$.queries = $$[$0-1].queries;
|
|
1694
1694
|
|
|
1695
1695
|
break;
|
|
1696
1696
|
case 673:
|
|
1697
1697
|
|
|
1698
|
-
this.$ = new yy.If({expression:$$[$0-1],thenstat:$$[$0]});
|
|
1699
|
-
if($$[$0].exists) this.$.exists = $$[$0].exists;
|
|
1700
|
-
if($$[$0].queries) this.$.queries = $$[$0].queries;
|
|
1698
|
+
this.$ = new yy.If({expression:$$[$0-1],thenstat:$$[$0]});
|
|
1699
|
+
if($$[$0].exists) this.$.exists = $$[$0].exists;
|
|
1700
|
+
if($$[$0].queries) this.$.queries = $$[$0].queries;
|
|
1701
1701
|
|
|
1702
1702
|
break;
|
|
1703
1703
|
case 674:
|
|
1704
1704
|
this.$ = $$[$0];
|
|
1705
1705
|
break;
|
|
1706
1706
|
case 675:
|
|
1707
|
-
this.$ = new yy.While({expression:$$[$0-1],loopstat:$$[$0]});
|
|
1708
|
-
if($$[$0].exists) this.$.exists = $$[$0].exists;
|
|
1709
|
-
if($$[$0].queries) this.$.queries = $$[$0].queries;
|
|
1707
|
+
this.$ = new yy.While({expression:$$[$0-1],loopstat:$$[$0]});
|
|
1708
|
+
if($$[$0].exists) this.$.exists = $$[$0].exists;
|
|
1709
|
+
if($$[$0].queries) this.$.queries = $$[$0].queries;
|
|
1710
1710
|
|
|
1711
1711
|
break;
|
|
1712
1712
|
case 676:
|
|
@@ -1756,9 +1756,9 @@ case 697:
|
|
|
1756
1756
|
break;
|
|
1757
1757
|
case 698:
|
|
1758
1758
|
|
|
1759
|
-
this.$ = new yy.Merge(); yy.extend(this.$,$$[$0-4]); yy.extend(this.$,$$[$0-3]);
|
|
1760
|
-
yy.extend(this.$,$$[$0-2]);
|
|
1761
|
-
yy.extend(this.$,{matches:$$[$0-1]});yy.extend(this.$,$$[$0]);
|
|
1759
|
+
this.$ = new yy.Merge(); yy.extend(this.$,$$[$0-4]); yy.extend(this.$,$$[$0-3]);
|
|
1760
|
+
yy.extend(this.$,$$[$0-2]);
|
|
1761
|
+
yy.extend(this.$,{matches:$$[$0-1]});yy.extend(this.$,$$[$0]);
|
|
1762
1762
|
|
|
1763
1763
|
break;
|
|
1764
1764
|
case 699: case 700:
|
|
@@ -1774,7 +1774,7 @@ case 708:
|
|
|
1774
1774
|
this.$ = {matched:true, expr: $$[$0-2], action:$$[$0]}
|
|
1775
1775
|
break;
|
|
1776
1776
|
case 709:
|
|
1777
|
-
this.$ = {
|
|
1777
|
+
this.$ = {delete:true};
|
|
1778
1778
|
break;
|
|
1779
1779
|
case 710:
|
|
1780
1780
|
this.$ = {update:$$[$0]};
|
|
@@ -1817,8 +1817,8 @@ case 725:
|
|
|
1817
1817
|
break;
|
|
1818
1818
|
case 726:
|
|
1819
1819
|
|
|
1820
|
-
this.$ = new yy.CreateVertex({
|
|
1821
|
-
yy.extend(this.$,$$[$0]);
|
|
1820
|
+
this.$ = new yy.CreateVertex({class:$$[$0-3],sharp:$$[$0-2], name:$$[$0-1]});
|
|
1821
|
+
yy.extend(this.$,$$[$0]);
|
|
1822
1822
|
|
|
1823
1823
|
break;
|
|
1824
1824
|
case 729:
|
|
@@ -1832,8 +1832,8 @@ case 731:
|
|
|
1832
1832
|
break;
|
|
1833
1833
|
case 732:
|
|
1834
1834
|
|
|
1835
|
-
this.$ = new yy.CreateEdge({from:$$[$0-3],to:$$[$0-1],name:$$[$0-5]});
|
|
1836
|
-
yy.extend(this.$,$$[$0]);
|
|
1835
|
+
this.$ = new yy.CreateEdge({from:$$[$0-3],to:$$[$0-1],name:$$[$0-5]});
|
|
1836
|
+
yy.extend(this.$,$$[$0]);
|
|
1837
1837
|
|
|
1838
1838
|
break;
|
|
1839
1839
|
case 733:
|
|
@@ -1844,29 +1844,29 @@ case 734:
|
|
|
1844
1844
|
break;
|
|
1845
1845
|
case 737:
|
|
1846
1846
|
|
|
1847
|
-
this.$ = $$[$0-2];
|
|
1848
|
-
if($$[$0-1]) this.$.json = new yy.Json({value:$$[$0-1]});
|
|
1849
|
-
if($$[$0]) this.$.as = $$[$0];
|
|
1847
|
+
this.$ = $$[$0-2];
|
|
1848
|
+
if($$[$0-1]) this.$.json = new yy.Json({value:$$[$0-1]});
|
|
1849
|
+
if($$[$0]) this.$.as = $$[$0];
|
|
1850
1850
|
|
|
1851
1851
|
break;
|
|
1852
1852
|
case 738:
|
|
1853
1853
|
|
|
1854
|
-
this.$ = {source:$$[$0-6], target: $$[$0]};
|
|
1855
|
-
if($$[$0-3]) this.$.json = new yy.Json({value:$$[$0-3]});
|
|
1856
|
-
if($$[$0-2]) this.$.as = $$[$0-2];
|
|
1857
|
-
yy.extend(this.$,$$[$0-4]);
|
|
1854
|
+
this.$ = {source:$$[$0-6], target: $$[$0]};
|
|
1855
|
+
if($$[$0-3]) this.$.json = new yy.Json({value:$$[$0-3]});
|
|
1856
|
+
if($$[$0-2]) this.$.as = $$[$0-2];
|
|
1857
|
+
yy.extend(this.$,$$[$0-4]);
|
|
1858
1858
|
|
|
1859
1859
|
break;
|
|
1860
1860
|
case 739:
|
|
1861
1861
|
|
|
1862
|
-
this.$ = {source:$$[$0-5], target: $$[$0]};
|
|
1863
|
-
if($$[$0-2]) this.$.json = new yy.Json({value:$$[$0-3]});
|
|
1864
|
-
if($$[$0-1]) this.$.as = $$[$0-2];
|
|
1862
|
+
this.$ = {source:$$[$0-5], target: $$[$0]};
|
|
1863
|
+
if($$[$0-2]) this.$.json = new yy.Json({value:$$[$0-3]});
|
|
1864
|
+
if($$[$0-1]) this.$.as = $$[$0-2];
|
|
1865
1865
|
|
|
1866
1866
|
break;
|
|
1867
1867
|
case 740:
|
|
1868
1868
|
|
|
1869
|
-
this.$ = {source:$$[$0-2], target: $$[$0]};
|
|
1869
|
+
this.$ = {source:$$[$0-2], target: $$[$0]};
|
|
1870
1870
|
|
|
1871
1871
|
break;
|
|
1872
1872
|
case 744:
|
|
@@ -1874,25 +1874,25 @@ case 744:
|
|
|
1874
1874
|
break;
|
|
1875
1875
|
case 747: case 748:
|
|
1876
1876
|
|
|
1877
|
-
var s3 = $$[$0-1];
|
|
1878
|
-
this.$ = {prop:$$[$0-3], sharp:$$[$0-2], name:(typeof s3 == 'undefined')?undefined:s3.substr(1,s3.length-2),
|
|
1877
|
+
var s3 = $$[$0-1];
|
|
1878
|
+
this.$ = {prop:$$[$0-3], sharp:$$[$0-2], name:(typeof s3 == 'undefined')?undefined:s3.substr(1,s3.length-2), class:$$[$0]};
|
|
1879
1879
|
|
|
1880
1880
|
break;
|
|
1881
1881
|
case 749:
|
|
1882
1882
|
|
|
1883
|
-
var s2 = $$[$0-1];
|
|
1884
|
-
this.$ = {sharp:$$[$0-2], name:(typeof s2 == 'undefined')?undefined:s2.substr(1,s2.length-2),
|
|
1883
|
+
var s2 = $$[$0-1];
|
|
1884
|
+
this.$ = {sharp:$$[$0-2], name:(typeof s2 == 'undefined')?undefined:s2.substr(1,s2.length-2), class:$$[$0]};
|
|
1885
1885
|
|
|
1886
1886
|
break;
|
|
1887
1887
|
case 750:
|
|
1888
1888
|
|
|
1889
|
-
var s1 = $$[$0-1];
|
|
1890
|
-
this.$ = {name:(typeof s1 == 'undefined')?undefined:s1.substr(1,s1.length-2),
|
|
1889
|
+
var s1 = $$[$0-1];
|
|
1890
|
+
this.$ = {name:(typeof s1 == 'undefined')?undefined:s1.substr(1,s1.length-2), class:$$[$0]};
|
|
1891
1891
|
|
|
1892
1892
|
break;
|
|
1893
1893
|
case 751:
|
|
1894
1894
|
|
|
1895
|
-
this.$ = {
|
|
1895
|
+
this.$ = {class:$$[$0]};
|
|
1896
1896
|
|
|
1897
1897
|
break;
|
|
1898
1898
|
case 757:
|
|
@@ -1909,21 +1909,21 @@ case 762:
|
|
|
1909
1909
|
break;
|
|
1910
1910
|
case 765:
|
|
1911
1911
|
|
|
1912
|
-
this.$ = new yy.CreateTrigger({trigger:$$[$0-6], when:$$[$0-5], action:$$[$0-4], table:$$[$0-2], statement:$$[$0]});
|
|
1913
|
-
if($$[$0].exists) this.$.exists = $$[$0].exists;
|
|
1914
|
-
if($$[$0].queries) this.$.queries = $$[$0].queries;
|
|
1912
|
+
this.$ = new yy.CreateTrigger({trigger:$$[$0-6], when:$$[$0-5], action:$$[$0-4], table:$$[$0-2], statement:$$[$0]});
|
|
1913
|
+
if($$[$0].exists) this.$.exists = $$[$0].exists;
|
|
1914
|
+
if($$[$0].queries) this.$.queries = $$[$0].queries;
|
|
1915
1915
|
|
|
1916
1916
|
break;
|
|
1917
1917
|
case 766:
|
|
1918
1918
|
|
|
1919
|
-
this.$ = new yy.CreateTrigger({trigger:$$[$0-5], when:$$[$0-4], action:$$[$0-3], table:$$[$0-1], funcid:$$[$0]});
|
|
1919
|
+
this.$ = new yy.CreateTrigger({trigger:$$[$0-5], when:$$[$0-4], action:$$[$0-3], table:$$[$0-1], funcid:$$[$0]});
|
|
1920
1920
|
|
|
1921
1921
|
break;
|
|
1922
1922
|
case 767:
|
|
1923
1923
|
|
|
1924
|
-
this.$ = new yy.CreateTrigger({trigger:$$[$0-6], when:$$[$0-4], action:$$[$0-3], table:$$[$0-5], statement:$$[$0]});
|
|
1925
|
-
if($$[$0].exists) this.$.exists = $$[$0].exists;
|
|
1926
|
-
if($$[$0].queries) this.$.queries = $$[$0].queries;
|
|
1924
|
+
this.$ = new yy.CreateTrigger({trigger:$$[$0-6], when:$$[$0-4], action:$$[$0-3], table:$$[$0-5], statement:$$[$0]});
|
|
1925
|
+
if($$[$0].exists) this.$.exists = $$[$0].exists;
|
|
1926
|
+
if($$[$0].queries) this.$.queries = $$[$0].queries;
|
|
1927
1927
|
|
|
1928
1928
|
break;
|
|
1929
1929
|
case 768: case 769: case 771:
|
|
@@ -2211,17 +2211,17 @@ _handle_error:
|
|
|
2211
2211
|
return true;
|
|
2212
2212
|
}};
|
|
2213
2213
|
|
|
2214
|
-
// from https://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
|
|
2215
|
-
// JSON.stringify([].slice.call(document.querySelectorAll('tr')).filter(x => x.children.length == 5 && x.children[2].innerText == 'reserved').map(x => x.children[0].innerText))
|
|
2214
|
+
// from https://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
|
|
2215
|
+
// JSON.stringify([].slice.call(document.querySelectorAll('tr')).filter(x => x.children.length == 5 && x.children[2].innerText == 'reserved').map(x => x.children[0].innerText))
|
|
2216
2216
|
|
|
2217
|
-
var nonReserved = ["A","ABSENT","ABSOLUTE","ACCORDING","ACTION","ADA","ADD","ADMIN","AFTER","ALWAYS","ASC","ASSERTION","ASSIGNMENT","ATTRIBUTE","ATTRIBUTES","BASE64","BEFORE","BERNOULLI","BLOCKED","BOM","BREADTH","C","CASCADE","CATALOG","CATALOG_NAME","CHAIN","CHARACTERISTICS","CHARACTERS","CHARACTER_SET_CATALOG","CHARACTER_SET_NAME","CHARACTER_SET_SCHEMA","CLASS_ORIGIN","COBOL","COLLATION","COLLATION_CATALOG","COLLATION_NAME","COLLATION_SCHEMA","COLUMNS","COLUMN_NAME","COMMAND_FUNCTION","COMMAND_FUNCTION_CODE","COMMITTED","CONDITION_NUMBER","CONNECTION","CONNECTION_NAME","CONSTRAINTS","CONSTRAINT_CATALOG","CONSTRAINT_NAME","CONSTRAINT_SCHEMA","CONSTRUCTOR","CONTENT","CONTINUE","CONTROL","CURSOR_NAME","DATA","DATETIME_INTERVAL_CODE","DATETIME_INTERVAL_PRECISION","DB","DEFAULTS","DEFERRABLE","DEFERRED","DEFINED","DEFINER","DEGREE","DEPTH","DERIVED","DESC","DESCRIPTOR","DIAGNOSTICS","DISPATCH","DOCUMENT","DOMAIN","DYNAMIC_FUNCTION","DYNAMIC_FUNCTION_CODE","EMPTY","ENCODING","ENFORCED","EXCLUDE","EXCLUDING","EXPRESSION","FILE","FINAL","FIRST","FLAG","FOLLOWING","FORTRAN","FOUND","FS","G","GENERAL","GENERATED","GO","GOTO","GRANTED","HEX","HIERARCHY","ID","IGNORE","IMMEDIATE","IMMEDIATELY","IMPLEMENTATION","INCLUDING","INCREMENT","INDENT","INITIALLY","INPUT","INSTANCE","INSTANTIABLE","INSTEAD","INTEGRITY","INVOKER","ISOLATION","K","KEY","KEY_MEMBER","KEY_TYPE","LAST","LENGTH","LEVEL","LIBRARY","LIMIT","LINK","LOCATION","LOCATOR","M","MAP","MAPPING","MATCHED","MAXVALUE","MESSAGE_LENGTH","MESSAGE_OCTET_LENGTH","MESSAGE_TEXT","MINVALUE","MORE","MUMPS","NAME","NAMES","NAMESPACE","NESTING","NEXT","NFC","NFD","NFKC","NFKD","NIL","NORMALIZED","NULLABLE","NULLS","NUMBER","OBJECT","OCTETS","OFF","OPTION","OPTIONS","ORDERING","ORDINALITY","OTHERS","OUTPUT","OVERRIDING","P","PAD","PARAMETER_MODE","PARAMETER_NAME","PARAMETER_ORDINAL_POSITION","PARAMETER_SPECIFIC_CATALOG","PARAMETER_SPECIFIC_NAME","PARAMETER_SPECIFIC_SCHEMA","PARTIAL","PASCAL","PASSING","PASSTHROUGH","PATH","PERMISSION","PLACING","PLI","PRECEDING","PRESERVE","PRIOR","PRIVILEGES","PUBLIC","READ","RECOVERY","RELATIVE","REPEATABLE","REQUIRING","RESPECT","RESTART","RESTORE","RESTRICT","RETURNED_CARDINALITY","RETURNED_LENGTH","RETURNED_OCTET_LENGTH","RETURNED_SQLSTATE","RETURNING","ROLE","ROUTINE","ROUTINE_CATALOG","ROUTINE_NAME","ROUTINE_SCHEMA","ROW_COUNT","SCALE","SCHEMA","SCHEMA_NAME","SCOPE_CATALOG","SCOPE_NAME","SCOPE_SCHEMA","SECTION","SECURITY","SELECTIVE","SELF","SEQUENCE","SERIALIZABLE","SERVER","SERVER_NAME","SESSION","SETS","SIMPLE","SIZE","SOURCE","SPACE","SPECIFIC_NAME","STANDALONE","STATE","STATEMENT","STRIP","STRUCTURE","STYLE","SUBCLASS_ORIGIN","T","TABLE_NAME","TEMPORARY","TIES","TOKEN","TOP_LEVEL_COUNT","TRANSACTION","TRANSACTIONS_COMMITTED","TRANSACTIONS_ROLLED_BACK","TRANSACTION_ACTIVE","TRANSFORM","TRANSFORMS","TRIGGER_CATALOG","TRIGGER_NAME","TRIGGER_SCHEMA","TYPE","UNBOUNDED","UNCOMMITTED","UNDER","UNLINK","UNNAMED","UNTYPED","URI","USAGE","USER_DEFINED_TYPE_CATALOG","USER_DEFINED_TYPE_CODE","USER_DEFINED_TYPE_NAME","USER_DEFINED_TYPE_SCHEMA","VALID","VERSION","VIEW","WHITESPACE","WORK","WRAPPER","WRITE","XMLDECLARATION","XMLSCHEMA","YES","ZONE"]
|
|
2217
|
+
var nonReserved = ["A","ABSENT","ABSOLUTE","ACCORDING","ACTION","ADA","ADD","ADMIN","AFTER","ALWAYS","ASC","ASSERTION","ASSIGNMENT","ATTRIBUTE","ATTRIBUTES","BASE64","BEFORE","BERNOULLI","BLOCKED","BOM","BREADTH","C","CASCADE","CATALOG","CATALOG_NAME","CHAIN","CHARACTERISTICS","CHARACTERS","CHARACTER_SET_CATALOG","CHARACTER_SET_NAME","CHARACTER_SET_SCHEMA","CLASS_ORIGIN","COBOL","COLLATION","COLLATION_CATALOG","COLLATION_NAME","COLLATION_SCHEMA","COLUMNS","COLUMN_NAME","COMMAND_FUNCTION","COMMAND_FUNCTION_CODE","COMMITTED","CONDITION_NUMBER","CONNECTION","CONNECTION_NAME","CONSTRAINTS","CONSTRAINT_CATALOG","CONSTRAINT_NAME","CONSTRAINT_SCHEMA","CONSTRUCTOR","CONTENT","CONTINUE","CONTROL","CURSOR_NAME","DATA","DATETIME_INTERVAL_CODE","DATETIME_INTERVAL_PRECISION","DB","DEFAULTS","DEFERRABLE","DEFERRED","DEFINED","DEFINER","DEGREE","DEPTH","DERIVED","DESC","DESCRIPTOR","DIAGNOSTICS","DISPATCH","DOCUMENT","DOMAIN","DYNAMIC_FUNCTION","DYNAMIC_FUNCTION_CODE","EMPTY","ENCODING","ENFORCED","EXCLUDE","EXCLUDING","EXPRESSION","FILE","FINAL","FIRST","FLAG","FOLLOWING","FORTRAN","FOUND","FS","G","GENERAL","GENERATED","GO","GOTO","GRANTED","HEX","HIERARCHY","ID","IGNORE","IMMEDIATE","IMMEDIATELY","IMPLEMENTATION","INCLUDING","INCREMENT","INDENT","INITIALLY","INPUT","INSTANCE","INSTANTIABLE","INSTEAD","INTEGRITY","INVOKER","ISOLATION","K","KEY","KEY_MEMBER","KEY_TYPE","LAST","LENGTH","LEVEL","LIBRARY","LIMIT","LINK","LOCATION","LOCATOR","M","MAP","MAPPING","MATCHED","MAXVALUE","MESSAGE_LENGTH","MESSAGE_OCTET_LENGTH","MESSAGE_TEXT","MINVALUE","MORE","MUMPS","NAME","NAMES","NAMESPACE","NESTING","NEXT","NFC","NFD","NFKC","NFKD","NIL","NORMALIZED","NULLABLE","NULLS","NUMBER","OBJECT","OCTETS","OFF","OPTION","OPTIONS","ORDERING","ORDINALITY","OTHERS","OUTPUT","OVERRIDING","P","PAD","PARAMETER_MODE","PARAMETER_NAME","PARAMETER_ORDINAL_POSITION","PARAMETER_SPECIFIC_CATALOG","PARAMETER_SPECIFIC_NAME","PARAMETER_SPECIFIC_SCHEMA","PARTIAL","PASCAL","PASSING","PASSTHROUGH","PATH","PERMISSION","PLACING","PLI","PRECEDING","PRESERVE","PRIOR","PRIVILEGES","PUBLIC","READ","RECOVERY","RELATIVE","REPEATABLE","REQUIRING","RESPECT","RESTART","RESTORE","RESTRICT","RETURNED_CARDINALITY","RETURNED_LENGTH","RETURNED_OCTET_LENGTH","RETURNED_SQLSTATE","RETURNING","ROLE","ROUTINE","ROUTINE_CATALOG","ROUTINE_NAME","ROUTINE_SCHEMA","ROW_COUNT","SCALE","SCHEMA","SCHEMA_NAME","SCOPE_CATALOG","SCOPE_NAME","SCOPE_SCHEMA","SECTION","SECURITY","SELECTIVE","SELF","SEQUENCE","SERIALIZABLE","SERVER","SERVER_NAME","SESSION","SETS","SIMPLE","SIZE","SOURCE","SPACE","SPECIFIC_NAME","STANDALONE","STATE","STATEMENT","STRIP","STRUCTURE","STYLE","SUBCLASS_ORIGIN","T","TABLE_NAME","TEMPORARY","TIES","TOKEN","TOP_LEVEL_COUNT","TRANSACTION","TRANSACTIONS_COMMITTED","TRANSACTIONS_ROLLED_BACK","TRANSACTION_ACTIVE","TRANSFORM","TRANSFORMS","TRIGGER_CATALOG","TRIGGER_NAME","TRIGGER_SCHEMA","TYPE","UNBOUNDED","UNCOMMITTED","UNDER","UNLINK","UNNAMED","UNTYPED","URI","USAGE","USER_DEFINED_TYPE_CATALOG","USER_DEFINED_TYPE_CODE","USER_DEFINED_TYPE_NAME","USER_DEFINED_TYPE_SCHEMA","VALID","VERSION","VIEW","WHITESPACE","WORK","WRAPPER","WRITE","XMLDECLARATION","XMLSCHEMA","YES","ZONE"]
|
|
2218
2218
|
|
|
2219
|
-
parser.parseError = function(str, hash) {
|
|
2220
|
-
if (hash.expected && hash.expected.indexOf("'LITERAL'") > -1 && /[a-zA-Z_][a-zA-Z_0-9]*/.test(hash.token) && nonReserved.indexOf(hash.token) > -1) {
|
|
2221
|
-
return
|
|
2222
|
-
}
|
|
2223
|
-
throw new SyntaxError(str)
|
|
2224
|
-
}
|
|
2219
|
+
parser.parseError = function(str, hash) {
|
|
2220
|
+
if (hash.expected && hash.expected.indexOf("'LITERAL'") > -1 && /[a-zA-Z_][a-zA-Z_0-9]*/.test(hash.token) && nonReserved.indexOf(hash.token) > -1) {
|
|
2221
|
+
return
|
|
2222
|
+
}
|
|
2223
|
+
throw new SyntaxError(str)
|
|
2224
|
+
}
|
|
2225
2225
|
/* generated by jison-lex 0.3.4 */
|
|
2226
2226
|
var lexer = (function(){
|
|
2227
2227
|
var lexer = ({
|
|
@@ -3491,7 +3491,8 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3491
3491
|
var a = new Uint8Array(buf);
|
|
3492
3492
|
var b = [...a].map((e) => String.fromCharCode(e)).join('');
|
|
3493
3493
|
success(cutbom(b));
|
|
3494
|
-
})
|
|
3494
|
+
})
|
|
3495
|
+
.catch((e) => {
|
|
3495
3496
|
if (error) return error(e);
|
|
3496
3497
|
console.error(e);
|
|
3497
3498
|
throw e;
|
|
@@ -3522,7 +3523,8 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3522
3523
|
RNFS.readFile(path, 'utf8')
|
|
3523
3524
|
.then(function (contents) {
|
|
3524
3525
|
success(cutbom(contents));
|
|
3525
|
-
})
|
|
3526
|
+
})
|
|
3527
|
+
.catch(function (err) {
|
|
3526
3528
|
return error(err, null);
|
|
3527
3529
|
});
|
|
3528
3530
|
//*/
|
|
@@ -3571,7 +3573,6 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3571
3573
|
}
|
|
3572
3574
|
};
|
|
3573
3575
|
xhr.open('GET', path, asy); // Async
|
|
3574
|
-
xhr.responseType = 'text';
|
|
3575
3576
|
xhr.send();
|
|
3576
3577
|
}
|
|
3577
3578
|
} else if (path instanceof Event) {
|
|
@@ -3631,7 +3632,8 @@ var loadBinaryFile = (utils.loadBinaryFile = function (
|
|
|
3631
3632
|
var a = new Uint8Array(buf);
|
|
3632
3633
|
var b = [...a].map((e) => String.fromCharCode(e)).join('');
|
|
3633
3634
|
success(b);
|
|
3634
|
-
})
|
|
3635
|
+
})
|
|
3636
|
+
.catch((e) => {
|
|
3635
3637
|
if (error) return error(e);
|
|
3636
3638
|
console.error(e);
|
|
3637
3639
|
throw e;
|
|
@@ -3665,14 +3667,15 @@ var loadBinaryFile = (utils.loadBinaryFile = function (
|
|
|
3665
3667
|
} else if (utils.isReactNative) {
|
|
3666
3668
|
// If ReactNative
|
|
3667
3669
|
//var RNFS = require('react-native-fs');
|
|
3668
|
-
var RNFetchBlob = require('react-native-fetch-blob')
|
|
3670
|
+
var RNFetchBlob = require('react-native-fetch-blob').default;
|
|
3669
3671
|
var dirs = RNFetchBlob.fs.dirs;
|
|
3670
3672
|
//should use readStream instead if the file is large
|
|
3671
3673
|
RNFetchBlob.fs
|
|
3672
3674
|
.readFile(path, 'base64')
|
|
3673
3675
|
.then(function (data) {
|
|
3674
3676
|
success(data);
|
|
3675
|
-
})
|
|
3677
|
+
})
|
|
3678
|
+
.catch(error);
|
|
3676
3679
|
//*/
|
|
3677
3680
|
} else {
|
|
3678
3681
|
if (typeof path === 'string') {
|
|
@@ -3732,7 +3735,8 @@ var removeFile = (utils.removeFile = function (path, cb) {
|
|
|
3732
3735
|
RNFS.unlink(path)
|
|
3733
3736
|
.then(function () {
|
|
3734
3737
|
cb && cb();
|
|
3735
|
-
})
|
|
3738
|
+
})
|
|
3739
|
+
.catch(function (err) {
|
|
3736
3740
|
throw err;
|
|
3737
3741
|
});
|
|
3738
3742
|
//*/
|
|
@@ -3753,7 +3757,8 @@ var deleteFile = (utils.deleteFile = function (path, cb) {
|
|
|
3753
3757
|
RNFS.unlink(path)
|
|
3754
3758
|
.then(function () {
|
|
3755
3759
|
cb && cb();
|
|
3756
|
-
})
|
|
3760
|
+
})
|
|
3761
|
+
.catch(function (err) {
|
|
3757
3762
|
throw err;
|
|
3758
3763
|
});
|
|
3759
3764
|
}
|
|
@@ -3797,7 +3802,8 @@ var fileExists = (utils.fileExists = function (path, cb) {
|
|
|
3797
3802
|
RNFS.exists(path)
|
|
3798
3803
|
.then(function (yes) {
|
|
3799
3804
|
cb && cb(yes);
|
|
3800
|
-
})
|
|
3805
|
+
})
|
|
3806
|
+
.catch(function (err) {
|
|
3801
3807
|
throw err;
|
|
3802
3808
|
});
|
|
3803
3809
|
//*/
|
|
@@ -3840,7 +3846,8 @@ var saveFile = (utils.saveFile = function (path, data, cb, opts) {
|
|
|
3840
3846
|
.then(function (success) {
|
|
3841
3847
|
//, 'utf8'
|
|
3842
3848
|
if (cb) res = cb(res);
|
|
3843
|
-
})
|
|
3849
|
+
})
|
|
3850
|
+
.catch(function (err) {
|
|
3844
3851
|
console.error(err.message);
|
|
3845
3852
|
});
|
|
3846
3853
|
} else if (utils.isCordova) {
|
|
@@ -4342,7 +4349,7 @@ utils.findAlaSQLPath = function () {
|
|
|
4342
4349
|
};
|
|
4343
4350
|
|
|
4344
4351
|
var getXLSX = function () {
|
|
4345
|
-
var XLSX = alasql
|
|
4352
|
+
var XLSX = alasql.private.externalXlsxLib;
|
|
4346
4353
|
|
|
4347
4354
|
if (XLSX) {
|
|
4348
4355
|
return XLSX;
|
|
@@ -4591,12 +4598,12 @@ alasql.lastid = 0;
|
|
|
4591
4598
|
|
|
4592
4599
|
alasql.buffer = {};
|
|
4593
4600
|
|
|
4594
|
-
alasql
|
|
4601
|
+
alasql.private = {
|
|
4595
4602
|
externalXlsxLib: null,
|
|
4596
4603
|
};
|
|
4597
4604
|
|
|
4598
4605
|
alasql.setXLSX = function (XLSX) {
|
|
4599
|
-
alasql
|
|
4606
|
+
alasql.private.externalXlsxLib = XLSX;
|
|
4600
4607
|
};
|
|
4601
4608
|
|
|
4602
4609
|
/**
|
|
@@ -4927,7 +4934,7 @@ alasql.promise = function (sql, params) {
|
|
|
4927
4934
|
// Main Database class
|
|
4928
4935
|
|
|
4929
4936
|
/**
|
|
4930
|
-
@class Database
|
|
4937
|
+
@class Database
|
|
4931
4938
|
*/
|
|
4932
4939
|
|
|
4933
4940
|
var Database = (alasql.Database = function (databaseid) {
|
|
@@ -5004,85 +5011,95 @@ Database.prototype.autoval = function (tablename, colname, getNext) {
|
|
|
5004
5011
|
return alasql.autoval(tablename, colname, getNext, this.databaseid);
|
|
5005
5012
|
};
|
|
5006
5013
|
|
|
5014
|
+
Database.prototype.transaction = function (cb) {
|
|
5015
|
+
var tx = new alasql.Transaction(this.databaseid);
|
|
5016
|
+
var res = cb(tx);
|
|
5017
|
+
return res;
|
|
5018
|
+
};
|
|
5019
|
+
|
|
5007
5020
|
// Aliases like MS SQL
|
|
5008
5021
|
|
|
5009
5022
|
/*
|
|
5010
5023
|
//
|
|
5011
|
-
//
|
|
5024
|
+
// Transaction class for Alasql.js
|
|
5012
5025
|
// Date: 03.11.2014
|
|
5013
5026
|
// (c) 2014, Andrey Gershun
|
|
5014
5027
|
//
|
|
5015
5028
|
*/
|
|
5016
5029
|
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
var res = cb(tx);
|
|
5020
|
-
return res;
|
|
5021
|
-
};
|
|
5022
|
-
|
|
5023
|
-
// Transaction class (for WebSQL compatibility)
|
|
5030
|
+
class Transaction {
|
|
5031
|
+
transactionid = Date.now();
|
|
5024
5032
|
|
|
5025
|
-
|
|
5026
|
-
Transaction class
|
|
5027
|
-
@class Transaction
|
|
5028
|
-
*/
|
|
5033
|
+
committed = false;
|
|
5029
5034
|
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
this.databaseid = databaseid;
|
|
5033
|
-
this.commited = false;
|
|
5034
|
-
this.dbversion = alasql.databases[databaseid].dbversion;
|
|
5035
|
-
// this.bank = cloneDeep(alasql.databases[databaseid]);
|
|
5036
|
-
this.bank = JSON.stringify(alasql.databases[databaseid]);
|
|
5037
|
-
// TODO CLone Tables with insertfns
|
|
5035
|
+
/** @type {string | undefined} */
|
|
5036
|
+
bank;
|
|
5038
5037
|
|
|
5039
|
-
|
|
5040
|
-
|
|
5038
|
+
constructor(databaseid) {
|
|
5039
|
+
this.databaseid = databaseid;
|
|
5040
|
+
this.dbversion = alasql.databases[databaseid].dbversion;
|
|
5041
|
+
// this.bank = structuredClone(alasql.databases[databaseid]);
|
|
5042
|
+
this.bank = JSON.stringify(alasql.databases[databaseid]);
|
|
5043
|
+
// TODO CLone Tables with insertfns
|
|
5044
|
+
}
|
|
5041
5045
|
|
|
5042
|
-
|
|
5046
|
+
/** Commit transaction */
|
|
5047
|
+
commit() {
|
|
5048
|
+
this.committed = true;
|
|
5049
|
+
alasql.databases[this.databaseid].dbversion = Date.now();
|
|
5050
|
+
delete this.bank;
|
|
5051
|
+
}
|
|
5043
5052
|
|
|
5044
|
-
|
|
5053
|
+
/** Rollback transaction */
|
|
5054
|
+
rollback() {
|
|
5055
|
+
if (!this.committed) {
|
|
5056
|
+
alasql.databases[this.databaseid] = JSON.parse(this.bank);
|
|
5057
|
+
// alasql.databases[this.databaseid].tables = this.bank;
|
|
5058
|
+
// alasql.databases[this.databaseid].dbversion = this.dbversion;
|
|
5059
|
+
delete this.bank;
|
|
5060
|
+
} else {
|
|
5061
|
+
throw new Error('Transaction already commited');
|
|
5062
|
+
}
|
|
5063
|
+
}
|
|
5045
5064
|
|
|
5046
|
-
/**
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5065
|
+
/**
|
|
5066
|
+
* Execute SQL statement
|
|
5067
|
+
* @param {string} sql SQL statement
|
|
5068
|
+
* @param {object} params Parameters
|
|
5069
|
+
* @param {function} cb Callback function
|
|
5070
|
+
* @return result
|
|
5071
|
+
*/
|
|
5072
|
+
exec(sql, params, cb) {
|
|
5073
|
+
return alasql.dexec(this.databaseid, sql, params, cb);
|
|
5074
|
+
}
|
|
5054
5075
|
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
*/
|
|
5059
|
-
Transaction.prototype.rollback = function () {
|
|
5060
|
-
if (!this.commited) {
|
|
5061
|
-
alasql.databases[this.databaseid] = JSON.parse(this.bank);
|
|
5062
|
-
// alasql.databases[this.databaseid].tables = this.bank;
|
|
5063
|
-
// alasql.databases[this.databaseid].dbversion = this.dbversion;
|
|
5064
|
-
delete this.bank;
|
|
5065
|
-
} else {
|
|
5066
|
-
throw new Error('Transaction already commited');
|
|
5076
|
+
/*
|
|
5077
|
+
queryArray (sql, params, cb) {
|
|
5078
|
+
return flatArray(this.exec(sql, params, cb));
|
|
5067
5079
|
}
|
|
5068
|
-
};
|
|
5069
5080
|
|
|
5070
|
-
|
|
5081
|
+
queryArrayOfArrays (sql, params, cb) {
|
|
5082
|
+
return arrayOfArrays(this.exec(sql, params, cb));
|
|
5083
|
+
}
|
|
5071
5084
|
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
@param {object} params Parameters
|
|
5076
|
-
@param {function} cb Callback function
|
|
5077
|
-
@return result
|
|
5078
|
-
*/
|
|
5079
|
-
Transaction.prototype.exec = function (sql, params, cb) {
|
|
5085
|
+
querySingle (sql, params, cb) {
|
|
5086
|
+
return this.exec(sql, params, cb)[0];
|
|
5087
|
+
}
|
|
5080
5088
|
|
|
5081
|
-
|
|
5082
|
-
|
|
5089
|
+
queryValue (sql, params, cb) {
|
|
5090
|
+
var res = this.querySingle(sql, params, cb);
|
|
5091
|
+
return res[Object.keys(res)[0]];
|
|
5092
|
+
}
|
|
5093
|
+
*/
|
|
5094
|
+
}
|
|
5083
5095
|
|
|
5084
5096
|
Transaction.prototype.executeSQL = Transaction.prototype.exec;
|
|
5085
5097
|
|
|
5098
|
+
// Transaction.prototype.query = Database.prototype.exec;
|
|
5099
|
+
// Transaction.prototype.run = Database.prototype.exec;
|
|
5100
|
+
|
|
5101
|
+
alasql.Transaction = Transaction;
|
|
5102
|
+
|
|
5086
5103
|
/*
|
|
5087
5104
|
//
|
|
5088
5105
|
// Table class for Alasql.js
|
|
@@ -5130,7 +5147,7 @@ var Table = (alasql.Table = function (params) {
|
|
|
5130
5147
|
this.insteadofupdate = {};
|
|
5131
5148
|
|
|
5132
5149
|
// Done
|
|
5133
|
-
|
|
5150
|
+
Object.assign(this, params);
|
|
5134
5151
|
});
|
|
5135
5152
|
|
|
5136
5153
|
Table.prototype.indexColumns = function () {
|
|
@@ -5157,7 +5174,7 @@ var View = (alasql.View = function (params) {
|
|
|
5157
5174
|
// Data array
|
|
5158
5175
|
this.query = [];
|
|
5159
5176
|
|
|
5160
|
-
|
|
5177
|
+
Object.assign(this, params);
|
|
5161
5178
|
});
|
|
5162
5179
|
|
|
5163
5180
|
/*
|
|
@@ -5201,27 +5218,29 @@ var Recordset = (alasql.Recordset = function (params) {
|
|
|
5201
5218
|
//
|
|
5202
5219
|
*/
|
|
5203
5220
|
|
|
5204
|
-
var yy = (alasqlparser.yy = alasql.yy = {});
|
|
5205
|
-
|
|
5206
|
-
// Utility
|
|
5207
|
-
yy.extend = extend;
|
|
5208
|
-
// Option for case sensitive
|
|
5209
|
-
yy.casesensitive = alasql.options.casesensitive;
|
|
5210
|
-
|
|
5211
5221
|
// Base class for all yy classes
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5222
|
+
class Base {
|
|
5223
|
+
constructor(params) {
|
|
5224
|
+
Object.assign(this, params);
|
|
5225
|
+
}
|
|
5226
|
+
toString() {}
|
|
5227
|
+
toType() {}
|
|
5228
|
+
toJS() {}
|
|
5229
|
+
exec() {}
|
|
5230
|
+
compile() {}
|
|
5231
|
+
}
|
|
5215
5232
|
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5233
|
+
var yy = {
|
|
5234
|
+
// Utility
|
|
5235
|
+
/** @deprecated use `Object.assign` instead */
|
|
5236
|
+
extend: Object.assign,
|
|
5219
5237
|
|
|
5220
|
-
|
|
5221
|
-
|
|
5238
|
+
// Option for case sensitive
|
|
5239
|
+
casesensitive: alasql.options.casesensitive,
|
|
5240
|
+
Base,
|
|
5241
|
+
};
|
|
5222
5242
|
|
|
5223
|
-
|
|
5224
|
-
Base.prototype.exec = function () {};
|
|
5243
|
+
alasqlparser.yy = alasql.yy = yy;
|
|
5225
5244
|
|
|
5226
5245
|
/*
|
|
5227
5246
|
//
|
|
@@ -5231,36 +5250,25 @@ Base.prototype.exec = function () {};
|
|
|
5231
5250
|
//
|
|
5232
5251
|
*/
|
|
5233
5252
|
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
}
|
|
5253
|
+
yy.Statements = class Statements {
|
|
5254
|
+
constructor(params) {
|
|
5255
|
+
Object.assign(this, params);
|
|
5256
|
+
}
|
|
5238
5257
|
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
return st.toString();
|
|
5243
|
-
})
|
|
5244
|
-
.join('; ');
|
|
5245
|
-
};
|
|
5258
|
+
toString() {
|
|
5259
|
+
return this.statements.map((st) => st.toString()).join('; ');
|
|
5260
|
+
}
|
|
5246
5261
|
|
|
5247
|
-
// Compile array of statements into single statement
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
return
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
return st(params);
|
|
5258
|
-
});
|
|
5259
|
-
if (cb) {
|
|
5260
|
-
cb(res);
|
|
5261
|
-
}
|
|
5262
|
-
return res;
|
|
5263
|
-
};
|
|
5262
|
+
// Compile array of statements into single statement
|
|
5263
|
+
compile(db) {
|
|
5264
|
+
const statements = this.statements.map((st) => st.compile(db));
|
|
5265
|
+
return statements.length === 1
|
|
5266
|
+
? statements[0]
|
|
5267
|
+
: (params, cb) => {
|
|
5268
|
+
const res = statements.map((st) => st(params));
|
|
5269
|
+
if (cb) cb(res);
|
|
5270
|
+
return res;
|
|
5271
|
+
};
|
|
5264
5272
|
}
|
|
5265
5273
|
};
|
|
5266
5274
|
|
|
@@ -5274,1078 +5282,1051 @@ yy.Statements.prototype.compile = function (db) {
|
|
|
5274
5282
|
//
|
|
5275
5283
|
*/
|
|
5276
5284
|
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5285
|
+
/**
|
|
5286
|
+
Search class
|
|
5287
|
+
@example
|
|
5288
|
+
SEARCH SUM(/a) FROM ? -- search over parameter object
|
|
5289
|
+
*/
|
|
5282
5290
|
|
|
5283
|
-
|
|
5284
|
-
|
|
5291
|
+
yy.Search = class Search {
|
|
5292
|
+
constructor(params) {
|
|
5293
|
+
Object.assign(this, params);
|
|
5294
|
+
}
|
|
5285
5295
|
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5296
|
+
toString() {
|
|
5297
|
+
let s = 'SEARCH ';
|
|
5298
|
+
if (this.selectors) s += this.selectors.toString();
|
|
5299
|
+
if (this.from) s += 'FROM ' + this.from.toString();
|
|
5300
|
+
return s;
|
|
5301
|
+
}
|
|
5290
5302
|
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5303
|
+
toJS(context) {
|
|
5304
|
+
const s = `this.queriesfn[${this.queriesidx - 1}](this.params,null,${context})`;
|
|
5305
|
+
return s;
|
|
5306
|
+
}
|
|
5294
5307
|
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5308
|
+
compile(databaseid) {
|
|
5309
|
+
var dbid = databaseid;
|
|
5310
|
+
|
|
5311
|
+
var statement = (params, cb) => {
|
|
5312
|
+
var res;
|
|
5313
|
+
this.#doSearch(dbid, params, function (data) {
|
|
5314
|
+
res = modify(statement.query, data);
|
|
5315
|
+
if (cb) res = cb(res);
|
|
5316
|
+
});
|
|
5317
|
+
// if(cb) res = cb(res);
|
|
5318
|
+
return res;
|
|
5319
|
+
};
|
|
5320
|
+
statement.query = {};
|
|
5321
|
+
return statement;
|
|
5322
|
+
}
|
|
5323
|
+
|
|
5324
|
+
#doSearch(databaseid, params, cb) {
|
|
5325
|
+
var res;
|
|
5326
|
+
var stope = {};
|
|
5327
|
+
var fromdata;
|
|
5328
|
+
var selectors = cloneDeep(this.selectors);
|
|
5329
|
+
|
|
5330
|
+
function processSelector(selectors, sidx, value) {
|
|
5331
|
+
// var val;
|
|
5332
|
+
|
|
5333
|
+
var val, // temp values use many places
|
|
5334
|
+
nest, // temp value used many places
|
|
5335
|
+
r, // temp value used many places
|
|
5336
|
+
sel = selectors[sidx];
|
|
5337
|
+
|
|
5338
|
+
// if(!alasql.srch[sel.srchid]) {
|
|
5339
|
+
// throw new Error('Selector "'+sel.srchid+'" not found');
|
|
5340
|
+
// };
|
|
5341
|
+
|
|
5342
|
+
var INFINITE_LOOP_BREAK = alasql.options.loopbreak || 100000;
|
|
5343
|
+
|
|
5344
|
+
if (sel.selid) {
|
|
5345
|
+
// TODO Process Selector
|
|
5346
|
+
if (sel.selid === 'PATH') {
|
|
5347
|
+
var queue = [{node: value, stack: []}];
|
|
5348
|
+
var visited = {};
|
|
5349
|
+
//var path = [];
|
|
5350
|
+
var objects = alasql.databases[alasql.useid].objects;
|
|
5351
|
+
while (queue.length > 0) {
|
|
5352
|
+
var q = queue.shift();
|
|
5353
|
+
var node = q.node;
|
|
5354
|
+
var stack = q.stack;
|
|
5355
|
+
var r = processSelector(sel.args, 0, node);
|
|
5356
|
+
if (r.length > 0) {
|
|
5357
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5358
|
+
return stack;
|
|
5359
|
+
} else {
|
|
5360
|
+
var rv = [];
|
|
5361
|
+
if (stack && stack.length > 0) {
|
|
5362
|
+
stack.forEach(function (stv) {
|
|
5363
|
+
rv = rv.concat(processSelector(selectors, sidx + 1, stv));
|
|
5364
|
+
});
|
|
5365
|
+
}
|
|
5366
|
+
return rv;
|
|
5367
|
+
// return processSelector(selectors,sidx+1,stack);
|
|
5318
5368
|
}
|
|
5319
|
-
return rv;
|
|
5320
|
-
// return processSelector(selectors,sidx+1,stack);
|
|
5321
|
-
}
|
|
5322
|
-
} else {
|
|
5323
|
-
if (typeof visited[node.$id] !== 'undefined') {
|
|
5324
|
-
continue;
|
|
5325
5369
|
} else {
|
|
5370
|
+
if (typeof visited[node.$id] !== 'undefined') {
|
|
5371
|
+
continue;
|
|
5372
|
+
} else {
|
|
5326
5373
|
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5374
|
+
visited[node.$id] = true;
|
|
5375
|
+
if (node.$out && node.$out.length > 0) {
|
|
5376
|
+
node.$out.forEach(function (edgeid) {
|
|
5377
|
+
var edge = objects[edgeid];
|
|
5378
|
+
var stack2 = stack.concat(edge);
|
|
5379
|
+
stack2.push(objects[edge.$out[0]]);
|
|
5380
|
+
queue.push({
|
|
5381
|
+
node: objects[edge.$out[0]],
|
|
5382
|
+
stack: stack2,
|
|
5383
|
+
});
|
|
5336
5384
|
});
|
|
5337
|
-
}
|
|
5385
|
+
}
|
|
5338
5386
|
}
|
|
5339
5387
|
}
|
|
5340
5388
|
}
|
|
5389
|
+
// Else return fail
|
|
5390
|
+
return [];
|
|
5341
5391
|
}
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
}
|
|
5345
|
-
if (sel.selid === 'NOT') {
|
|
5346
|
-
var nest = processSelector(sel.args, 0, value);
|
|
5392
|
+
if (sel.selid === 'NOT') {
|
|
5393
|
+
var nest = processSelector(sel.args, 0, value);
|
|
5347
5394
|
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
} else {
|
|
5351
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5352
|
-
return [value];
|
|
5395
|
+
if (nest.length > 0) {
|
|
5396
|
+
return [];
|
|
5353
5397
|
} else {
|
|
5354
|
-
|
|
5398
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5399
|
+
return [value];
|
|
5400
|
+
} else {
|
|
5401
|
+
return processSelector(selectors, sidx + 1, value);
|
|
5402
|
+
}
|
|
5355
5403
|
}
|
|
5356
|
-
}
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
nest = distinctArray(value);
|
|
5361
|
-
} else {
|
|
5362
|
-
nest = processSelector(sel.args, 0, value);
|
|
5363
|
-
}
|
|
5364
|
-
if (nest.length === 0) {
|
|
5365
|
-
return [];
|
|
5366
|
-
} else {
|
|
5367
|
-
var res = distinctArray(nest);
|
|
5368
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5369
|
-
return res;
|
|
5404
|
+
} else if (sel.selid === 'DISTINCT') {
|
|
5405
|
+
var nest;
|
|
5406
|
+
if (typeof sel.args === 'undefined' || sel.args.length === 0) {
|
|
5407
|
+
nest = distinctArray(value);
|
|
5370
5408
|
} else {
|
|
5371
|
-
|
|
5409
|
+
nest = processSelector(sel.args, 0, value);
|
|
5372
5410
|
}
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
var res = true;
|
|
5376
|
-
sel.args.forEach(function (se) {
|
|
5377
|
-
res = res && processSelector(se, 0, value).length > 0;
|
|
5378
|
-
});
|
|
5379
|
-
if (!res) {
|
|
5380
|
-
return [];
|
|
5381
|
-
} else {
|
|
5382
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5383
|
-
return [value];
|
|
5411
|
+
if (nest.length === 0) {
|
|
5412
|
+
return [];
|
|
5384
5413
|
} else {
|
|
5385
|
-
|
|
5414
|
+
var res = distinctArray(nest);
|
|
5415
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5416
|
+
return res;
|
|
5417
|
+
} else {
|
|
5418
|
+
return processSelector(selectors, sidx + 1, res);
|
|
5419
|
+
}
|
|
5386
5420
|
}
|
|
5387
|
-
}
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
return [];
|
|
5395
|
-
} else {
|
|
5396
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5397
|
-
return [value];
|
|
5421
|
+
} else if (sel.selid === 'AND') {
|
|
5422
|
+
var res = true;
|
|
5423
|
+
sel.args.forEach(function (se) {
|
|
5424
|
+
res = res && processSelector(se, 0, value).length > 0;
|
|
5425
|
+
});
|
|
5426
|
+
if (!res) {
|
|
5427
|
+
return [];
|
|
5398
5428
|
} else {
|
|
5399
|
-
|
|
5429
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5430
|
+
return [value];
|
|
5431
|
+
} else {
|
|
5432
|
+
return processSelector(selectors, sidx + 1, value);
|
|
5433
|
+
}
|
|
5400
5434
|
}
|
|
5401
|
-
}
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
return nest;
|
|
5435
|
+
} else if (sel.selid === 'OR') {
|
|
5436
|
+
var res = false;
|
|
5437
|
+
sel.args.forEach(function (se) {
|
|
5438
|
+
res = res || processSelector(se, 0, value).length > 0;
|
|
5439
|
+
});
|
|
5440
|
+
if (!res) {
|
|
5441
|
+
return [];
|
|
5409
5442
|
} else {
|
|
5410
|
-
|
|
5443
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5444
|
+
return [value];
|
|
5445
|
+
} else {
|
|
5446
|
+
return processSelector(selectors, sidx + 1, value);
|
|
5447
|
+
}
|
|
5411
5448
|
}
|
|
5412
|
-
}
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
if (nest.length === 0) {
|
|
5417
|
-
return [];
|
|
5418
|
-
} else {
|
|
5419
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5420
|
-
return [nest[0]];
|
|
5449
|
+
} else if (sel.selid === 'ALL') {
|
|
5450
|
+
var nest = processSelector(sel.args[0], 0, value);
|
|
5451
|
+
if (nest.length === 0) {
|
|
5452
|
+
return [];
|
|
5421
5453
|
} else {
|
|
5422
|
-
|
|
5454
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5455
|
+
return nest;
|
|
5456
|
+
} else {
|
|
5457
|
+
return processSelector(selectors, sidx + 1, nest);
|
|
5458
|
+
}
|
|
5423
5459
|
}
|
|
5424
|
-
}
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
nest = nest.concat(processSelector(se, 0, value));
|
|
5429
|
-
});
|
|
5430
|
-
if (nest.length === 0) {
|
|
5431
|
-
return [];
|
|
5432
|
-
} else {
|
|
5433
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5434
|
-
return nest;
|
|
5460
|
+
} else if (sel.selid === 'ANY') {
|
|
5461
|
+
var nest = processSelector(sel.args[0], 0, value);
|
|
5462
|
+
if (nest.length === 0) {
|
|
5463
|
+
return [];
|
|
5435
5464
|
} else {
|
|
5436
|
-
|
|
5465
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5466
|
+
return [nest[0]];
|
|
5467
|
+
} else {
|
|
5468
|
+
return processSelector(selectors, sidx + 1, [nest[0]]);
|
|
5469
|
+
}
|
|
5437
5470
|
}
|
|
5438
|
-
}
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
if (nest.length === 0) {
|
|
5446
|
-
return [];
|
|
5447
|
-
} else {
|
|
5448
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5449
|
-
return nest;
|
|
5471
|
+
} else if (sel.selid === 'UNIONALL') {
|
|
5472
|
+
var nest = [];
|
|
5473
|
+
sel.args.forEach(function (se) {
|
|
5474
|
+
nest = nest.concat(processSelector(se, 0, value));
|
|
5475
|
+
});
|
|
5476
|
+
if (nest.length === 0) {
|
|
5477
|
+
return [];
|
|
5450
5478
|
} else {
|
|
5451
|
-
|
|
5479
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5480
|
+
return nest;
|
|
5481
|
+
} else {
|
|
5482
|
+
return processSelector(selectors, sidx + 1, nest);
|
|
5483
|
+
}
|
|
5452
5484
|
}
|
|
5453
|
-
}
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
return [value];
|
|
5485
|
+
} else if (sel.selid === 'UNION') {
|
|
5486
|
+
var nest = [];
|
|
5487
|
+
sel.args.forEach(function (se) {
|
|
5488
|
+
nest = nest.concat(processSelector(se, 0, value));
|
|
5489
|
+
});
|
|
5490
|
+
var nest = distinctArray(nest);
|
|
5491
|
+
if (nest.length === 0) {
|
|
5492
|
+
return [];
|
|
5462
5493
|
} else {
|
|
5463
|
-
|
|
5494
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5495
|
+
return nest;
|
|
5496
|
+
} else {
|
|
5497
|
+
return processSelector(selectors, sidx + 1, nest);
|
|
5498
|
+
}
|
|
5464
5499
|
}
|
|
5465
|
-
}
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
var lvar,
|
|
5469
|
-
lmax,
|
|
5470
|
-
lmin = sel.args[0].value;
|
|
5471
|
-
if (!sel.args[1]) {
|
|
5472
|
-
lmax = lmin; // Add security break
|
|
5473
|
-
} else {
|
|
5474
|
-
lmax = sel.args[1].value;
|
|
5475
|
-
}
|
|
5476
|
-
if (sel.args[2]) {
|
|
5477
|
-
lvar = sel.args[2].variable;
|
|
5478
|
-
}
|
|
5479
|
-
//var lsel = sel.sels;
|
|
5500
|
+
} else if (sel.selid === 'IF') {
|
|
5501
|
+
var nest = processSelector(sel.args, 0, value);
|
|
5480
5502
|
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
if (lmin === 0) {
|
|
5484
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5485
|
-
retval = [value];
|
|
5503
|
+
if (nest.length === 0) {
|
|
5504
|
+
return [];
|
|
5486
5505
|
} else {
|
|
5487
|
-
if (
|
|
5488
|
-
|
|
5506
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5507
|
+
return [value];
|
|
5508
|
+
} else {
|
|
5509
|
+
return processSelector(selectors, sidx + 1, value);
|
|
5489
5510
|
}
|
|
5490
|
-
retval = retval.concat(processSelector(selectors, sidx + 1, value));
|
|
5491
5511
|
}
|
|
5492
|
-
}
|
|
5512
|
+
} else if (sel.selid === 'REPEAT') {
|
|
5493
5513
|
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5514
|
+
var lvar,
|
|
5515
|
+
lmax,
|
|
5516
|
+
lmin = sel.args[0].value;
|
|
5517
|
+
if (!sel.args[1]) {
|
|
5518
|
+
lmax = lmin; // Add security break
|
|
5519
|
+
} else {
|
|
5520
|
+
lmax = sel.args[1].value;
|
|
5521
|
+
}
|
|
5522
|
+
if (sel.args[2]) {
|
|
5523
|
+
lvar = sel.args[2].variable;
|
|
5524
|
+
}
|
|
5525
|
+
//var lsel = sel.sels;
|
|
5497
5526
|
|
|
5498
|
-
var
|
|
5499
|
-
while (nests.length > 0) {
|
|
5500
|
-
var nest = nests[0];
|
|
5527
|
+
var retval = [];
|
|
5501
5528
|
|
|
5502
|
-
|
|
5503
|
-
if (
|
|
5529
|
+
if (lmin === 0) {
|
|
5530
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5531
|
+
retval = [value];
|
|
5532
|
+
} else {
|
|
5504
5533
|
if (lvar) {
|
|
5505
|
-
alasql.vars[lvar] =
|
|
5534
|
+
alasql.vars[lvar] = 0;
|
|
5506
5535
|
}
|
|
5536
|
+
retval = retval.concat(processSelector(selectors, sidx + 1, value));
|
|
5537
|
+
}
|
|
5538
|
+
}
|
|
5507
5539
|
|
|
5508
|
-
|
|
5540
|
+
// var nests = processSelector(sel.sels,0,value).slice();
|
|
5541
|
+
if (lmax > 0) {
|
|
5542
|
+
var nests = [{value: value, lvl: 1}];
|
|
5509
5543
|
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5544
|
+
var i = 0;
|
|
5545
|
+
while (nests.length > 0) {
|
|
5546
|
+
var nest = nests[0];
|
|
5547
|
+
|
|
5548
|
+
nests.shift();
|
|
5549
|
+
if (nest.lvl <= lmax) {
|
|
5550
|
+
if (lvar) {
|
|
5551
|
+
alasql.vars[lvar] = nest.lvl;
|
|
5552
|
+
}
|
|
5553
|
+
|
|
5554
|
+
var nest1 = processSelector(sel.sels, 0, nest.value);
|
|
5555
|
+
|
|
5556
|
+
nest1.forEach(function (n) {
|
|
5557
|
+
nests.push({value: n, lvl: nest.lvl + 1});
|
|
5558
|
+
});
|
|
5559
|
+
if (nest.lvl >= lmin) {
|
|
5560
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5561
|
+
retval = retval.concat(nest1);
|
|
5562
|
+
//return nests;
|
|
5563
|
+
} else {
|
|
5564
|
+
nest1.forEach(function (n) {
|
|
5565
|
+
retval = retval.concat(processSelector(selectors, sidx + 1, n));
|
|
5566
|
+
});
|
|
5567
|
+
}
|
|
5521
5568
|
}
|
|
5522
5569
|
}
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5570
|
+
// Security brake
|
|
5571
|
+
i++;
|
|
5572
|
+
if (i > INFINITE_LOOP_BREAK) {
|
|
5573
|
+
throw new Error('Infinite loop brake. Number of iterations = ' + i);
|
|
5574
|
+
}
|
|
5528
5575
|
}
|
|
5529
5576
|
}
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
}
|
|
5543
|
-
} else if (sel.selid === 'TO') {
|
|
5544
|
-
|
|
5545
|
-
var oldv = alasql.vars[sel.args[0]];
|
|
5546
|
-
var newv = [];
|
|
5547
|
-
if (oldv !== undefined) {
|
|
5577
|
+
return retval;
|
|
5578
|
+
} else if (sel.selid === 'OF') {
|
|
5579
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5580
|
+
return [value];
|
|
5581
|
+
} else {
|
|
5582
|
+
var r1 = [];
|
|
5583
|
+
Object.keys(value).forEach(function (keyv) {
|
|
5584
|
+
alasql.vars[sel.args[0].variable] = keyv;
|
|
5585
|
+
r1 = r1.concat(processSelector(selectors, sidx + 1, value[keyv]));
|
|
5586
|
+
});
|
|
5587
|
+
return r1;
|
|
5588
|
+
}
|
|
5589
|
+
} else if (sel.selid === 'TO') {
|
|
5548
5590
|
|
|
5549
|
-
|
|
5591
|
+
var oldv = alasql.vars[sel.args[0]];
|
|
5592
|
+
var newv = [];
|
|
5593
|
+
if (oldv !== undefined) {
|
|
5550
5594
|
|
|
5551
|
-
|
|
5552
|
-
newv = [];
|
|
5553
|
-
}
|
|
5554
|
-
newv.push(value);
|
|
5595
|
+
newv = oldv.slice(0);
|
|
5555
5596
|
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
var r1 = processSelector(selectors, sidx + 1, value);
|
|
5597
|
+
} else {
|
|
5598
|
+
newv = [];
|
|
5599
|
+
}
|
|
5600
|
+
newv.push(value);
|
|
5561
5601
|
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5602
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5603
|
+
return [value];
|
|
5604
|
+
} else {
|
|
5605
|
+
alasql.vars[sel.args[0]] = newv;
|
|
5606
|
+
var r1 = processSelector(selectors, sidx + 1, value);
|
|
5565
5607
|
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
} else {
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
}
|
|
5587
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5588
|
-
return [val];
|
|
5589
|
-
} else {
|
|
5590
|
-
return processSelector(selectors, sidx + 1, val);
|
|
5591
|
-
}
|
|
5592
|
-
} else if (sel.selid === 'AVG') {
|
|
5593
|
-
nest = processSelector(sel.args, 0, value);
|
|
5594
|
-
if (nest.length > 0) {
|
|
5595
|
-
val =
|
|
5596
|
-
nest.reduce(function (sum, current) {
|
|
5608
|
+
alasql.vars[sel.args[0]] = oldv;
|
|
5609
|
+
return r1;
|
|
5610
|
+
}
|
|
5611
|
+
|
|
5612
|
+
} else if (sel.selid === 'ARRAY') {
|
|
5613
|
+
var nest = processSelector(sel.args, 0, value);
|
|
5614
|
+
if (nest.length > 0) {
|
|
5615
|
+
val = nest;
|
|
5616
|
+
} else {
|
|
5617
|
+
return [];
|
|
5618
|
+
}
|
|
5619
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5620
|
+
return [val];
|
|
5621
|
+
} else {
|
|
5622
|
+
return processSelector(selectors, sidx + 1, val);
|
|
5623
|
+
}
|
|
5624
|
+
} else if (sel.selid === 'SUM') {
|
|
5625
|
+
var nest = processSelector(sel.args, 0, value);
|
|
5626
|
+
if (nest.length > 0) {
|
|
5627
|
+
var val = nest.reduce(function (sum, current) {
|
|
5597
5628
|
return sum + current;
|
|
5598
|
-
}, 0)
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5629
|
+
}, 0);
|
|
5630
|
+
} else {
|
|
5631
|
+
return [];
|
|
5632
|
+
}
|
|
5633
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5634
|
+
return [val];
|
|
5635
|
+
} else {
|
|
5636
|
+
return processSelector(selectors, sidx + 1, val);
|
|
5637
|
+
}
|
|
5638
|
+
} else if (sel.selid === 'AVG') {
|
|
5639
|
+
nest = processSelector(sel.args, 0, value);
|
|
5640
|
+
if (nest.length > 0) {
|
|
5641
|
+
val =
|
|
5642
|
+
nest.reduce(function (sum, current) {
|
|
5643
|
+
return sum + current;
|
|
5644
|
+
}, 0) / nest.length;
|
|
5645
|
+
} else {
|
|
5646
|
+
return [];
|
|
5647
|
+
}
|
|
5648
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5649
|
+
return [val];
|
|
5650
|
+
} else {
|
|
5651
|
+
return processSelector(selectors, sidx + 1, val);
|
|
5652
|
+
}
|
|
5653
|
+
} else if (sel.selid === 'COUNT') {
|
|
5654
|
+
nest = processSelector(sel.args, 0, value);
|
|
5655
|
+
if (nest.length > 0) {
|
|
5656
|
+
val = nest.length;
|
|
5657
|
+
} else {
|
|
5658
|
+
return [];
|
|
5659
|
+
}
|
|
5660
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5661
|
+
return [val];
|
|
5662
|
+
} else {
|
|
5663
|
+
return processSelector(selectors, sidx + 1, val);
|
|
5664
|
+
}
|
|
5665
|
+
} else if (sel.selid === 'FIRST') {
|
|
5666
|
+
nest = processSelector(sel.args, 0, value);
|
|
5667
|
+
if (nest.length > 0) {
|
|
5668
|
+
val = nest[0];
|
|
5669
|
+
} else {
|
|
5670
|
+
return [];
|
|
5671
|
+
}
|
|
5626
5672
|
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5673
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5674
|
+
return [val];
|
|
5675
|
+
} else {
|
|
5676
|
+
return processSelector(selectors, sidx + 1, val);
|
|
5677
|
+
}
|
|
5678
|
+
} else if (sel.selid === 'LAST') {
|
|
5679
|
+
nest = processSelector(sel.args, 0, value);
|
|
5680
|
+
if (nest.length > 0) {
|
|
5681
|
+
val = nest[nest.length - 1];
|
|
5682
|
+
} else {
|
|
5683
|
+
return [];
|
|
5684
|
+
}
|
|
5639
5685
|
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5686
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5687
|
+
return [val];
|
|
5688
|
+
} else {
|
|
5689
|
+
return processSelector(selectors, sidx + 1, val);
|
|
5690
|
+
}
|
|
5691
|
+
} else if (sel.selid === 'MIN') {
|
|
5692
|
+
nest = processSelector(sel.args, 0, value);
|
|
5693
|
+
if (nest.length === 0) {
|
|
5694
|
+
return [];
|
|
5695
|
+
}
|
|
5696
|
+
var val = nest.reduce(function (min, current) {
|
|
5697
|
+
return Math.min(min, current);
|
|
5698
|
+
}, Infinity);
|
|
5699
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5700
|
+
return [val];
|
|
5701
|
+
} else {
|
|
5702
|
+
return processSelector(selectors, sidx + 1, val);
|
|
5703
|
+
}
|
|
5704
|
+
} else if (sel.selid === 'MAX') {
|
|
5705
|
+
var nest = processSelector(sel.args, 0, value);
|
|
5706
|
+
if (nest.length === 0) {
|
|
5707
|
+
return [];
|
|
5708
|
+
}
|
|
5709
|
+
var val = nest.reduce(function (max, current) {
|
|
5710
|
+
return Math.max(max, current);
|
|
5711
|
+
}, -Infinity);
|
|
5712
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5713
|
+
return [val];
|
|
5714
|
+
} else {
|
|
5715
|
+
return processSelector(selectors, sidx + 1, val);
|
|
5716
|
+
}
|
|
5717
|
+
} else if (sel.selid === 'PLUS') {
|
|
5718
|
+
var retval = [];
|
|
5719
|
+
// retval = retval.concat(processSelector(selectors,sidx+1,n))
|
|
5720
|
+
var nests = processSelector(sel.args, 0, value).slice();
|
|
5721
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5722
|
+
retval = retval.concat(nests);
|
|
5723
|
+
} else {
|
|
5724
|
+
nests.forEach(function (n) {
|
|
5725
|
+
retval = retval.concat(processSelector(selectors, sidx + 1, n));
|
|
5726
|
+
});
|
|
5727
|
+
}
|
|
5682
5728
|
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5729
|
+
var i = 0;
|
|
5730
|
+
while (nests.length > 0) {
|
|
5731
|
+
// nest = nests[0];
|
|
5732
|
+
// nests.shift();
|
|
5733
|
+
var nest = nests.shift();
|
|
5688
5734
|
|
|
5689
|
-
|
|
5735
|
+
nest = processSelector(sel.args, 0, nest);
|
|
5690
5736
|
|
|
5691
|
-
|
|
5737
|
+
nests = nests.concat(nest);
|
|
5692
5738
|
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5739
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5740
|
+
retval = retval.concat(nest);
|
|
5741
|
+
//return retval;
|
|
5742
|
+
} else {
|
|
5743
|
+
nest.forEach(function (n) {
|
|
5698
5744
|
|
|
5699
|
-
|
|
5745
|
+
var rn = processSelector(selectors, sidx + 1, n);
|
|
5700
5746
|
|
|
5701
|
-
|
|
5702
|
-
|
|
5747
|
+
retval = retval.concat(rn);
|
|
5748
|
+
});
|
|
5749
|
+
}
|
|
5750
|
+
|
|
5751
|
+
// Security brake
|
|
5752
|
+
i++;
|
|
5753
|
+
if (i > INFINITE_LOOP_BREAK) {
|
|
5754
|
+
throw new Error('Infinite loop brake. Number of iterations = ' + i);
|
|
5755
|
+
}
|
|
5703
5756
|
}
|
|
5757
|
+
return retval;
|
|
5704
5758
|
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5759
|
+
} else if (sel.selid === 'STAR') {
|
|
5760
|
+
var retval = [];
|
|
5761
|
+
retval = processSelector(selectors, sidx + 1, value);
|
|
5762
|
+
var nests = processSelector(sel.args, 0, value).slice();
|
|
5763
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5764
|
+
retval = retval.concat(nests);
|
|
5765
|
+
//return nests;
|
|
5766
|
+
} else {
|
|
5767
|
+
nests.forEach(function (n) {
|
|
5768
|
+
retval = retval.concat(processSelector(selectors, sidx + 1, n));
|
|
5769
|
+
});
|
|
5709
5770
|
}
|
|
5710
|
-
|
|
5711
|
-
|
|
5771
|
+
var i = 0;
|
|
5772
|
+
while (nests.length > 0) {
|
|
5773
|
+
var nest = nests[0];
|
|
5774
|
+
nests.shift();
|
|
5712
5775
|
|
|
5713
|
-
|
|
5714
|
-
var retval = [];
|
|
5715
|
-
retval = processSelector(selectors, sidx + 1, value);
|
|
5716
|
-
var nests = processSelector(sel.args, 0, value).slice();
|
|
5717
|
-
if (sidx + 1 + 1 > selectors.length) {
|
|
5718
|
-
retval = retval.concat(nests);
|
|
5719
|
-
//return nests;
|
|
5720
|
-
} else {
|
|
5721
|
-
nests.forEach(function (n) {
|
|
5722
|
-
retval = retval.concat(processSelector(selectors, sidx + 1, n));
|
|
5723
|
-
});
|
|
5724
|
-
}
|
|
5725
|
-
var i = 0;
|
|
5726
|
-
while (nests.length > 0) {
|
|
5727
|
-
var nest = nests[0];
|
|
5728
|
-
nests.shift();
|
|
5776
|
+
nest = processSelector(sel.args, 0, nest);
|
|
5729
5777
|
|
|
5730
|
-
|
|
5778
|
+
nests = nests.concat(nest);
|
|
5731
5779
|
|
|
5732
|
-
|
|
5780
|
+
if (sidx + 1 + 1 <= selectors.length) {
|
|
5781
|
+
nest.forEach(function (n) {
|
|
5782
|
+
retval = retval.concat(processSelector(selectors, sidx + 1, n));
|
|
5783
|
+
});
|
|
5784
|
+
}
|
|
5733
5785
|
|
|
5786
|
+
// Security brake
|
|
5787
|
+
i++;
|
|
5788
|
+
if (i > INFINITE_LOOP_BREAK) {
|
|
5789
|
+
throw new Error('Infinite loop brake. Number of iterations = ' + i);
|
|
5790
|
+
}
|
|
5791
|
+
}
|
|
5792
|
+
|
|
5793
|
+
return retval;
|
|
5794
|
+
} else if (sel.selid === 'QUESTION') {
|
|
5795
|
+
var retval = [];
|
|
5796
|
+
retval = retval.concat(processSelector(selectors, sidx + 1, value));
|
|
5797
|
+
var nest = processSelector(sel.args, 0, value);
|
|
5734
5798
|
if (sidx + 1 + 1 <= selectors.length) {
|
|
5735
5799
|
nest.forEach(function (n) {
|
|
5736
5800
|
retval = retval.concat(processSelector(selectors, sidx + 1, n));
|
|
5737
5801
|
});
|
|
5738
5802
|
}
|
|
5803
|
+
return retval;
|
|
5804
|
+
} else if (sel.selid === 'WITH') {
|
|
5805
|
+
var nest = processSelector(sel.args, 0, value);
|
|
5739
5806
|
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
throw new Error('Infinite loop brake. Number of iterations = ' + i);
|
|
5744
|
-
}
|
|
5745
|
-
}
|
|
5746
|
-
|
|
5747
|
-
return retval;
|
|
5748
|
-
} else if (sel.selid === 'QUESTION') {
|
|
5749
|
-
var retval = [];
|
|
5750
|
-
retval = retval.concat(processSelector(selectors, sidx + 1, value));
|
|
5751
|
-
var nest = processSelector(sel.args, 0, value);
|
|
5752
|
-
if (sidx + 1 + 1 <= selectors.length) {
|
|
5753
|
-
nest.forEach(function (n) {
|
|
5754
|
-
retval = retval.concat(processSelector(selectors, sidx + 1, n));
|
|
5755
|
-
});
|
|
5756
|
-
}
|
|
5757
|
-
return retval;
|
|
5758
|
-
} else if (sel.selid === 'WITH') {
|
|
5759
|
-
var nest = processSelector(sel.args, 0, value);
|
|
5760
|
-
|
|
5761
|
-
if (nest.length === 0) {
|
|
5762
|
-
return [];
|
|
5763
|
-
} else {
|
|
5807
|
+
if (nest.length === 0) {
|
|
5808
|
+
return [];
|
|
5809
|
+
} else {
|
|
5764
5810
|
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5811
|
+
var r = {status: 1, values: nest};
|
|
5812
|
+
}
|
|
5813
|
+
} else if (sel.selid === 'ROOT') {
|
|
5814
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5815
|
+
return [value];
|
|
5816
|
+
} else {
|
|
5817
|
+
return processSelector(selectors, sidx + 1, fromdata);
|
|
5818
|
+
}
|
|
5770
5819
|
} else {
|
|
5771
|
-
|
|
5820
|
+
throw new Error('Wrong selector ' + sel.selid);
|
|
5772
5821
|
}
|
|
5822
|
+
} else if (sel.srchid) {
|
|
5823
|
+
var r = alasql.srch[sel.srchid.toUpperCase()](value, sel.args, stope, params);
|
|
5824
|
+
|
|
5773
5825
|
} else {
|
|
5774
|
-
throw new Error('
|
|
5826
|
+
throw new Error('Selector not found');
|
|
5775
5827
|
}
|
|
5776
|
-
} else if (sel.srchid) {
|
|
5777
|
-
var r = alasql.srch[sel.srchid.toUpperCase()](value, sel.args, stope, params);
|
|
5778
|
-
|
|
5779
|
-
} else {
|
|
5780
|
-
throw new Error('Selector not found');
|
|
5781
|
-
}
|
|
5782
5828
|
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5829
|
+
if (typeof r === 'undefined') {
|
|
5830
|
+
r = {status: 1, values: [value]};
|
|
5831
|
+
}
|
|
5786
5832
|
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5833
|
+
var res = [];
|
|
5834
|
+
if (r.status === 1) {
|
|
5835
|
+
var arr = r.values;
|
|
5790
5836
|
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5837
|
+
if (sidx + 1 + 1 > selectors.length) {
|
|
5838
|
+
// if(sidx+1+1 > selectors.length) {
|
|
5839
|
+
res = arr;
|
|
5794
5840
|
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5841
|
+
} else {
|
|
5842
|
+
for (var i = 0; i < r.values.length; i++) {
|
|
5843
|
+
res = res.concat(processSelector(selectors, sidx + 1, arr[i]));
|
|
5844
|
+
}
|
|
5798
5845
|
}
|
|
5799
5846
|
}
|
|
5847
|
+
return res;
|
|
5800
5848
|
}
|
|
5801
|
-
return res;
|
|
5802
|
-
}
|
|
5803
5849
|
|
|
5804
|
-
|
|
5850
|
+
if (selectors !== undefined && selectors.length > 0) {
|
|
5805
5851
|
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5852
|
+
if (
|
|
5853
|
+
selectors &&
|
|
5854
|
+
selectors[0] &&
|
|
5855
|
+
selectors[0].srchid === 'PROP' &&
|
|
5856
|
+
selectors[0].args &&
|
|
5857
|
+
selectors[0].args[0]
|
|
5858
|
+
) {
|
|
5813
5859
|
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5860
|
+
if (selectors[0].args[0].toUpperCase() === 'XML') {
|
|
5861
|
+
stope.mode = 'XML';
|
|
5862
|
+
selectors.shift();
|
|
5863
|
+
} else if (selectors[0].args[0].toUpperCase() === 'HTML') {
|
|
5864
|
+
stope.mode = 'HTML';
|
|
5865
|
+
selectors.shift();
|
|
5866
|
+
} else if (selectors[0].args[0].toUpperCase() === 'JSON') {
|
|
5867
|
+
stope.mode = 'JSON';
|
|
5868
|
+
selectors.shift();
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
if (selectors.length > 0 && selectors[0].srchid === 'VALUE') {
|
|
5872
|
+
stope.value = true;
|
|
5822
5873
|
selectors.shift();
|
|
5823
5874
|
}
|
|
5824
5875
|
}
|
|
5825
|
-
if (selectors.length > 0 && selectors[0].srchid === 'VALUE') {
|
|
5826
|
-
stope.value = true;
|
|
5827
|
-
selectors.shift();
|
|
5828
|
-
}
|
|
5829
|
-
}
|
|
5830
|
-
|
|
5831
|
-
if (this.from instanceof yy.Column) {
|
|
5832
|
-
var dbid = this.from.databaseid || databaseid;
|
|
5833
|
-
fromdata = alasql.databases[dbid].tables[this.from.columnid].data;
|
|
5834
|
-
//selectors.unshift({srchid:'CHILD'});
|
|
5835
|
-
} else if (this.from instanceof yy.FuncValue && alasql.from[this.from.funcid.toUpperCase()]) {
|
|
5836
|
-
var args = this.from.args.map(function (arg) {
|
|
5837
|
-
var as = arg.toJS();
|
|
5838
5876
|
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5877
|
+
if (this.from instanceof yy.Column) {
|
|
5878
|
+
var dbid = this.from.databaseid || databaseid;
|
|
5879
|
+
fromdata = alasql.databases[dbid].tables[this.from.columnid].data;
|
|
5880
|
+
//selectors.unshift({srchid:'CHILD'});
|
|
5881
|
+
} else if (this.from instanceof yy.FuncValue && alasql.from[this.from.funcid.toUpperCase()]) {
|
|
5882
|
+
var args = this.from.args.map(function (arg) {
|
|
5883
|
+
var as = arg.toJS();
|
|
5842
5884
|
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
} else if (typeof this.from === 'undefined') {
|
|
5846
|
-
fromdata = alasql.databases[databaseid].objects;
|
|
5847
|
-
} else {
|
|
5848
|
-
var fromfn = new Function('params,alasql', 'var y;return ' + this.from.toJS());
|
|
5849
|
-
fromdata = fromfn(params, alasql);
|
|
5850
|
-
// Check for Mogo Collections
|
|
5851
|
-
if (
|
|
5852
|
-
typeof Mongo === 'object' &&
|
|
5853
|
-
typeof Mongo.Collection !== 'object' &&
|
|
5854
|
-
fromdata instanceof Mongo.Collection
|
|
5855
|
-
) {
|
|
5856
|
-
fromdata = fromdata.find().fetch();
|
|
5857
|
-
}
|
|
5858
|
-
|
|
5859
|
-
// if(typeof fromdata == 'object' && Array.isArray(fromdata)) {
|
|
5860
|
-
// selectors.unshift({srchid:'CHILD'});
|
|
5861
|
-
// }
|
|
5862
|
-
}
|
|
5863
|
-
|
|
5864
|
-
// If source data is array than first step is to run over array
|
|
5865
|
-
// var selidx = 0;
|
|
5866
|
-
// var selvalue = fromdata;
|
|
5867
|
-
|
|
5868
|
-
if (selectors !== undefined && selectors.length > 0) {
|
|
5869
|
-
// Init variables for TO() selectors
|
|
5870
|
-
|
|
5871
|
-
if (false) {
|
|
5872
|
-
selectors.forEach(function (selector) {
|
|
5873
|
-
if (selector.srchid === 'TO') {
|
|
5874
|
-
//* @todo move to TO selector
|
|
5875
|
-
alasql.vars[selector.args[0]] = [];
|
|
5876
|
-
// TODO - process nested selectors
|
|
5877
|
-
}
|
|
5885
|
+
var fn = new Function('params,alasql', 'var y;return ' + as).bind(this);
|
|
5886
|
+
return fn(params, alasql);
|
|
5878
5887
|
});
|
|
5879
|
-
}
|
|
5880
5888
|
|
|
5881
|
-
|
|
5882
|
-
} else {
|
|
5883
|
-
res = fromdata;
|
|
5884
|
-
}
|
|
5885
|
-
|
|
5886
|
-
if (this.into) {
|
|
5887
|
-
var a1, a2;
|
|
5888
|
-
if (typeof this.into.args[0] !== 'undefined') {
|
|
5889
|
-
a1 = new Function('params,alasql', 'var y;return ' + this.into.args[0].toJS())(
|
|
5890
|
-
params,
|
|
5891
|
-
alasql
|
|
5892
|
-
);
|
|
5893
|
-
}
|
|
5894
|
-
if (typeof this.into.args[1] !== 'undefined') {
|
|
5895
|
-
a2 = new Function('params,alasql', 'var y;return ' + this.into.args[1].toJS())(
|
|
5896
|
-
params,
|
|
5897
|
-
alasql
|
|
5898
|
-
);
|
|
5899
|
-
}
|
|
5900
|
-
res = alasql.into[this.into.funcid.toUpperCase()](a1, a2, res, [], cb);
|
|
5901
|
-
} else {
|
|
5902
|
-
if (stope.value && res.length > 0) {
|
|
5903
|
-
res = res[0];
|
|
5904
|
-
}
|
|
5905
|
-
if (cb) {
|
|
5906
|
-
res = cb(res);
|
|
5907
|
-
}
|
|
5908
|
-
}
|
|
5909
|
-
return res;
|
|
5910
|
-
}
|
|
5911
|
-
|
|
5912
|
-
/**
|
|
5913
|
-
Search class
|
|
5914
|
-
@class
|
|
5915
|
-
@example
|
|
5916
|
-
SEARCH SUM(/a) FROM ? -- search over parameter object
|
|
5917
|
-
*/
|
|
5918
|
-
|
|
5919
|
-
yy.Search = function (params) {
|
|
5920
|
-
return yy.extend(this, params);
|
|
5921
|
-
};
|
|
5922
|
-
|
|
5923
|
-
yy.Search.prototype.toString = function () {
|
|
5924
|
-
var s = 'SEARCH' + ' ';
|
|
5925
|
-
if (this.selectors) {
|
|
5926
|
-
s += this.selectors.toString();
|
|
5927
|
-
}
|
|
5928
|
-
if (this.from) {
|
|
5929
|
-
s += 'FROM' + ' ' + this.from.toString();
|
|
5930
|
-
}
|
|
5931
|
-
|
|
5932
|
-
return s;
|
|
5933
|
-
};
|
|
5934
|
-
|
|
5935
|
-
yy.Search.prototype.toJS = function (context) {
|
|
5936
|
-
|
|
5937
|
-
var s = 'this.queriesfn[' + (this.queriesidx - 1) + '](this.params,null,' + context + ')';
|
|
5938
|
-
// var s = '';
|
|
5939
|
-
return s;
|
|
5940
|
-
};
|
|
5941
|
-
|
|
5942
|
-
yy.Search.prototype.compile = function (databaseid) {
|
|
5943
|
-
var dbid = databaseid;
|
|
5944
|
-
var self = this;
|
|
5889
|
+
fromdata = alasql.from[this.from.funcid.toUpperCase()].apply(this, args);
|
|
5945
5890
|
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5891
|
+
} else if (typeof this.from === 'undefined') {
|
|
5892
|
+
fromdata = alasql.databases[databaseid].objects;
|
|
5893
|
+
} else {
|
|
5894
|
+
var fromfn = new Function('params,alasql', 'var y;return ' + this.from.toJS());
|
|
5895
|
+
fromdata = fromfn(params, alasql);
|
|
5896
|
+
// Check for Mogo Collections
|
|
5897
|
+
if (
|
|
5898
|
+
typeof Mongo === 'object' &&
|
|
5899
|
+
typeof Mongo.Collection !== 'object' &&
|
|
5900
|
+
fromdata instanceof Mongo.Collection
|
|
5901
|
+
) {
|
|
5902
|
+
fromdata = fromdata.find().fetch();
|
|
5955
5903
|
}
|
|
5956
|
-
});
|
|
5957
5904
|
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
return statement;
|
|
5963
|
-
};
|
|
5905
|
+
// if(typeof fromdata == 'object' && Array.isArray(fromdata)) {
|
|
5906
|
+
// selectors.unshift({srchid:'CHILD'});
|
|
5907
|
+
// }
|
|
5908
|
+
}
|
|
5964
5909
|
|
|
5965
|
-
//
|
|
5966
|
-
|
|
5910
|
+
// If source data is array than first step is to run over array
|
|
5911
|
+
// var selidx = 0;
|
|
5912
|
+
// var selvalue = fromdata;
|
|
5967
5913
|
|
|
5968
|
-
|
|
5914
|
+
if (selectors !== undefined && selectors.length > 0) {
|
|
5915
|
+
// Init variables for TO() selectors
|
|
5969
5916
|
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5917
|
+
if (false) {
|
|
5918
|
+
selectors.forEach(function (selector) {
|
|
5919
|
+
if (selector.srchid === 'TO') {
|
|
5920
|
+
//* @todo move to TO selector
|
|
5921
|
+
alasql.vars[selector.args[0]] = [];
|
|
5922
|
+
// TODO - process nested selectors
|
|
5923
|
+
}
|
|
5924
|
+
});
|
|
5975
5925
|
}
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
return {status: 1, values: arr};
|
|
5979
|
-
} else {
|
|
5980
|
-
return {status: -1, values: []};
|
|
5981
|
-
}
|
|
5982
|
-
} else {
|
|
5983
|
-
if (
|
|
5984
|
-
typeof val !== 'object' ||
|
|
5985
|
-
val === null ||
|
|
5986
|
-
typeof args !== 'object' ||
|
|
5987
|
-
typeof val[args[0]] === 'undefined'
|
|
5988
|
-
) {
|
|
5989
|
-
return {status: -1, values: []};
|
|
5926
|
+
|
|
5927
|
+
res = processSelector(selectors, 0, fromdata);
|
|
5990
5928
|
} else {
|
|
5991
|
-
|
|
5929
|
+
res = fromdata;
|
|
5992
5930
|
}
|
|
5993
|
-
}
|
|
5994
|
-
};
|
|
5995
|
-
|
|
5996
|
-
alasql.srch.APROP = function (val, args) {
|
|
5997
|
-
if (
|
|
5998
|
-
typeof val !== 'object' ||
|
|
5999
|
-
val === null ||
|
|
6000
|
-
typeof args !== 'object' ||
|
|
6001
|
-
typeof val[args[0]] === 'undefined'
|
|
6002
|
-
) {
|
|
6003
|
-
return {status: 1, values: [undefined]};
|
|
6004
|
-
} else {
|
|
6005
|
-
return {status: 1, values: [val[args[0]]]};
|
|
6006
|
-
}
|
|
6007
|
-
};
|
|
6008
5931
|
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
if (
|
|
6025
|
-
val
|
|
6026
|
-
.toUpperCase()
|
|
6027
|
-
.match(
|
|
6028
|
-
new RegExp(
|
|
6029
|
-
'^' +
|
|
6030
|
-
exprfn(val, alasql, params).toUpperCase().replace(/%/g, '.*').replace(/\?|_/g, '.') +
|
|
6031
|
-
'$'
|
|
6032
|
-
),
|
|
6033
|
-
'g'
|
|
6034
|
-
)
|
|
6035
|
-
) {
|
|
6036
|
-
return {status: 1, values: [val]};
|
|
6037
|
-
} else {
|
|
6038
|
-
return {status: -1, values: []};
|
|
6039
|
-
}
|
|
6040
|
-
};
|
|
6041
|
-
|
|
6042
|
-
alasql.srch.ATTR = function (val, args, stope) {
|
|
6043
|
-
if (stope.mode === 'XML') {
|
|
6044
|
-
if (typeof args === 'undefined') {
|
|
6045
|
-
return {status: 1, values: [val.attributes]};
|
|
5932
|
+
if (this.into) {
|
|
5933
|
+
var a1, a2;
|
|
5934
|
+
if (typeof this.into.args[0] !== 'undefined') {
|
|
5935
|
+
a1 = new Function('params,alasql', 'var y;return ' + this.into.args[0].toJS())(
|
|
5936
|
+
params,
|
|
5937
|
+
alasql
|
|
5938
|
+
);
|
|
5939
|
+
}
|
|
5940
|
+
if (typeof this.into.args[1] !== 'undefined') {
|
|
5941
|
+
a2 = new Function('params,alasql', 'var y;return ' + this.into.args[1].toJS())(
|
|
5942
|
+
params,
|
|
5943
|
+
alasql
|
|
5944
|
+
);
|
|
5945
|
+
}
|
|
5946
|
+
res = alasql.into[this.into.funcid.toUpperCase()](a1, a2, res, [], cb);
|
|
6046
5947
|
} else {
|
|
6047
|
-
if (
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
return {status: 1, values: [val.attributes[args[0]]]};
|
|
6053
|
-
} else {
|
|
6054
|
-
return {status: -1, values: []};
|
|
5948
|
+
if (stope.value && res.length > 0) {
|
|
5949
|
+
res = res[0];
|
|
5950
|
+
}
|
|
5951
|
+
if (cb) {
|
|
5952
|
+
res = cb(res);
|
|
6055
5953
|
}
|
|
6056
5954
|
}
|
|
6057
|
-
|
|
6058
|
-
throw new Error('ATTR is not using in usual mode');
|
|
6059
|
-
}
|
|
6060
|
-
};
|
|
6061
|
-
|
|
6062
|
-
alasql.srch.CONTENT = function (val, args, stope) {
|
|
6063
|
-
if (stope.mode === 'XML') {
|
|
6064
|
-
return {status: 1, values: [val.content]};
|
|
6065
|
-
} else {
|
|
6066
|
-
throw new Error('ATTR is not using in usual mode');
|
|
6067
|
-
}
|
|
6068
|
-
};
|
|
6069
|
-
|
|
6070
|
-
alasql.srch.SHARP = function (val, args) {
|
|
6071
|
-
var obj = alasql.databases[alasql.useid].objects[args[0]];
|
|
6072
|
-
if (typeof val !== 'undefined' && val === obj) {
|
|
6073
|
-
return {status: 1, values: [val]};
|
|
6074
|
-
} else {
|
|
6075
|
-
return {status: -1, values: []};
|
|
5955
|
+
return res;
|
|
6076
5956
|
}
|
|
6077
5957
|
};
|
|
6078
5958
|
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
return {status: -1, values: []};
|
|
6084
|
-
};
|
|
5959
|
+
// List of search functions
|
|
5960
|
+
alasql.srch = {
|
|
5961
|
+
PROP(val, args, stope) {
|
|
6085
5962
|
|
|
6086
|
-
|
|
5963
|
+
if (stope.mode === 'XML') {
|
|
5964
|
+
const values = val.children.filter((v) => v.name.toUpperCase() === args[0].toUpperCase());
|
|
6087
5965
|
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
5966
|
+
return {
|
|
5967
|
+
status: values.length ? 1 : -1,
|
|
5968
|
+
values,
|
|
5969
|
+
};
|
|
6091
5970
|
} else {
|
|
6092
|
-
if (
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
};
|
|
5971
|
+
if (
|
|
5972
|
+
typeof val !== 'object' ||
|
|
5973
|
+
val === null ||
|
|
5974
|
+
typeof args !== 'object' ||
|
|
5975
|
+
typeof val[args[0]] === 'undefined'
|
|
5976
|
+
) {
|
|
5977
|
+
return {status: -1, values: []};
|
|
6099
5978
|
} else {
|
|
6100
|
-
return {
|
|
6101
|
-
status: 1,
|
|
6102
|
-
values: Object.keys(val).map(function (key) {
|
|
6103
|
-
return val[key];
|
|
6104
|
-
}),
|
|
6105
|
-
};
|
|
5979
|
+
return {status: 1, values: [val[args[0]]]};
|
|
6106
5980
|
}
|
|
6107
5981
|
}
|
|
6108
|
-
}
|
|
6109
|
-
// If primitive value
|
|
6110
|
-
return {status: 1, values: []};
|
|
6111
|
-
}
|
|
6112
|
-
};
|
|
5982
|
+
},
|
|
6113
5983
|
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
}
|
|
5984
|
+
APROP(val, args) {
|
|
5985
|
+
if (
|
|
5986
|
+
typeof val !== 'object' ||
|
|
5987
|
+
val === null ||
|
|
5988
|
+
typeof args !== 'object' ||
|
|
5989
|
+
typeof val[args[0]] === 'undefined'
|
|
5990
|
+
) {
|
|
5991
|
+
return {status: 1, values: [undefined]};
|
|
5992
|
+
} else {
|
|
5993
|
+
return {status: 1, values: [val[args[0]]]};
|
|
5994
|
+
}
|
|
5995
|
+
},
|
|
6123
5996
|
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
}
|
|
6133
|
-
};
|
|
5997
|
+
EQ(val, args, stope, params) {
|
|
5998
|
+
var exprs = args[0].toJS('x', '');
|
|
5999
|
+
var exprfn = new Function('x,alasql,params', 'return ' + exprs);
|
|
6000
|
+
if (val === exprfn(val, alasql, params)) {
|
|
6001
|
+
return {status: 1, values: [val]};
|
|
6002
|
+
} else {
|
|
6003
|
+
return {status: -1, values: []};
|
|
6004
|
+
}
|
|
6005
|
+
},
|
|
6134
6006
|
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6007
|
+
// Test expression
|
|
6008
|
+
LIKE(val, args, stope, params) {
|
|
6009
|
+
var exprs = args[0].toJS('x', '');
|
|
6010
|
+
var exprfn = new Function('x,alasql,params', 'return ' + exprs);
|
|
6011
|
+
if (
|
|
6012
|
+
val
|
|
6013
|
+
.toUpperCase()
|
|
6014
|
+
.match(
|
|
6015
|
+
new RegExp(
|
|
6016
|
+
'^' +
|
|
6017
|
+
exprfn(val, alasql, params).toUpperCase().replace(/%/g, '.*').replace(/\?|_/g, '.') +
|
|
6018
|
+
'$'
|
|
6019
|
+
),
|
|
6020
|
+
'g'
|
|
6021
|
+
)
|
|
6022
|
+
) {
|
|
6023
|
+
return {status: 1, values: [val]};
|
|
6024
|
+
} else {
|
|
6025
|
+
return {status: -1, values: []};
|
|
6026
|
+
}
|
|
6027
|
+
},
|
|
6142
6028
|
|
|
6143
|
-
|
|
6029
|
+
ATTR(val, args, stope) {
|
|
6030
|
+
if (stope.mode === 'XML') {
|
|
6031
|
+
if (typeof args === 'undefined') {
|
|
6032
|
+
return {status: 1, values: [val.attributes]};
|
|
6033
|
+
} else {
|
|
6034
|
+
if (
|
|
6035
|
+
typeof val === 'object' &&
|
|
6036
|
+
typeof val.attributes === 'object' &&
|
|
6037
|
+
typeof val.attributes[args[0]] !== 'undefined'
|
|
6038
|
+
) {
|
|
6039
|
+
return {status: 1, values: [val.attributes[args[0]]]};
|
|
6040
|
+
} else {
|
|
6041
|
+
return {status: -1, values: []};
|
|
6042
|
+
}
|
|
6043
|
+
}
|
|
6044
|
+
} else {
|
|
6045
|
+
throw new Error('ATTR is not using in usual mode');
|
|
6046
|
+
}
|
|
6047
|
+
},
|
|
6144
6048
|
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
}
|
|
6152
|
-
};
|
|
6049
|
+
CONTENT(val, args, stope) {
|
|
6050
|
+
if (stope.mode !== 'XML') {
|
|
6051
|
+
throw new Error('ATTR is not using in usual mode');
|
|
6052
|
+
}
|
|
6053
|
+
return {status: 1, values: [val.content]};
|
|
6054
|
+
},
|
|
6153
6055
|
|
|
6154
|
-
|
|
6155
|
-
alasql.
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
}
|
|
6056
|
+
SHARP(val, args) {
|
|
6057
|
+
const obj = alasql.databases[alasql.useid].objects[args[0]];
|
|
6058
|
+
if (val !== undefined && val === obj) {
|
|
6059
|
+
return {status: 1, values: [val]};
|
|
6060
|
+
} else {
|
|
6061
|
+
return {status: -1, values: []};
|
|
6062
|
+
}
|
|
6063
|
+
},
|
|
6162
6064
|
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
return {status: 1, values: [val]};
|
|
6167
|
-
} else {
|
|
6168
|
-
return {status: -1, values: []};
|
|
6169
|
-
}
|
|
6170
|
-
};
|
|
6065
|
+
PARENT(/*val,args,stope*/) {
|
|
6066
|
+
// TODO: implement
|
|
6067
|
+
console.error('PARENT not implemented', arguments);
|
|
6171
6068
|
|
|
6172
|
-
// Transform expression
|
|
6173
|
-
alasql.srch.EDGE = function (val) {
|
|
6174
|
-
if (val.$node === 'EDGE') {
|
|
6175
|
-
return {status: 1, values: [val]};
|
|
6176
|
-
} else {
|
|
6177
6069
|
return {status: -1, values: []};
|
|
6178
|
-
}
|
|
6179
|
-
};
|
|
6070
|
+
},
|
|
6180
6071
|
|
|
6181
|
-
|
|
6182
|
-
alasql.srch.EX = function (val, args, stope, params) {
|
|
6183
|
-
var exprs = args[0].toJS('x', '');
|
|
6184
|
-
var exprfn = new Function('x,alasql,params', 'return ' + exprs);
|
|
6185
|
-
return {status: 1, values: [exprfn(val, alasql, params)]};
|
|
6186
|
-
};
|
|
6072
|
+
CHILD(val, args, stope) {
|
|
6187
6073
|
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6074
|
+
if (typeof val === 'object') {
|
|
6075
|
+
if (Array.isArray(val)) {
|
|
6076
|
+
return {status: 1, values: val};
|
|
6077
|
+
} else {
|
|
6078
|
+
if (stope.mode === 'XML') {
|
|
6079
|
+
return {
|
|
6080
|
+
status: 1,
|
|
6081
|
+
values: Object.keys(val.children).map(function (key) {
|
|
6082
|
+
return val.children[key];
|
|
6083
|
+
}),
|
|
6084
|
+
};
|
|
6085
|
+
} else {
|
|
6086
|
+
return {
|
|
6087
|
+
status: 1,
|
|
6088
|
+
values: Object.keys(val).map(function (key) {
|
|
6089
|
+
return val[key];
|
|
6090
|
+
}),
|
|
6091
|
+
};
|
|
6092
|
+
}
|
|
6197
6093
|
}
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
}
|
|
6094
|
+
} else {
|
|
6095
|
+
// If primitive value
|
|
6096
|
+
return {status: 1, values: []};
|
|
6097
|
+
}
|
|
6098
|
+
},
|
|
6203
6099
|
|
|
6204
|
-
//
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
};
|
|
6100
|
+
// Return all keys
|
|
6101
|
+
KEYS(val) {
|
|
6102
|
+
if (typeof val === 'object' && val !== null) {
|
|
6103
|
+
return {status: 1, values: Object.keys(val)};
|
|
6104
|
+
} else {
|
|
6105
|
+
// If primitive value
|
|
6106
|
+
return {status: 1, values: []};
|
|
6107
|
+
}
|
|
6108
|
+
},
|
|
6208
6109
|
|
|
6209
|
-
//
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
var
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
}
|
|
6219
|
-
};
|
|
6110
|
+
// Test expression
|
|
6111
|
+
WHERE(val, args, stope, params) {
|
|
6112
|
+
var exprs = args[0].toJS('x', '');
|
|
6113
|
+
var exprfn = new Function('x,alasql,params', 'return ' + exprs);
|
|
6114
|
+
if (exprfn(val, alasql, params)) {
|
|
6115
|
+
return {status: 1, values: [val]};
|
|
6116
|
+
} else {
|
|
6117
|
+
return {status: -1, values: []};
|
|
6118
|
+
}
|
|
6119
|
+
},
|
|
6220
6120
|
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
res = res.concat(alasql.databases[alasql.useid].objects[vv]);
|
|
6229
|
-
});
|
|
6230
|
-
}
|
|
6231
|
-
});
|
|
6232
|
-
return {status: 1, values: res};
|
|
6233
|
-
} else {
|
|
6234
|
-
return {status: -1, values: []};
|
|
6235
|
-
}
|
|
6236
|
-
};
|
|
6121
|
+
NAME(val, args) {
|
|
6122
|
+
if (val.name === args[0]) {
|
|
6123
|
+
return {status: 1, values: [val]};
|
|
6124
|
+
} else {
|
|
6125
|
+
return {status: -1, values: []};
|
|
6126
|
+
}
|
|
6127
|
+
},
|
|
6237
6128
|
|
|
6238
|
-
|
|
6239
|
-
alasql.srch.IN = function (val) {
|
|
6240
|
-
if (val.$in && val.$in.length > 0) {
|
|
6241
|
-
var res = val.$in.map(function (v) {
|
|
6242
|
-
return alasql.databases[alasql.useid].objects[v];
|
|
6243
|
-
});
|
|
6244
|
-
return {status: 1, values: res};
|
|
6245
|
-
} else {
|
|
6246
|
-
return {status: -1, values: []};
|
|
6247
|
-
}
|
|
6248
|
-
};
|
|
6129
|
+
CLASS(val, args) {
|
|
6249
6130
|
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
});
|
|
6259
|
-
}
|
|
6260
|
-
});
|
|
6261
|
-
return {status: 1, values: res};
|
|
6262
|
-
} else {
|
|
6263
|
-
return {status: -1, values: []};
|
|
6264
|
-
}
|
|
6265
|
-
};
|
|
6131
|
+
// Please avoid `===` here
|
|
6132
|
+
if (val.$class == args) {
|
|
6133
|
+
// jshint ignore:line
|
|
6134
|
+
return {status: 1, values: [val]};
|
|
6135
|
+
} else {
|
|
6136
|
+
return {status: -1, values: []};
|
|
6137
|
+
}
|
|
6138
|
+
},
|
|
6266
6139
|
|
|
6267
|
-
// Transform expression
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
}
|
|
6140
|
+
// Transform expression
|
|
6141
|
+
VERTEX(val) {
|
|
6142
|
+
if (val.$node === 'VERTEX') {
|
|
6143
|
+
return {status: 1, values: [val]};
|
|
6144
|
+
} else {
|
|
6145
|
+
return {status: -1, values: []};
|
|
6146
|
+
}
|
|
6147
|
+
},
|
|
6272
6148
|
|
|
6273
|
-
// Transform expression
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
}
|
|
6149
|
+
// Transform expression
|
|
6150
|
+
INSTANCEOF(val, args) {
|
|
6151
|
+
if (val instanceof alasql.fn[args[0]]) {
|
|
6152
|
+
return {status: 1, values: [val]};
|
|
6153
|
+
} else {
|
|
6154
|
+
return {status: -1, values: []};
|
|
6155
|
+
}
|
|
6156
|
+
},
|
|
6278
6157
|
|
|
6279
|
-
// Transform expression
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
};
|
|
6158
|
+
// Transform expression
|
|
6159
|
+
EDGE(val) {
|
|
6160
|
+
if (val.$node === 'EDGE') {
|
|
6161
|
+
return {status: 1, values: [val]};
|
|
6162
|
+
} else {
|
|
6163
|
+
return {status: -1, values: []};
|
|
6164
|
+
}
|
|
6165
|
+
},
|
|
6166
|
+
|
|
6167
|
+
// Transform expression
|
|
6168
|
+
EX(val, args, stope, params) {
|
|
6169
|
+
var exprs = args[0].toJS('x', '');
|
|
6170
|
+
var exprfn = new Function('x,alasql,params', 'return ' + exprs);
|
|
6171
|
+
return {status: 1, values: [exprfn(val, alasql, params)]};
|
|
6172
|
+
},
|
|
6173
|
+
|
|
6174
|
+
// Transform expression
|
|
6175
|
+
RETURN(val, args, stope, params) {
|
|
6176
|
+
var res = {};
|
|
6177
|
+
if (args && args.length > 0) {
|
|
6178
|
+
args.forEach(function (arg) {
|
|
6179
|
+
var exprs = arg.toJS('x', '');
|
|
6180
|
+
var exprfn = new Function('x,alasql,params', 'return ' + exprs);
|
|
6181
|
+
if (typeof arg.as === 'undefined') {
|
|
6182
|
+
arg.as = arg.toString();
|
|
6183
|
+
}
|
|
6184
|
+
res[arg.as] = exprfn(val, alasql, params);
|
|
6185
|
+
});
|
|
6186
|
+
}
|
|
6187
|
+
return {status: 1, values: [res]};
|
|
6188
|
+
},
|
|
6285
6189
|
|
|
6286
|
-
//
|
|
6287
|
-
|
|
6190
|
+
// Transform expression
|
|
6191
|
+
REF(val) {
|
|
6192
|
+
return {status: 1, values: [alasql.databases[alasql.useid].objects[val]]};
|
|
6193
|
+
},
|
|
6288
6194
|
|
|
6289
|
-
//
|
|
6195
|
+
// Transform expression
|
|
6196
|
+
OUT(val) {
|
|
6197
|
+
if (val.$out && val.$out.length > 0) {
|
|
6198
|
+
var res = val.$out.map(function (v) {
|
|
6199
|
+
return alasql.databases[alasql.useid].objects[v];
|
|
6200
|
+
});
|
|
6201
|
+
return {status: 1, values: res};
|
|
6202
|
+
} else {
|
|
6203
|
+
return {status: -1, values: []};
|
|
6204
|
+
}
|
|
6205
|
+
},
|
|
6206
|
+
|
|
6207
|
+
OUTOUT(val) {
|
|
6208
|
+
if (val.$out && val.$out.length > 0) {
|
|
6209
|
+
var res = [];
|
|
6210
|
+
val.$out.forEach(function (v) {
|
|
6211
|
+
var av = alasql.databases[alasql.useid].objects[v];
|
|
6212
|
+
if (av && av.$out && av.$out.length > 0) {
|
|
6213
|
+
av.$out.forEach(function (vv) {
|
|
6214
|
+
res = res.concat(alasql.databases[alasql.useid].objects[vv]);
|
|
6215
|
+
});
|
|
6216
|
+
}
|
|
6217
|
+
});
|
|
6218
|
+
return {status: 1, values: res};
|
|
6219
|
+
} else {
|
|
6220
|
+
return {status: -1, values: []};
|
|
6221
|
+
}
|
|
6222
|
+
},
|
|
6223
|
+
|
|
6224
|
+
// Transform expression
|
|
6225
|
+
IN(val) {
|
|
6226
|
+
if (val.$in && val.$in.length > 0) {
|
|
6227
|
+
var res = val.$in.map(function (v) {
|
|
6228
|
+
return alasql.databases[alasql.useid].objects[v];
|
|
6229
|
+
});
|
|
6230
|
+
return {status: 1, values: res};
|
|
6231
|
+
} else {
|
|
6232
|
+
return {status: -1, values: []};
|
|
6233
|
+
}
|
|
6234
|
+
},
|
|
6290
6235
|
|
|
6291
|
-
|
|
6292
|
-
|
|
6236
|
+
ININ(val) {
|
|
6237
|
+
if (val.$in && val.$in.length > 0) {
|
|
6238
|
+
var res = [];
|
|
6239
|
+
val.$in.forEach(function (v) {
|
|
6240
|
+
var av = alasql.databases[alasql.useid].objects[v];
|
|
6241
|
+
if (av && av.$in && av.$in.length > 0) {
|
|
6242
|
+
av.$in.forEach(function (vv) {
|
|
6243
|
+
res = res.concat(alasql.databases[alasql.useid].objects[vv]);
|
|
6244
|
+
});
|
|
6245
|
+
}
|
|
6246
|
+
});
|
|
6247
|
+
return {status: 1, values: res};
|
|
6248
|
+
} else {
|
|
6249
|
+
return {status: -1, values: []};
|
|
6250
|
+
}
|
|
6251
|
+
},
|
|
6293
6252
|
|
|
6294
|
-
|
|
6295
|
-
|
|
6253
|
+
// Transform expression
|
|
6254
|
+
AS(val, args) {
|
|
6255
|
+
alasql.vars[args[0]] = val;
|
|
6256
|
+
return {status: 1, values: [val]};
|
|
6257
|
+
},
|
|
6258
|
+
|
|
6259
|
+
// Transform expression
|
|
6260
|
+
AT(val, args) {
|
|
6261
|
+
var v = alasql.vars[args[0]];
|
|
6262
|
+
return {status: 1, values: [v]};
|
|
6263
|
+
},
|
|
6264
|
+
|
|
6265
|
+
// Transform expression
|
|
6266
|
+
CLONEDEEP(val) {
|
|
6267
|
+
// TODO something wrong
|
|
6268
|
+
var z = cloneDeep(val);
|
|
6269
|
+
return {status: 1, values: [z]};
|
|
6270
|
+
},
|
|
6271
|
+
|
|
6272
|
+
// // Transform expression
|
|
6273
|
+
// DELETE (val,args) {
|
|
6274
|
+
// // TODO something wrong
|
|
6275
|
+
// delete val;
|
|
6276
|
+
// return {status: 1, values: []};
|
|
6277
|
+
// },
|
|
6278
|
+
|
|
6279
|
+
// Transform expression
|
|
6280
|
+
SET(val, args, stope, params) {
|
|
6281
|
+
|
|
6282
|
+
var s = args
|
|
6283
|
+
.map(function (st) {
|
|
6296
6284
|
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6285
|
+
if (st.method === '@') {
|
|
6286
|
+
return "alasql.vars['" + st.variable + "']=" + st.expression.toJS('x', '');
|
|
6287
|
+
} else if (st.method === '$') {
|
|
6288
|
+
return "params['" + st.variable + "']=" + st.expression.toJS('x', '');
|
|
6289
|
+
} else {
|
|
6290
|
+
return "x['" + st.column.columnid + "']=" + st.expression.toJS('x', '');
|
|
6291
|
+
}
|
|
6292
|
+
})
|
|
6293
|
+
.join(';');
|
|
6294
|
+
var setfn = new Function('x,params,alasql', s);
|
|
6307
6295
|
|
|
6308
|
-
|
|
6296
|
+
setfn(val, params, alasql);
|
|
6309
6297
|
|
|
6310
|
-
|
|
6311
|
-
}
|
|
6298
|
+
return {status: 1, values: [val]};
|
|
6299
|
+
},
|
|
6312
6300
|
|
|
6313
|
-
|
|
6314
|
-
|
|
6301
|
+
ROW(val, args, stope, params) {
|
|
6302
|
+
var s = 'var y;return [';
|
|
6303
|
+
s += args.map((arg) => arg.toJS('x', '')).join(',');
|
|
6304
|
+
s += ']';
|
|
6305
|
+
var setfn = new Function('x,params,alasql', s);
|
|
6306
|
+
var rv = setfn(val, params, alasql);
|
|
6315
6307
|
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
return arg.toJS('x', '');
|
|
6319
|
-
})
|
|
6320
|
-
.join(',');
|
|
6321
|
-
s += ']';
|
|
6322
|
-
var setfn = new Function('x,params,alasql', s);
|
|
6323
|
-
var rv = setfn(val, params, alasql);
|
|
6308
|
+
return {status: 1, values: [rv]};
|
|
6309
|
+
},
|
|
6324
6310
|
|
|
6325
|
-
|
|
6326
|
-
|
|
6311
|
+
D3(val) {
|
|
6312
|
+
if (val.$node !== 'VERTEX' && val.$node === 'EDGE') {
|
|
6313
|
+
val.source = val.$in[0];
|
|
6314
|
+
val.target = val.$out[0];
|
|
6315
|
+
}
|
|
6327
6316
|
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
val.source = val.$in[0];
|
|
6331
|
-
val.target = val.$out[0];
|
|
6332
|
-
}
|
|
6317
|
+
return {status: 1, values: [val]};
|
|
6318
|
+
},
|
|
6333
6319
|
|
|
6334
|
-
|
|
6320
|
+
ORDERBY(val, args /*, stope */) {
|
|
6321
|
+
var res = val.sort(compileSearchOrder(args));
|
|
6322
|
+
return {status: 1, values: res};
|
|
6323
|
+
},
|
|
6335
6324
|
};
|
|
6336
6325
|
|
|
6337
6326
|
var compileSearchOrder = function (order) {
|
|
6338
6327
|
if (order) {
|
|
6339
|
-
|
|
6340
|
-
if (
|
|
6341
|
-
order &&
|
|
6342
|
-
order.length === 1 &&
|
|
6343
|
-
order[0].expression &&
|
|
6344
|
-
typeof order[0].expression === 'function'
|
|
6345
|
-
) {
|
|
6346
|
-
|
|
6328
|
+
if (typeof order?.[0]?.expression === 'function') {
|
|
6347
6329
|
var func = order[0].expression;
|
|
6348
|
-
|
|
6349
6330
|
return function (a, b) {
|
|
6350
6331
|
var ra = func(a),
|
|
6351
6332
|
rb = func(b);
|
|
@@ -6439,12 +6420,6 @@ var compileSearchOrder = function (order) {
|
|
|
6439
6420
|
}
|
|
6440
6421
|
};
|
|
6441
6422
|
|
|
6442
|
-
alasql.srch.ORDERBY = function (val, args /*,stope*/) {
|
|
6443
|
-
|
|
6444
|
-
var res = val.sort(compileSearchOrder(args));
|
|
6445
|
-
return {status: 1, values: res};
|
|
6446
|
-
};
|
|
6447
|
-
|
|
6448
6423
|
// Main query procedure
|
|
6449
6424
|
function queryfn(query, oldscope, cb, A, B) {
|
|
6450
6425
|
var aaa = query.sources.length;
|
|
@@ -7276,7 +7251,7 @@ function swapSources(query, h) {
|
|
|
7276
7251
|
/* global yy */
|
|
7277
7252
|
|
|
7278
7253
|
yy.Select = function (params) {
|
|
7279
|
-
return
|
|
7254
|
+
return Object.assign(this, params);
|
|
7280
7255
|
};
|
|
7281
7256
|
yy.Select.prototype.toString = function () {
|
|
7282
7257
|
var s;
|
|
@@ -7800,7 +7775,7 @@ yy.Select.prototype.execute = function (databaseid, params, cb) {
|
|
|
7800
7775
|
*/
|
|
7801
7776
|
|
|
7802
7777
|
yy.ExistsValue = function (params) {
|
|
7803
|
-
return
|
|
7778
|
+
return Object.assign(this, params);
|
|
7804
7779
|
};
|
|
7805
7780
|
yy.ExistsValue.prototype.toString = function () {
|
|
7806
7781
|
return 'EXISTS(' + this.value.toString() + ')';
|
|
@@ -8709,16 +8684,37 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8709
8684
|
",g['$$_VALUES_" + colas + "']={},g['$$_VALUES_" + colas + "'][" + colexp + ']=true';
|
|
8710
8685
|
}
|
|
8711
8686
|
if (col.aggregatorid === 'SUM') {
|
|
8712
|
-
|
|
8687
|
+
if ('funcid' in col.expression) {
|
|
8688
|
+
let colexpression = col.expression.args[0];
|
|
8689
|
+
let colexp1 = colexpression.toJS('p', tableid, defcols);
|
|
8690
|
+
return `'${colas}':(${colexp1})|| typeof ${colexp1} == 'number' ? ${colexp1} : null,`;
|
|
8691
|
+
}
|
|
8692
|
+
return `'${colas}':(${colexp})|| typeof ${colexp} == 'number' ? ${colexp} : null,`;
|
|
8713
8693
|
} else if (
|
|
8714
|
-
col.aggregatorid === 'MIN' ||
|
|
8715
|
-
col.aggregatorid === 'MAX' ||
|
|
8716
8694
|
col.aggregatorid === 'FIRST' ||
|
|
8717
8695
|
col.aggregatorid === 'LAST'
|
|
8718
8696
|
// || col.aggregatorid == 'AVG'
|
|
8719
8697
|
// ) { return "'"+col.as+'\':r[\''+col.as+'\'],'; }//f.field.arguments[0].toJS();
|
|
8720
8698
|
) {
|
|
8721
8699
|
return "'" + colas + "':" + colexp + ','; //f.field.arguments[0].toJS();
|
|
8700
|
+
} else if (col.aggregatorid === 'MIN') {
|
|
8701
|
+
if ('funcid' in col.expression) {
|
|
8702
|
+
let colexpression = col.expression.args[0];
|
|
8703
|
+
let colexp1 = colexpression.toJS('p', tableid, defcols);
|
|
8704
|
+
return `'${colas}': (typeof ${colexp1} == 'number' ? ${colexp1} : typeof ${colexp1} == 'object' ?
|
|
8705
|
+
typeof Number(${colexp1}) == 'number' && ${colexp1}!== null? ${colexp1} : null : null),`;
|
|
8706
|
+
}
|
|
8707
|
+
return `'${colas}': (typeof ${colexp} == 'number' ? ${colexp} : typeof ${colexp} == 'object' ?
|
|
8708
|
+
typeof Number(${colexp}) == 'number' && ${colexp}!== null? ${colexp} : null : null),`;
|
|
8709
|
+
} else if (col.aggregatorid === 'MAX') {
|
|
8710
|
+
if ('funcid' in col.expression) {
|
|
8711
|
+
let colexpression = col.expression.args[0];
|
|
8712
|
+
let colexp1 = colexpression.toJS('p', tableid, defcols);
|
|
8713
|
+
return `'${colas}' : (typeof ${colexp1} == 'number' ? ${colexp1} : typeof ${colexp1} == 'object' ?
|
|
8714
|
+
typeof Number(${colexp1}) == 'number' ? ${colexp1} : null : null),`;
|
|
8715
|
+
}
|
|
8716
|
+
return `'${colas}' : (typeof ${colexp} == 'number' ? ${colexp} : typeof ${colexp} == 'object' ?
|
|
8717
|
+
typeof Number(${colexp}) == 'number' ? ${colexp} : null : null),`;
|
|
8722
8718
|
} else if (col.aggregatorid === 'ARRAY') {
|
|
8723
8719
|
return "'" + colas + "':[" + colexp + '],';
|
|
8724
8720
|
} else if (col.aggregatorid === 'COUNT') {
|
|
@@ -8812,7 +8808,34 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8812
8808
|
var post = "g['$$_VALUES_" + colas + "'][" + colexp + ']=true;}';
|
|
8813
8809
|
}
|
|
8814
8810
|
if (col.aggregatorid === 'SUM') {
|
|
8815
|
-
|
|
8811
|
+
if ('funcid' in col.expression) {
|
|
8812
|
+
let colexpression = col.expression.args[0];
|
|
8813
|
+
let colexp1 = colexpression.toJS('p', tableid, defcols);
|
|
8814
|
+
return (
|
|
8815
|
+
pre +
|
|
8816
|
+
`if(g['${colas}'] == null && ${colexp1} == null){g['${colas}'] = null}
|
|
8817
|
+
else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp1}!== 'object' && typeof ${colexp1}!== 'number'){g['${colas}'] = null}
|
|
8818
|
+
else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp1} == 'number'){g['${colas}'] = ${colexp1}}
|
|
8819
|
+
else if(typeof g['${colas}']!== 'number' && typeof ${colexp1}!== 'number' && typeof ${colexp1}!== 'object'){g['${colas}'] = g['${colas}']}
|
|
8820
|
+
else if((g['${colas}'] == null || (typeof g['${colas}']!== 'number' && typeof g['${colas}']!== 'object')) && (${colexp1} == null || (typeof ${colexp1}!== 'number' && typeof ${colexp1}!== 'object'))){g['${colas}'] = null}
|
|
8821
|
+
else if(typeof g['${colas}'] == 'number' && typeof ${colexp1} ==null){g['${colas}'] = g['${colas}']}
|
|
8822
|
+
else if(typeof g['${colas}'] == null && typeof ${colexp1} =='number'){g['${colas}'] = ${colexp1}}
|
|
8823
|
+
else{g['${colas}'] += ${colexp1}||0}` +
|
|
8824
|
+
post
|
|
8825
|
+
);
|
|
8826
|
+
}
|
|
8827
|
+
return (
|
|
8828
|
+
pre +
|
|
8829
|
+
`if(g['${colas}'] == null && ${colexp} == null){g['${colas}'] = null}
|
|
8830
|
+
else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number'&& typeof ${colexp}!== 'object' && typeof ${colexp}!== 'number'){g['${colas}'] = null}
|
|
8831
|
+
else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp} == 'number'){g['${colas}'] = ${colexp}}
|
|
8832
|
+
else if(typeof g['${colas}']!== 'number' && typeof ${colexp}!== 'number' && typeof ${colexp}!== 'object'){g['${colas}'] = g['${colas}']}
|
|
8833
|
+
else if((g['${colas}'] == null || (typeof g['${colas}']!== 'number' && typeof g['${colas}']!== 'object')) && (${colexp} == null || (typeof ${colexp}!== 'number' && typeof ${colexp}!== 'object'))){g['${colas}'] = null}
|
|
8834
|
+
else if(typeof g['${colas}'] == 'number' && typeof ${colexp} ==null){g['${colas}'] = g['${colas}']}
|
|
8835
|
+
else if(typeof g['${colas}'] == null && typeof ${colexp} =='number'){g['${colas}'] = ${colexp}}
|
|
8836
|
+
else{g['${colas}'] += ${colexp}||0}` +
|
|
8837
|
+
post
|
|
8838
|
+
);
|
|
8816
8839
|
} else if (col.aggregatorid === 'COUNT') {
|
|
8817
8840
|
|
|
8818
8841
|
if (col.expression.columnid === '*') {
|
|
@@ -8833,12 +8856,48 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8833
8856
|
} else if (col.aggregatorid === 'ARRAY') {
|
|
8834
8857
|
return pre + "g['" + colas + "'].push(" + colexp + ');' + post;
|
|
8835
8858
|
} else if (col.aggregatorid === 'MIN') {
|
|
8859
|
+
if ('funcid' in col.expression) {
|
|
8860
|
+
let colexpression = col.expression.args[0];
|
|
8861
|
+
let colexp1 = colexpression.toJS('p', tableid, defcols);
|
|
8862
|
+
return (
|
|
8863
|
+
pre +
|
|
8864
|
+
`if((g['${colas}'] == null && ${colexp1}!== null) ? y = ${colexp1} : (g['${colas}']!== null &&
|
|
8865
|
+
${colexp1} == null) ? y = g['${colas}']:((y=${colexp1}) < g['${colas}'])){ if(typeof y == 'number')
|
|
8866
|
+
{g['${colas}'] = y;}else if(typeof y == 'object' && y instanceof Date){g['${colas}'] = y;}
|
|
8867
|
+
else if(typeof y == 'object' && typeof Number(y) == 'number'){g['${colas}'] = Number(y);}}
|
|
8868
|
+
else if(g['${colas}']!== null && typeof g['${colas}'] == 'object' && y instanceof Date){g['${colas}'] = g['${colas}']}
|
|
8869
|
+
else if(g['${colas}']!== null && typeof g['${colas}'] == 'object'){g['${colas}'] = Number(g['${colas}'])}` +
|
|
8870
|
+
post
|
|
8871
|
+
);
|
|
8872
|
+
}
|
|
8836
8873
|
return (
|
|
8837
|
-
pre +
|
|
8874
|
+
pre +
|
|
8875
|
+
`if((g['${colas}'] == null && ${colexp}!== null) ? y = ${colexp} : (g['${colas}']!== null &&
|
|
8876
|
+
${colexp} == null) ? y = g['${colas}']:((y=${colexp}) < g['${colas}'])){ if(typeof y == 'number')
|
|
8877
|
+
{g['${colas}'] = y;}else if(typeof y == 'object' && y instanceof Date){g['${colas}'] = y;}
|
|
8878
|
+
else if(typeof y == 'object' && typeof Number(y) == 'number'){g['${colas}'] = Number(y);}}
|
|
8879
|
+
else if(g['${colas}']!== null && typeof g['${colas}'] == 'object' && y instanceof Date){g['${colas}'] = g['${colas}']}
|
|
8880
|
+
else if(g['${colas}']!== null && typeof g['${colas}'] == 'object'){g['${colas}'] = Number(g['${colas}'])}` +
|
|
8881
|
+
post
|
|
8838
8882
|
);
|
|
8839
8883
|
} else if (col.aggregatorid === 'MAX') {
|
|
8884
|
+
if ('funcid' in col.expression) {
|
|
8885
|
+
let colexpression = col.expression.args[0];
|
|
8886
|
+
let colexp1 = colexpression.toJS('p', tableid, defcols);
|
|
8887
|
+
return (
|
|
8888
|
+
pre +
|
|
8889
|
+
`if((y=${colexp1}) > g['${colas}']){if(typeof y == 'number'){g['${colas}'] = y;}
|
|
8890
|
+
else if(typeof y == 'object' && y instanceof Date){g['${colas}'] = y;}
|
|
8891
|
+
else if(typeof y == 'object' && typeof Number(y) == 'number'){g['${colas}'] = Number(y);}}` +
|
|
8892
|
+
post
|
|
8893
|
+
);
|
|
8894
|
+
}
|
|
8840
8895
|
return (
|
|
8841
|
-
pre +
|
|
8896
|
+
pre +
|
|
8897
|
+
`if((y=${colexp}) > g['${colas}']){if(typeof y == 'number'){g['${colas}'] = y;}
|
|
8898
|
+
else if(typeof y == 'object' && y instanceof Date){g['${colas}'] = y;}
|
|
8899
|
+
else if(typeof y == 'object' && typeof Number(y) == 'number'){g['${colas}'] = Number(y);}}` +
|
|
8900
|
+
post
|
|
8842
8901
|
);
|
|
8843
8902
|
} else if (col.aggregatorid === 'FIRST') {
|
|
8844
8903
|
return '';
|
|
@@ -10036,7 +10095,7 @@ yy.Select.prototype.compileDefCols = function (query, databaseid) {
|
|
|
10036
10095
|
// SELECT UNION statement
|
|
10037
10096
|
|
|
10038
10097
|
yy.Union = function (params) {
|
|
10039
|
-
return
|
|
10098
|
+
return Object.assign(this, params);
|
|
10040
10099
|
};
|
|
10041
10100
|
yy.Union.prototype.toString = function () {
|
|
10042
10101
|
return 'UNION';
|
|
@@ -10055,7 +10114,7 @@ yy.Union.prototype.compile = function (tableid) {
|
|
|
10055
10114
|
*/
|
|
10056
10115
|
|
|
10057
10116
|
yy.Apply = function (params) {
|
|
10058
|
-
return
|
|
10117
|
+
return Object.assign(this, params);
|
|
10059
10118
|
};
|
|
10060
10119
|
|
|
10061
10120
|
yy.Apply.prototype.toString = function () {
|
|
@@ -10075,7 +10134,7 @@ yy.Apply.prototype.toString = function () {
|
|
|
10075
10134
|
*/
|
|
10076
10135
|
|
|
10077
10136
|
yy.Over = function (params) {
|
|
10078
|
-
return
|
|
10137
|
+
return Object.assign(this, params);
|
|
10079
10138
|
};
|
|
10080
10139
|
yy.Over.prototype.toString = function () {
|
|
10081
10140
|
var s = 'OVER (';
|
|
@@ -10098,13 +10157,15 @@ yy.Over.prototype.toString = function () {
|
|
|
10098
10157
|
//
|
|
10099
10158
|
*/
|
|
10100
10159
|
|
|
10160
|
+
var assign = Object.assign;
|
|
10161
|
+
|
|
10101
10162
|
/**
|
|
10102
10163
|
Expression statement ( = 2*2; )
|
|
10103
10164
|
@class
|
|
10104
10165
|
@param {object} params Initial parameters
|
|
10105
10166
|
*/
|
|
10106
10167
|
yy.ExpressionStatement = function (params) {
|
|
10107
|
-
return
|
|
10168
|
+
return assign(this, params);
|
|
10108
10169
|
};
|
|
10109
10170
|
|
|
10110
10171
|
/**
|
|
@@ -10145,7 +10206,7 @@ yy.ExpressionStatement.prototype.execute = function (databaseid, params, cb) {
|
|
|
10145
10206
|
*/
|
|
10146
10207
|
|
|
10147
10208
|
yy.Expression = function (params) {
|
|
10148
|
-
return
|
|
10209
|
+
return assign(this, params);
|
|
10149
10210
|
};
|
|
10150
10211
|
|
|
10151
10212
|
/**
|
|
@@ -10217,7 +10278,7 @@ yy.Expression.prototype.compile = function (context, tableid, defcols) {
|
|
|
10217
10278
|
@class
|
|
10218
10279
|
*/
|
|
10219
10280
|
yy.JavaScript = function (params) {
|
|
10220
|
-
return
|
|
10281
|
+
return assign(this, params);
|
|
10221
10282
|
};
|
|
10222
10283
|
yy.JavaScript.prototype.toString = function () {
|
|
10223
10284
|
var s = '``' + this.value + '``';
|
|
@@ -10245,7 +10306,7 @@ yy.JavaScript.prototype.execute = function (databaseid, params, cb) {
|
|
|
10245
10306
|
*/
|
|
10246
10307
|
|
|
10247
10308
|
yy.Literal = function (params) {
|
|
10248
|
-
return
|
|
10309
|
+
return assign(this, params);
|
|
10249
10310
|
};
|
|
10250
10311
|
yy.Literal.prototype.toString = function () {
|
|
10251
10312
|
var s = this.value;
|
|
@@ -10262,7 +10323,7 @@ yy.Literal.prototype.toString = function () {
|
|
|
10262
10323
|
*/
|
|
10263
10324
|
|
|
10264
10325
|
yy.Join = function (params) {
|
|
10265
|
-
return
|
|
10326
|
+
return assign(this, params);
|
|
10266
10327
|
};
|
|
10267
10328
|
yy.Join.prototype.toString = function () {
|
|
10268
10329
|
var s = ' ';
|
|
@@ -10279,7 +10340,7 @@ yy.Join.prototype.toString = function () {
|
|
|
10279
10340
|
*/
|
|
10280
10341
|
|
|
10281
10342
|
yy.Table = function (params) {
|
|
10282
|
-
return
|
|
10343
|
+
return assign(this, params);
|
|
10283
10344
|
};
|
|
10284
10345
|
yy.Table.prototype.toString = function () {
|
|
10285
10346
|
var s = this.tableid;
|
|
@@ -10296,7 +10357,7 @@ yy.Table.prototype.toString = function () {
|
|
|
10296
10357
|
*/
|
|
10297
10358
|
|
|
10298
10359
|
yy.View = function (params) {
|
|
10299
|
-
return
|
|
10360
|
+
return assign(this, params);
|
|
10300
10361
|
};
|
|
10301
10362
|
yy.View.prototype.toString = function () {
|
|
10302
10363
|
var s = this.viewid;
|
|
@@ -10312,7 +10373,7 @@ yy.View.prototype.toString = function () {
|
|
|
10312
10373
|
@class
|
|
10313
10374
|
*/
|
|
10314
10375
|
yy.Op = function (params) {
|
|
10315
|
-
return
|
|
10376
|
+
return assign(this, params);
|
|
10316
10377
|
};
|
|
10317
10378
|
yy.Op.prototype.toString = function () {
|
|
10318
10379
|
if (this.op === 'IN' || this.op === 'NOT IN') {
|
|
@@ -10510,9 +10571,9 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10510
10571
|
||
|
|
10511
10572
|
(
|
|
10512
10573
|
${leftOperand} < 0
|
|
10513
|
-
&&
|
|
10514
|
-
true == ${rightOperand}
|
|
10515
|
-
)
|
|
10574
|
+
&&
|
|
10575
|
+
true == ${rightOperand}
|
|
10576
|
+
)
|
|
10516
10577
|
)`;
|
|
10517
10578
|
}
|
|
10518
10579
|
}
|
|
@@ -10698,7 +10759,7 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10698
10759
|
};
|
|
10699
10760
|
|
|
10700
10761
|
yy.VarValue = function (params) {
|
|
10701
|
-
return
|
|
10762
|
+
return assign(this, params);
|
|
10702
10763
|
};
|
|
10703
10764
|
yy.VarValue.prototype.toString = function () {
|
|
10704
10765
|
return '@' + this.variable;
|
|
@@ -10713,7 +10774,7 @@ yy.VarValue.prototype.toJS = function () {
|
|
|
10713
10774
|
};
|
|
10714
10775
|
|
|
10715
10776
|
yy.NumValue = function (params) {
|
|
10716
|
-
return
|
|
10777
|
+
return assign(this, params);
|
|
10717
10778
|
};
|
|
10718
10779
|
yy.NumValue.prototype.toString = function () {
|
|
10719
10780
|
return this.value.toString();
|
|
@@ -10728,7 +10789,7 @@ yy.NumValue.prototype.toJS = function () {
|
|
|
10728
10789
|
};
|
|
10729
10790
|
|
|
10730
10791
|
yy.StringValue = function (params) {
|
|
10731
|
-
return
|
|
10792
|
+
return assign(this, params);
|
|
10732
10793
|
};
|
|
10733
10794
|
yy.StringValue.prototype.toString = function () {
|
|
10734
10795
|
return "'" + this.value.toString() + "'";
|
|
@@ -10743,7 +10804,7 @@ yy.StringValue.prototype.toJS = function () {
|
|
|
10743
10804
|
};
|
|
10744
10805
|
|
|
10745
10806
|
yy.DomainValueValue = function (params) {
|
|
10746
|
-
return
|
|
10807
|
+
return assign(this, params);
|
|
10747
10808
|
};
|
|
10748
10809
|
yy.DomainValueValue.prototype.toString = function () {
|
|
10749
10810
|
return 'VALUE';
|
|
@@ -10760,7 +10821,7 @@ yy.DomainValueValue.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10760
10821
|
};
|
|
10761
10822
|
|
|
10762
10823
|
yy.ArrayValue = function (params) {
|
|
10763
|
-
return
|
|
10824
|
+
return assign(this, params);
|
|
10764
10825
|
};
|
|
10765
10826
|
yy.ArrayValue.prototype.toString = function () {
|
|
10766
10827
|
return 'ARRAY[]';
|
|
@@ -10783,7 +10844,7 @@ yy.ArrayValue.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10783
10844
|
};
|
|
10784
10845
|
|
|
10785
10846
|
yy.LogicValue = function (params) {
|
|
10786
|
-
return
|
|
10847
|
+
return assign(this, params);
|
|
10787
10848
|
};
|
|
10788
10849
|
yy.LogicValue.prototype.toString = function () {
|
|
10789
10850
|
return this.value ? 'TRUE' : 'FALSE';
|
|
@@ -10798,7 +10859,7 @@ yy.LogicValue.prototype.toJS = function () {
|
|
|
10798
10859
|
};
|
|
10799
10860
|
|
|
10800
10861
|
yy.NullValue = function (params) {
|
|
10801
|
-
return
|
|
10862
|
+
return assign(this, params);
|
|
10802
10863
|
};
|
|
10803
10864
|
yy.NullValue.prototype.toString = function () {
|
|
10804
10865
|
return 'NULL';
|
|
@@ -10809,7 +10870,7 @@ yy.NullValue.prototype.toJS = function () {
|
|
|
10809
10870
|
};
|
|
10810
10871
|
|
|
10811
10872
|
yy.ParamValue = function (params) {
|
|
10812
|
-
return
|
|
10873
|
+
return assign(this, params);
|
|
10813
10874
|
};
|
|
10814
10875
|
yy.ParamValue.prototype.toString = function () {
|
|
10815
10876
|
return '$' + this.param;
|
|
@@ -10823,7 +10884,7 @@ yy.ParamValue.prototype.toJS = function () {
|
|
|
10823
10884
|
};
|
|
10824
10885
|
|
|
10825
10886
|
yy.UniOp = function (params) {
|
|
10826
|
-
return
|
|
10887
|
+
return assign(this, params);
|
|
10827
10888
|
};
|
|
10828
10889
|
yy.UniOp.prototype.toString = function () {
|
|
10829
10890
|
var s;
|
|
@@ -10913,7 +10974,7 @@ yy.UniOp.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10913
10974
|
};
|
|
10914
10975
|
|
|
10915
10976
|
yy.Column = function (params) {
|
|
10916
|
-
return
|
|
10977
|
+
return assign(this, params);
|
|
10917
10978
|
};
|
|
10918
10979
|
yy.Column.prototype.toString = function () {
|
|
10919
10980
|
var s;
|
|
@@ -10994,7 +11055,7 @@ yy.Column.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10994
11055
|
};
|
|
10995
11056
|
|
|
10996
11057
|
yy.AggrValue = function (params) {
|
|
10997
|
-
return
|
|
11058
|
+
return assign(this, params);
|
|
10998
11059
|
};
|
|
10999
11060
|
yy.AggrValue.prototype.toString = function () {
|
|
11000
11061
|
var s = '';
|
|
@@ -11069,13 +11130,13 @@ yy.AggrValue.prototype.toJS = function () {
|
|
|
11069
11130
|
};
|
|
11070
11131
|
|
|
11071
11132
|
yy.OrderExpression = function (params) {
|
|
11072
|
-
return
|
|
11133
|
+
return assign(this, params);
|
|
11073
11134
|
};
|
|
11074
11135
|
|
|
11075
11136
|
yy.OrderExpression.prototype.toString = yy.Expression.prototype.toString;
|
|
11076
11137
|
|
|
11077
11138
|
yy.GroupExpression = function (params) {
|
|
11078
|
-
return
|
|
11139
|
+
return assign(this, params);
|
|
11079
11140
|
};
|
|
11080
11141
|
yy.GroupExpression.prototype.toString = function () {
|
|
11081
11142
|
return this.type + '(' + this.group.toString() + ')';
|
|
@@ -11256,7 +11317,7 @@ yy.Select.prototype.Where = function (expr) {
|
|
|
11256
11317
|
*/
|
|
11257
11318
|
|
|
11258
11319
|
yy.FuncValue = function (params) {
|
|
11259
|
-
return
|
|
11320
|
+
return Object.assign(this, params);
|
|
11260
11321
|
};
|
|
11261
11322
|
|
|
11262
11323
|
var re_invalidFnNameChars = /[^0-9A-Z_$]+/i;
|
|
@@ -11718,7 +11779,7 @@ stdfn.NEWID =
|
|
|
11718
11779
|
*/
|
|
11719
11780
|
|
|
11720
11781
|
yy.CaseValue = function (params) {
|
|
11721
|
-
return
|
|
11782
|
+
return Object.assign(this, params);
|
|
11722
11783
|
};
|
|
11723
11784
|
yy.CaseValue.prototype.toString = function () {
|
|
11724
11785
|
var s = 'CASE ';
|
|
@@ -11792,7 +11853,7 @@ yy.CaseValue.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11792
11853
|
*/
|
|
11793
11854
|
|
|
11794
11855
|
yy.Json = function (params) {
|
|
11795
|
-
return
|
|
11856
|
+
return Object.assign(this, params);
|
|
11796
11857
|
};
|
|
11797
11858
|
yy.Json.prototype.toString = function () {
|
|
11798
11859
|
var s = ''; // '@'
|
|
@@ -11901,7 +11962,7 @@ yy.Json.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11901
11962
|
*/
|
|
11902
11963
|
|
|
11903
11964
|
yy.Convert = function (params) {
|
|
11904
|
-
return
|
|
11965
|
+
return Object.assign(this, params);
|
|
11905
11966
|
};
|
|
11906
11967
|
yy.Convert.prototype.toString = function () {
|
|
11907
11968
|
var s = 'CONVERT(';
|
|
@@ -12195,7 +12256,7 @@ alasql.stdfn.CONVERT = function (value, args) {
|
|
|
12195
12256
|
/* global alasql, yy, hash */
|
|
12196
12257
|
|
|
12197
12258
|
yy.ColumnDef = function (params) {
|
|
12198
|
-
return
|
|
12259
|
+
return Object.assign(this, params);
|
|
12199
12260
|
};
|
|
12200
12261
|
yy.ColumnDef.prototype.toString = function () {
|
|
12201
12262
|
var s = this.columnid;
|
|
@@ -12223,7 +12284,7 @@ yy.ColumnDef.prototype.toString = function () {
|
|
|
12223
12284
|
};
|
|
12224
12285
|
|
|
12225
12286
|
yy.CreateTable = function (params) {
|
|
12226
|
-
return
|
|
12287
|
+
return Object.assign(this, params);
|
|
12227
12288
|
};
|
|
12228
12289
|
yy.CreateTable.prototype.toString = function () {
|
|
12229
12290
|
var s = 'CREATE';
|
|
@@ -12234,7 +12295,7 @@ yy.CreateTable.prototype.toString = function () {
|
|
|
12234
12295
|
if (this.view) {
|
|
12235
12296
|
s += ' VIEW';
|
|
12236
12297
|
} else {
|
|
12237
|
-
s += ' ' + (this
|
|
12298
|
+
s += ' ' + (this.class ? 'CLASS' : 'TABLE');
|
|
12238
12299
|
}
|
|
12239
12300
|
if (this.ifnotexists) {
|
|
12240
12301
|
s += ' IF NOT EXISTS';
|
|
@@ -12303,7 +12364,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
12303
12364
|
|
|
12304
12365
|
var table = (db.tables[tableid] = new alasql.Table()); // TODO Can use special object?
|
|
12305
12366
|
// If this is a class
|
|
12306
|
-
if (this
|
|
12367
|
+
if (this.class) {
|
|
12307
12368
|
table.isclass = true;
|
|
12308
12369
|
}
|
|
12309
12370
|
|
|
@@ -12344,8 +12405,8 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
12344
12405
|
});
|
|
12345
12406
|
}
|
|
12346
12407
|
|
|
12347
|
-
if (col
|
|
12348
|
-
ss.push("'" + col.columnid + "':" + col
|
|
12408
|
+
if (col.default) {
|
|
12409
|
+
ss.push("'" + col.columnid + "':" + col.default.toJS('r', ''));
|
|
12349
12410
|
}
|
|
12350
12411
|
|
|
12351
12412
|
// Check for primary key
|
|
@@ -12674,7 +12735,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
12674
12735
|
alasql.inserted = oldinserted;
|
|
12675
12736
|
};
|
|
12676
12737
|
|
|
12677
|
-
table
|
|
12738
|
+
table.delete = function (index) {
|
|
12678
12739
|
var table = this;
|
|
12679
12740
|
var r = table.data[index];
|
|
12680
12741
|
|
|
@@ -13041,7 +13102,7 @@ function newDate(d) {
|
|
|
13041
13102
|
*/
|
|
13042
13103
|
|
|
13043
13104
|
yy.DropTable = function (params) {
|
|
13044
|
-
return
|
|
13105
|
+
return Object.assign(this, params);
|
|
13045
13106
|
};
|
|
13046
13107
|
yy.DropTable.prototype.toString = function () {
|
|
13047
13108
|
var s = 'DROP' + ' ';
|
|
@@ -13114,7 +13175,7 @@ yy.DropTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
13114
13175
|
};
|
|
13115
13176
|
|
|
13116
13177
|
yy.TruncateTable = function (params) {
|
|
13117
|
-
return
|
|
13178
|
+
return Object.assign(this, params);
|
|
13118
13179
|
};
|
|
13119
13180
|
yy.TruncateTable.prototype.toString = function () {
|
|
13120
13181
|
var s = 'TRUNCATE TABLE';
|
|
@@ -13150,12 +13211,12 @@ yy.TruncateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
13150
13211
|
*/
|
|
13151
13212
|
|
|
13152
13213
|
yy.CreateVertex = function (params) {
|
|
13153
|
-
return
|
|
13214
|
+
return Object.assign(this, params);
|
|
13154
13215
|
};
|
|
13155
13216
|
yy.CreateVertex.prototype.toString = function () {
|
|
13156
13217
|
var s = 'CREATE VERTEX ';
|
|
13157
|
-
if (this
|
|
13158
|
-
s += this
|
|
13218
|
+
if (this.class) {
|
|
13219
|
+
s += this.class + ' ';
|
|
13159
13220
|
}
|
|
13160
13221
|
if (this.sharp) {
|
|
13161
13222
|
s += '#' + this.sharp + ' ';
|
|
@@ -13233,13 +13294,13 @@ yy.CreateVertex.prototype.compile = function (databaseid) {
|
|
|
13233
13294
|
};
|
|
13234
13295
|
|
|
13235
13296
|
yy.CreateEdge = function (params) {
|
|
13236
|
-
return
|
|
13297
|
+
return Object.assign(this, params);
|
|
13237
13298
|
};
|
|
13238
13299
|
yy.CreateEdge.prototype.toString = function () {
|
|
13239
13300
|
|
|
13240
13301
|
var s = 'CREATE EDGE' + ' ';
|
|
13241
|
-
if (this
|
|
13242
|
-
s += this
|
|
13302
|
+
if (this.class) {
|
|
13303
|
+
s += this.class + ' ';
|
|
13243
13304
|
}
|
|
13244
13305
|
// todo: SET
|
|
13245
13306
|
// todo: CONTENT
|
|
@@ -13326,12 +13387,12 @@ yy.CreateEdge.prototype.compile = function (databaseid) {
|
|
|
13326
13387
|
};
|
|
13327
13388
|
|
|
13328
13389
|
yy.CreateGraph = function (params) {
|
|
13329
|
-
return
|
|
13390
|
+
return Object.assign(this, params);
|
|
13330
13391
|
};
|
|
13331
13392
|
yy.CreateGraph.prototype.toString = function () {
|
|
13332
13393
|
var s = 'CREATE GRAPH' + ' ';
|
|
13333
|
-
if (this
|
|
13334
|
-
s += this
|
|
13394
|
+
if (this.class) {
|
|
13395
|
+
s += this.class + ' ';
|
|
13335
13396
|
}
|
|
13336
13397
|
return s;
|
|
13337
13398
|
};
|
|
@@ -13364,8 +13425,8 @@ yy.CreateGraph.prototype.execute = function (databaseid, params, cb) {
|
|
|
13364
13425
|
if (typeof g.name !== 'undefined') {
|
|
13365
13426
|
e.name = g.name;
|
|
13366
13427
|
}
|
|
13367
|
-
if (typeof g
|
|
13368
|
-
e.$class = g
|
|
13428
|
+
if (typeof g.class !== 'undefined') {
|
|
13429
|
+
e.$class = g.class;
|
|
13369
13430
|
}
|
|
13370
13431
|
|
|
13371
13432
|
var db = alasql.databases[databaseid];
|
|
@@ -13493,8 +13554,8 @@ yy.CreateGraph.prototype.execute = function (databaseid, params, cb) {
|
|
|
13493
13554
|
if (typeof g.name !== 'undefined') {
|
|
13494
13555
|
v.name = g.name;
|
|
13495
13556
|
}
|
|
13496
|
-
if (typeof g
|
|
13497
|
-
v.$class = g
|
|
13557
|
+
if (typeof g.class !== 'undefined') {
|
|
13558
|
+
v.$class = g.class;
|
|
13498
13559
|
}
|
|
13499
13560
|
|
|
13500
13561
|
var db = alasql.databases[databaseid];
|
|
@@ -13591,7 +13652,7 @@ yy.CreateGraph.prototype.compile1 = function (databaseid) {
|
|
|
13591
13652
|
|
|
13592
13653
|
// ALTER TABLE table1 RENAME TO table2
|
|
13593
13654
|
yy.AlterTable = function (params) {
|
|
13594
|
-
return
|
|
13655
|
+
return Object.assign(this, params);
|
|
13595
13656
|
};
|
|
13596
13657
|
yy.AlterTable.prototype.toString = function () {
|
|
13597
13658
|
var s = 'ALTER TABLE ' + this.table.toString();
|
|
@@ -13768,7 +13829,7 @@ yy.AlterTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
13768
13829
|
*/
|
|
13769
13830
|
|
|
13770
13831
|
yy.CreateIndex = function (params) {
|
|
13771
|
-
return
|
|
13832
|
+
return Object.assign(this, params);
|
|
13772
13833
|
};
|
|
13773
13834
|
yy.CreateIndex.prototype.toString = function () {
|
|
13774
13835
|
var s = 'CREATE';
|
|
@@ -13831,7 +13892,7 @@ yy.CreateIndex.prototype.execute = function (databaseid, params, cb) {
|
|
|
13831
13892
|
};
|
|
13832
13893
|
|
|
13833
13894
|
yy.Reindex = function (params) {
|
|
13834
|
-
return
|
|
13895
|
+
return Object.assign(this, params);
|
|
13835
13896
|
};
|
|
13836
13897
|
yy.Reindex.prototype.toString = function () {
|
|
13837
13898
|
var s = 'REINDEX ' + this.indexid;
|
|
@@ -13861,7 +13922,7 @@ yy.Reindex.prototype.execute = function (databaseid, params, cb) {
|
|
|
13861
13922
|
*/
|
|
13862
13923
|
|
|
13863
13924
|
yy.DropIndex = function (params) {
|
|
13864
|
-
return
|
|
13925
|
+
return Object.assign(this, params);
|
|
13865
13926
|
};
|
|
13866
13927
|
yy.DropIndex.prototype.toString = function () {
|
|
13867
13928
|
return 'DROP INDEX' + this.indexid;
|
|
@@ -13884,7 +13945,7 @@ yy.DropIndex.prototype.compile = function (db) {
|
|
|
13884
13945
|
*/
|
|
13885
13946
|
|
|
13886
13947
|
yy.WithSelect = function (params) {
|
|
13887
|
-
return
|
|
13948
|
+
return Object.assign(this, params);
|
|
13888
13949
|
};
|
|
13889
13950
|
yy.WithSelect.prototype.toString = function () {
|
|
13890
13951
|
var s = 'WITH ';
|
|
@@ -13933,7 +13994,7 @@ yy.WithSelect.prototype.execute = function (databaseid, params, cb) {
|
|
|
13933
13994
|
*/
|
|
13934
13995
|
|
|
13935
13996
|
yy.If = function (params) {
|
|
13936
|
-
return
|
|
13997
|
+
return Object.assign(this, params);
|
|
13937
13998
|
};
|
|
13938
13999
|
yy.If.prototype.toString = function () {
|
|
13939
14000
|
var s = 'IF' + ' ';
|
|
@@ -13973,7 +14034,7 @@ yy.If.prototype.execute = function (databaseid, params, cb) {
|
|
|
13973
14034
|
*/
|
|
13974
14035
|
|
|
13975
14036
|
yy.While = function (params) {
|
|
13976
|
-
return
|
|
14037
|
+
return Object.assign(this, params);
|
|
13977
14038
|
};
|
|
13978
14039
|
yy.While.prototype.toString = function () {
|
|
13979
14040
|
var s = 'WHILE ';
|
|
@@ -14015,7 +14076,7 @@ yy.While.prototype.execute = function (databaseid, params, cb) {
|
|
|
14015
14076
|
};
|
|
14016
14077
|
|
|
14017
14078
|
yy.Break = function (params) {
|
|
14018
|
-
return
|
|
14079
|
+
return Object.assign(this, params);
|
|
14019
14080
|
};
|
|
14020
14081
|
yy.Break.prototype.toString = function () {
|
|
14021
14082
|
var s = 'BREAK';
|
|
@@ -14029,7 +14090,7 @@ yy.Break.prototype.execute = function (databaseid, params, cb, scope) {
|
|
|
14029
14090
|
};
|
|
14030
14091
|
|
|
14031
14092
|
yy.Continue = function (params) {
|
|
14032
|
-
return
|
|
14093
|
+
return Object.assign(this, params);
|
|
14033
14094
|
};
|
|
14034
14095
|
yy.Continue.prototype.toString = function () {
|
|
14035
14096
|
var s = 'CONTINUE';
|
|
@@ -14043,7 +14104,7 @@ yy.Continue.prototype.execute = function (databaseid, params, cb, scope) {
|
|
|
14043
14104
|
};
|
|
14044
14105
|
|
|
14045
14106
|
yy.BeginEnd = function (params) {
|
|
14046
|
-
return
|
|
14107
|
+
return Object.assign(this, params);
|
|
14047
14108
|
};
|
|
14048
14109
|
yy.BeginEnd.prototype.toString = function () {
|
|
14049
14110
|
var s = 'BEGIN ' + this.statements.toString() + ' END';
|
|
@@ -14077,7 +14138,7 @@ yy.BeginEnd.prototype.execute = function (databaseid, params, cb, scope) {
|
|
|
14077
14138
|
|
|
14078
14139
|
/* global yy alasql*/
|
|
14079
14140
|
yy.Insert = function (params) {
|
|
14080
|
-
return
|
|
14141
|
+
return Object.assign(this, params);
|
|
14081
14142
|
};
|
|
14082
14143
|
yy.Insert.prototype.toString = function () {
|
|
14083
14144
|
var s = 'INSERT ';
|
|
@@ -14293,7 +14354,7 @@ yy.Insert.prototype.compile = function (databaseid) {
|
|
|
14293
14354
|
else return res.length;
|
|
14294
14355
|
};
|
|
14295
14356
|
}
|
|
14296
|
-
} else if (this
|
|
14357
|
+
} else if (this.default) {
|
|
14297
14358
|
var insertfns = "db.tables['" + tableid + "'].data.push({" + table.defaultfns + '});return 1;';
|
|
14298
14359
|
var insertfn = new Function('db,params,alasql', insertfns);
|
|
14299
14360
|
} else {
|
|
@@ -14345,7 +14406,7 @@ yy.Insert.prototype.execute = function (databaseid, params, cb) {
|
|
|
14345
14406
|
*/
|
|
14346
14407
|
|
|
14347
14408
|
yy.CreateTrigger = function (params) {
|
|
14348
|
-
return
|
|
14409
|
+
return Object.assign(this, params);
|
|
14349
14410
|
};
|
|
14350
14411
|
yy.CreateTrigger.prototype.toString = function () {
|
|
14351
14412
|
var s = 'CREATE TRIGGER ' + this.trigger + ' ';
|
|
@@ -14398,7 +14459,7 @@ yy.CreateTrigger.prototype.execute = function (databaseid, params, cb) {
|
|
|
14398
14459
|
};
|
|
14399
14460
|
|
|
14400
14461
|
yy.DropTrigger = function (params) {
|
|
14401
|
-
return
|
|
14462
|
+
return Object.assign(this, params);
|
|
14402
14463
|
};
|
|
14403
14464
|
yy.DropTrigger.prototype.toString = function () {
|
|
14404
14465
|
var s = 'DROP TRIGGER ' + this.trigger;
|
|
@@ -14457,7 +14518,7 @@ yy.DropTrigger.prototype.execute = function (databaseid, params, cb) {
|
|
|
14457
14518
|
*/
|
|
14458
14519
|
|
|
14459
14520
|
yy.Delete = function (params) {
|
|
14460
|
-
return
|
|
14521
|
+
return Object.assign(this, params);
|
|
14461
14522
|
};
|
|
14462
14523
|
yy.Delete.prototype.toString = function () {
|
|
14463
14524
|
var s = 'DELETE FROM ' + this.table.toString();
|
|
@@ -14527,8 +14588,8 @@ yy.Delete.prototype.compile = function (databaseid) {
|
|
|
14527
14588
|
for (var i = 0, ilen = table.data.length; i < ilen; i++) {
|
|
14528
14589
|
if (wherefn(table.data[i], params, alasql)) {
|
|
14529
14590
|
// Check for transaction - if it is not possible then return all back
|
|
14530
|
-
if (table
|
|
14531
|
-
table
|
|
14591
|
+
if (table.delete) {
|
|
14592
|
+
table.delete(i, params, alasql);
|
|
14532
14593
|
} else {
|
|
14533
14594
|
// Simply do not push
|
|
14534
14595
|
}
|
|
@@ -14616,7 +14677,7 @@ yy.Delete.prototype.execute = function (databaseid, params, cb) {
|
|
|
14616
14677
|
/* global yy alasql */
|
|
14617
14678
|
|
|
14618
14679
|
yy.Update = function (params) {
|
|
14619
|
-
return
|
|
14680
|
+
return Object.assign(this, params);
|
|
14620
14681
|
};
|
|
14621
14682
|
yy.Update.prototype.toString = function () {
|
|
14622
14683
|
var s = 'UPDATE ' + this.table.toString();
|
|
@@ -14626,7 +14687,7 @@ yy.Update.prototype.toString = function () {
|
|
|
14626
14687
|
};
|
|
14627
14688
|
|
|
14628
14689
|
yy.SetColumn = function (params) {
|
|
14629
|
-
return
|
|
14690
|
+
return Object.assign(this, params);
|
|
14630
14691
|
};
|
|
14631
14692
|
yy.SetColumn.prototype.toString = function () {
|
|
14632
14693
|
return this.column.toString() + '=' + this.expression.toString();
|
|
@@ -14728,7 +14789,7 @@ yy.Update.prototype.execute = function (databaseid, params, cb) {
|
|
|
14728
14789
|
/* global alasql, yy */
|
|
14729
14790
|
|
|
14730
14791
|
yy.Merge = function (params) {
|
|
14731
|
-
return
|
|
14792
|
+
return Object.assign(this, params);
|
|
14732
14793
|
};
|
|
14733
14794
|
yy.Merge.prototype.toString = function () {
|
|
14734
14795
|
var s = 'MERGE ';
|
|
@@ -14745,7 +14806,7 @@ yy.Merge.prototype.toString = function () {
|
|
|
14745
14806
|
if (m.bysource) s += 'BY SOURCE ';
|
|
14746
14807
|
if (m.expr) s += 'AND' + ' ' + m.expr.toString() + ' ';
|
|
14747
14808
|
s += 'THEN ';
|
|
14748
|
-
if (m.action
|
|
14809
|
+
if (m.action.delete) s += 'DELETE ';
|
|
14749
14810
|
if (m.action.insert) {
|
|
14750
14811
|
s += 'INSERT ';
|
|
14751
14812
|
if (m.action.columns) s += '(' + m.action.columns.toString() + ') ';
|
|
@@ -14786,7 +14847,7 @@ yy.Merge.prototype.execute = function (databaseid, params, cb) {
|
|
|
14786
14847
|
|
|
14787
14848
|
// CREATE DATABASE databaseid
|
|
14788
14849
|
yy.CreateDatabase = function (params) {
|
|
14789
|
-
return
|
|
14850
|
+
return Object.assign(this, params);
|
|
14790
14851
|
};
|
|
14791
14852
|
yy.CreateDatabase.prototype.toString = function () {
|
|
14792
14853
|
var s = 'CREATE';
|
|
@@ -14839,7 +14900,7 @@ yy.CreateDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
14839
14900
|
|
|
14840
14901
|
// CREATE DATABASE databaseid
|
|
14841
14902
|
yy.AttachDatabase = function (params) {
|
|
14842
|
-
return
|
|
14903
|
+
return Object.assign(this, params);
|
|
14843
14904
|
};
|
|
14844
14905
|
yy.AttachDatabase.prototype.toString = function (args) {
|
|
14845
14906
|
var s = 'ATTACH';
|
|
@@ -14877,7 +14938,7 @@ yy.AttachDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
14877
14938
|
|
|
14878
14939
|
// CREATE DATABASE databaseid
|
|
14879
14940
|
yy.DetachDatabase = function (params) {
|
|
14880
|
-
return
|
|
14941
|
+
return Object.assign(this, params);
|
|
14881
14942
|
};
|
|
14882
14943
|
yy.DetachDatabase.prototype.toString = function () {
|
|
14883
14944
|
var s = 'DETACH';
|
|
@@ -14938,7 +14999,7 @@ yy.DetachDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
14938
14999
|
// USE DATABSE databaseid
|
|
14939
15000
|
// USE databaseid
|
|
14940
15001
|
yy.UseDatabase = function (params) {
|
|
14941
|
-
return
|
|
15002
|
+
return Object.assign(this, params);
|
|
14942
15003
|
};
|
|
14943
15004
|
yy.UseDatabase.prototype.toString = function () {
|
|
14944
15005
|
return 'USE' + ' ' + 'DATABASE' + ' ' + this.databaseid;
|
|
@@ -14957,7 +15018,7 @@ yy.UseDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
14957
15018
|
|
|
14958
15019
|
// DROP DATABASE databaseid
|
|
14959
15020
|
yy.DropDatabase = function (params) {
|
|
14960
|
-
return
|
|
15021
|
+
return Object.assign(this, params);
|
|
14961
15022
|
};
|
|
14962
15023
|
yy.DropDatabase.prototype.toString = function () {
|
|
14963
15024
|
var s = 'DROP';
|
|
@@ -15007,7 +15068,7 @@ yy.DropDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
15007
15068
|
*/
|
|
15008
15069
|
|
|
15009
15070
|
yy.Declare = function (params) {
|
|
15010
|
-
return
|
|
15071
|
+
return Object.assign(this, params);
|
|
15011
15072
|
};
|
|
15012
15073
|
yy.Declare.prototype.toString = function () {
|
|
15013
15074
|
var s = 'DECLARE ';
|
|
@@ -15079,7 +15140,7 @@ yy.Declare.prototype.execute = function (databaseid, params, cb) {
|
|
|
15079
15140
|
*/
|
|
15080
15141
|
|
|
15081
15142
|
yy.ShowDatabases = function (params) {
|
|
15082
|
-
return
|
|
15143
|
+
return Object.assign(this, params);
|
|
15083
15144
|
};
|
|
15084
15145
|
yy.ShowDatabases.prototype.toString = function () {
|
|
15085
15146
|
var s = 'SHOW DATABASES';
|
|
@@ -15107,7 +15168,7 @@ yy.ShowDatabases.prototype.execute = function (databaseid, params, cb) {
|
|
|
15107
15168
|
};
|
|
15108
15169
|
|
|
15109
15170
|
yy.ShowTables = function (params) {
|
|
15110
|
-
return
|
|
15171
|
+
return Object.assign(this, params);
|
|
15111
15172
|
};
|
|
15112
15173
|
yy.ShowTables.prototype.toString = function () {
|
|
15113
15174
|
var s = 'SHOW TABLES';
|
|
@@ -15134,7 +15195,7 @@ yy.ShowTables.prototype.execute = function (databaseid, params, cb) {
|
|
|
15134
15195
|
};
|
|
15135
15196
|
|
|
15136
15197
|
yy.ShowColumns = function (params) {
|
|
15137
|
-
return
|
|
15198
|
+
return Object.assign(this, params);
|
|
15138
15199
|
};
|
|
15139
15200
|
yy.ShowColumns.prototype.toString = function () {
|
|
15140
15201
|
var s = 'SHOW COLUMNS';
|
|
@@ -15160,7 +15221,7 @@ yy.ShowColumns.prototype.execute = function (databaseid, params, cb) {
|
|
|
15160
15221
|
};
|
|
15161
15222
|
|
|
15162
15223
|
yy.ShowIndex = function (params) {
|
|
15163
|
-
return
|
|
15224
|
+
return Object.assign(this, params);
|
|
15164
15225
|
};
|
|
15165
15226
|
yy.ShowIndex.prototype.toString = function () {
|
|
15166
15227
|
var s = 'SHOW INDEX';
|
|
@@ -15183,7 +15244,7 @@ yy.ShowIndex.prototype.execute = function (databaseid, params, cb) {
|
|
|
15183
15244
|
};
|
|
15184
15245
|
|
|
15185
15246
|
yy.ShowCreateTable = function (params) {
|
|
15186
|
-
return
|
|
15247
|
+
return Object.assign(this, params);
|
|
15187
15248
|
};
|
|
15188
15249
|
yy.ShowCreateTable.prototype.toString = function () {
|
|
15189
15250
|
var s = 'SHOW CREATE TABLE ' + this.table.tableid;
|
|
@@ -15222,7 +15283,7 @@ yy.ShowCreateTable.prototype.execute = function (databaseid) {
|
|
|
15222
15283
|
*/
|
|
15223
15284
|
|
|
15224
15285
|
yy.SetVariable = function (params) {
|
|
15225
|
-
return
|
|
15286
|
+
return Object.assign(this, params);
|
|
15226
15287
|
};
|
|
15227
15288
|
yy.SetVariable.prototype.toString = function () {
|
|
15228
15289
|
var s = 'SET ';
|
|
@@ -15613,7 +15674,7 @@ alasql.prompt = function (el, useidel, firstsql) {
|
|
|
15613
15674
|
//
|
|
15614
15675
|
*/
|
|
15615
15676
|
yy.BeginTransaction = function (params) {
|
|
15616
|
-
return
|
|
15677
|
+
return Object.assign(this, params);
|
|
15617
15678
|
};
|
|
15618
15679
|
yy.BeginTransaction.prototype.toString = function () {
|
|
15619
15680
|
return 'BEGIN TRANSACTION';
|
|
@@ -15631,7 +15692,7 @@ yy.BeginTransaction.prototype.execute = function (databaseid, params, cb) {
|
|
|
15631
15692
|
};
|
|
15632
15693
|
|
|
15633
15694
|
yy.CommitTransaction = function (params) {
|
|
15634
|
-
return
|
|
15695
|
+
return Object.assign(this, params);
|
|
15635
15696
|
};
|
|
15636
15697
|
yy.CommitTransaction.prototype.toString = function () {
|
|
15637
15698
|
return 'COMMIT TRANSACTION';
|
|
@@ -15649,7 +15710,7 @@ yy.CommitTransaction.prototype.execute = function (databaseid, params, cb) {
|
|
|
15649
15710
|
};
|
|
15650
15711
|
|
|
15651
15712
|
yy.RollbackTransaction = function (params) {
|
|
15652
|
-
return
|
|
15713
|
+
return Object.assign(this, params);
|
|
15653
15714
|
};
|
|
15654
15715
|
yy.RollbackTransaction.prototype.toString = function () {
|
|
15655
15716
|
return 'ROLLBACK TRANSACTION';
|
|
@@ -17082,7 +17143,7 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
|
|
|
17082
17143
|
return EOF;
|
|
17083
17144
|
}
|
|
17084
17145
|
if (eol) {
|
|
17085
|
-
return (eol = false, EOL
|
|
17146
|
+
return (eol = false), EOL;
|
|
17086
17147
|
}
|
|
17087
17148
|
var j = I;
|
|
17088
17149
|
if (text.charCodeAt(j) === quoteCode) {
|
|
@@ -17518,7 +17579,7 @@ alasql.from.GEXF = function (filename, opts, cb, idx, query) {
|
|
|
17518
17579
|
/* globals: alasql, yy */
|
|
17519
17580
|
|
|
17520
17581
|
/**
|
|
17521
|
-
Print statement
|
|
17582
|
+
Print statement
|
|
17522
17583
|
@class
|
|
17523
17584
|
@param {object} params Initial setup properties
|
|
17524
17585
|
*/
|
|
@@ -17526,11 +17587,11 @@ alasql.from.GEXF = function (filename, opts, cb, idx, query) {
|
|
|
17526
17587
|
/* global alasql, yy */
|
|
17527
17588
|
|
|
17528
17589
|
yy.Print = function (params) {
|
|
17529
|
-
return
|
|
17590
|
+
return Object.assign(this, params);
|
|
17530
17591
|
};
|
|
17531
17592
|
|
|
17532
|
-
/**
|
|
17533
|
-
Generate SQL string
|
|
17593
|
+
/**
|
|
17594
|
+
Generate SQL string
|
|
17534
17595
|
@this Print statement object
|
|
17535
17596
|
*/
|
|
17536
17597
|
yy.Print.prototype.toString = function () {
|
|
@@ -17543,7 +17604,7 @@ yy.Print.prototype.toString = function () {
|
|
|
17543
17604
|
Print result of select statement or expression
|
|
17544
17605
|
@param {string} databaseid Database identificator
|
|
17545
17606
|
@param {object} params Query parameters
|
|
17546
|
-
@param {statement-callback} cb Callback function
|
|
17607
|
+
@param {statement-callback} cb Callback function
|
|
17547
17608
|
@this Print statement object
|
|
17548
17609
|
*/
|
|
17549
17610
|
yy.Print.prototype.execute = function (databaseid, params, cb) {
|
|
@@ -17584,7 +17645,7 @@ yy.Print.prototype.execute = function (databaseid, params, cb) {
|
|
|
17584
17645
|
*/
|
|
17585
17646
|
|
|
17586
17647
|
yy.Source = function (params) {
|
|
17587
|
-
return
|
|
17648
|
+
return Object.assign(this, params);
|
|
17588
17649
|
};
|
|
17589
17650
|
yy.Source.prototype.toString = function () {
|
|
17590
17651
|
var s = 'SOURCE';
|
|
@@ -17624,7 +17685,7 @@ yy.Source.prototype.execute = function (databaseid, params, cb) {
|
|
|
17624
17685
|
/* global alasql, yy */
|
|
17625
17686
|
|
|
17626
17687
|
yy.Require = function (params) {
|
|
17627
|
-
return
|
|
17688
|
+
return Object.assign(this, params);
|
|
17628
17689
|
};
|
|
17629
17690
|
yy.Require.prototype.toString = function () {
|
|
17630
17691
|
var s = 'REQUIRE';
|
|
@@ -17696,7 +17757,7 @@ yy.Require.prototype.execute = function (databaseid, params, cb) {
|
|
|
17696
17757
|
*/
|
|
17697
17758
|
|
|
17698
17759
|
yy.Assert = function (params) {
|
|
17699
|
-
return
|
|
17760
|
+
return Object.assign(this, params);
|
|
17700
17761
|
};
|
|
17701
17762
|
yy.Source.prototype.toString = function () {
|
|
17702
17763
|
var s = 'ASSERT';
|
|
@@ -17773,29 +17834,46 @@ var IDB = (alasql.engines.INDEXEDDB = function () {
|
|
|
17773
17834
|
'';
|
|
17774
17835
|
});
|
|
17775
17836
|
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
var result = {
|
|
17786
|
-
contains: function (name) {
|
|
17787
|
-
return true; // Always return true
|
|
17788
|
-
},
|
|
17789
|
-
notsupported: true,
|
|
17790
|
-
};
|
|
17791
|
-
setTimeout(function () {
|
|
17792
|
-
var event = {target: {result: result}};
|
|
17793
|
-
request.onsuccess(event);
|
|
17794
|
-
}, 0);
|
|
17795
|
-
return request;
|
|
17796
|
-
};
|
|
17797
|
-
IDB.getDatabaseNamesNotSupported = true;
|
|
17837
|
+
/**
|
|
17838
|
+
* @param {string} name
|
|
17839
|
+
* @returns {Promise<{name: string, version: number}|0>}
|
|
17840
|
+
*/
|
|
17841
|
+
async function _databaseExists(name) {
|
|
17842
|
+
const indexedDB = globalThis.indexedDB;
|
|
17843
|
+
|
|
17844
|
+
if (!indexedDB) {
|
|
17845
|
+
throw new Error('IndexedDB is not supported in this browser');
|
|
17798
17846
|
}
|
|
17847
|
+
|
|
17848
|
+
if (indexedDB.databases) {
|
|
17849
|
+
const dbs = await indexedDB.databases();
|
|
17850
|
+
const db = dbs.find((db) => db.name === name);
|
|
17851
|
+
// @ts-ignore
|
|
17852
|
+
return db || 0;
|
|
17853
|
+
}
|
|
17854
|
+
|
|
17855
|
+
// Try if it exist
|
|
17856
|
+
const req = indexedDB.open(name);
|
|
17857
|
+
|
|
17858
|
+
return new Promise(function (resolve, reject) {
|
|
17859
|
+
req.onsuccess = () => {
|
|
17860
|
+
req.result.close();
|
|
17861
|
+
resolve({name, version: req.result.version});
|
|
17862
|
+
};
|
|
17863
|
+
|
|
17864
|
+
req.onupgradeneeded = (evt) => {
|
|
17865
|
+
evt.target.transaction.abort();
|
|
17866
|
+
resolve(0);
|
|
17867
|
+
};
|
|
17868
|
+
|
|
17869
|
+
req.onerror = () => {
|
|
17870
|
+
reject(new Error('IndexedDB error'));
|
|
17871
|
+
};
|
|
17872
|
+
|
|
17873
|
+
req.onblocked = () => {
|
|
17874
|
+
resolve({name, version: req.result.version});
|
|
17875
|
+
};
|
|
17876
|
+
});
|
|
17799
17877
|
}
|
|
17800
17878
|
|
|
17801
17879
|
//
|
|
@@ -17803,333 +17881,235 @@ if (utils.hasIndexedDB) {
|
|
|
17803
17881
|
// work only in chrome
|
|
17804
17882
|
//
|
|
17805
17883
|
IDB.showDatabases = function (like, cb) {
|
|
17884
|
+
if (!indexedDB.databases) {
|
|
17885
|
+
cb(null, new Error('SHOW DATABASE is not supported in this browser'));
|
|
17886
|
+
return;
|
|
17887
|
+
}
|
|
17888
|
+
|
|
17889
|
+
indexedDB.databases().then((dblist) => {
|
|
17890
|
+
const res = [];
|
|
17891
|
+
const relike = like && new RegExp(like.value.replace(/\%/g, '.*'), 'g');
|
|
17806
17892
|
|
|
17807
|
-
var request = IDB.getDatabaseNames();
|
|
17808
|
-
request.onsuccess = function (event) {
|
|
17809
|
-
var dblist = event.target.result;
|
|
17810
|
-
if (IDB.getDatabaseNamesNotSupported) {
|
|
17811
|
-
throw new Error('SHOW DATABASE is not supported in this browser');
|
|
17812
|
-
}
|
|
17813
|
-
var res = [];
|
|
17814
|
-
if (like) {
|
|
17815
|
-
var relike = new RegExp(like.value.replace(/\%/g, '.*'), 'g');
|
|
17816
|
-
}
|
|
17817
17893
|
for (var i = 0; i < dblist.length; i++) {
|
|
17818
|
-
if (!like || dblist[i].match(relike)) {
|
|
17819
|
-
res.push({databaseid: dblist[i]});
|
|
17894
|
+
if (!like || dblist[i].name.match(relike)) {
|
|
17895
|
+
res.push({databaseid: dblist[i].name});
|
|
17820
17896
|
}
|
|
17821
17897
|
}
|
|
17898
|
+
|
|
17822
17899
|
cb(res);
|
|
17823
|
-
};
|
|
17900
|
+
});
|
|
17824
17901
|
};
|
|
17825
17902
|
|
|
17826
|
-
IDB.createDatabase = function (ixdbid, args, ifnotexists, dbid, cb) {
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
request2.onsuccess = function (event) {
|
|
17832
|
-
event.target.result.close();
|
|
17833
|
-
if (cb) cb(1);
|
|
17834
|
-
};
|
|
17835
|
-
} else {
|
|
17836
|
-
var request1 = indexedDB.open(ixdbid, 1);
|
|
17837
|
-
request1.onupgradeneeded = function (e) {
|
|
17838
|
-
|
|
17839
|
-
e.target.transaction.abort();
|
|
17840
|
-
};
|
|
17841
|
-
request1.onsuccess = function (e) {
|
|
17842
|
-
|
|
17843
|
-
if (ifnotexists) {
|
|
17844
|
-
if (cb) cb(0);
|
|
17845
|
-
} else {
|
|
17846
|
-
throw new Error(
|
|
17847
|
-
'IndexedDB: Cannot create new database "' + ixdbid + '" because it already exists'
|
|
17848
|
-
);
|
|
17849
|
-
}
|
|
17850
|
-
};
|
|
17851
|
-
}
|
|
17852
|
-
|
|
17853
|
-
};
|
|
17903
|
+
IDB.createDatabase = async function (ixdbid, args, ifnotexists, dbid, cb) {
|
|
17904
|
+
const found = await _databaseExists(ixdbid).catch((err) => {
|
|
17905
|
+
if (cb) cb(null, err);
|
|
17906
|
+
throw err;
|
|
17907
|
+
});
|
|
17854
17908
|
|
|
17855
|
-
|
|
17856
|
-
var indexedDB = utils.global.indexedDB;
|
|
17857
|
-
if (IDB.getDatabaseNamesNotSupported) {
|
|
17858
|
-
// Hack for Firefox
|
|
17909
|
+
if (found) {
|
|
17859
17910
|
if (ifnotexists) {
|
|
17860
|
-
|
|
17861
|
-
var dbExists = true;
|
|
17862
|
-
var request2 = indexedDB.open(ixdbid);
|
|
17863
|
-
|
|
17864
|
-
request2.onupgradeneeded = function (e) {
|
|
17865
|
-
|
|
17866
|
-
dbExists = false;
|
|
17867
|
-
// e.target.transaction.abort();
|
|
17868
|
-
// cb(0);
|
|
17869
|
-
};
|
|
17870
|
-
request2.onsuccess = function (event) {
|
|
17871
|
-
|
|
17872
|
-
event.target.result.close();
|
|
17873
|
-
if (dbExists) {
|
|
17874
|
-
if (cb) cb(0);
|
|
17875
|
-
} else {
|
|
17876
|
-
if (cb) cb(1);
|
|
17877
|
-
}
|
|
17878
|
-
};
|
|
17911
|
+
cb && cb(0);
|
|
17879
17912
|
} else {
|
|
17880
|
-
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
};
|
|
17885
|
-
request1.onabort = function (event) {
|
|
17886
|
-
if (cb) cb(1);
|
|
17887
|
-
};
|
|
17888
|
-
request1.onsuccess = function (event) {
|
|
17889
|
-
event.target.result.close();
|
|
17890
|
-
throw new Error(
|
|
17891
|
-
'IndexedDB: Cannot create new database "' + ixdbid + '" because it already exists'
|
|
17892
|
-
);
|
|
17893
|
-
// cb(0);
|
|
17894
|
-
};
|
|
17913
|
+
const err = new Error(
|
|
17914
|
+
`IndexedDB: Cannot create new database "${ixdbid}" because it already exists`
|
|
17915
|
+
);
|
|
17916
|
+
if (cb) cb(null, err);
|
|
17895
17917
|
}
|
|
17896
17918
|
} else {
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
if (ifnotexists) {
|
|
17902
|
-
if (cb) cb(0);
|
|
17903
|
-
return;
|
|
17904
|
-
} else {
|
|
17905
|
-
throw new Error(
|
|
17906
|
-
'IndexedDB: Cannot create new database "' + ixdbid + '" because it already exists'
|
|
17907
|
-
);
|
|
17908
|
-
}
|
|
17909
|
-
}
|
|
17910
|
-
|
|
17911
|
-
var request2 = indexedDB.open(ixdbid, 1);
|
|
17912
|
-
request2.onsuccess = function (event) {
|
|
17913
|
-
event.target.result.close();
|
|
17914
|
-
if (cb) cb(1);
|
|
17915
|
-
};
|
|
17919
|
+
const request = indexedDB.open(ixdbid, 1);
|
|
17920
|
+
request.onsuccess = () => {
|
|
17921
|
+
request.result.close();
|
|
17922
|
+
cb(1);
|
|
17916
17923
|
};
|
|
17917
17924
|
}
|
|
17918
17925
|
};
|
|
17919
17926
|
|
|
17920
|
-
IDB.dropDatabase = function (ixdbid, ifexists, cb) {
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
if (!dblist.contains(ixdbid)) {
|
|
17926
|
-
if (ifexists) {
|
|
17927
|
-
if (cb) cb(0);
|
|
17928
|
-
return;
|
|
17929
|
-
} else {
|
|
17930
|
-
throw new Error(
|
|
17931
|
-
'IndexedDB: Cannot drop new database "' + ixdbid + '" because it does not exist'
|
|
17932
|
-
);
|
|
17933
|
-
}
|
|
17934
|
-
}
|
|
17935
|
-
var request2 = indexedDB.deleteDatabase(ixdbid);
|
|
17936
|
-
request2.onsuccess = function (event) {
|
|
17927
|
+
IDB.dropDatabase = async function (ixdbid, ifexists, cb) {
|
|
17928
|
+
const found = await _databaseExists(ixdbid).catch((err) => {
|
|
17929
|
+
if (cb) cb(null, err);
|
|
17930
|
+
throw err;
|
|
17931
|
+
});
|
|
17937
17932
|
|
|
17933
|
+
if (found) {
|
|
17934
|
+
const request = indexedDB.deleteDatabase(ixdbid);
|
|
17935
|
+
request.onsuccess = () => {
|
|
17938
17936
|
if (cb) cb(1);
|
|
17939
17937
|
};
|
|
17940
|
-
}
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
request1.onsuccess = function (event) {
|
|
17950
|
-
var dblist = event.target.result;
|
|
17951
|
-
if (!dblist.contains(ixdbid)) {
|
|
17952
|
-
throw new Error(
|
|
17953
|
-
'IndexedDB: Cannot attach database "' + ixdbid + '" because it does not exist'
|
|
17954
|
-
);
|
|
17938
|
+
} else {
|
|
17939
|
+
if (ifexists) {
|
|
17940
|
+
cb && cb(0);
|
|
17941
|
+
} else {
|
|
17942
|
+
cb &&
|
|
17943
|
+
cb(
|
|
17944
|
+
null,
|
|
17945
|
+
new Error(`IndexedDB: Cannot drop new database "${ixdbid}" because it does not exist'`)
|
|
17946
|
+
);
|
|
17955
17947
|
}
|
|
17956
|
-
|
|
17957
|
-
request2.onsuccess = function (event) {
|
|
17958
|
-
var ixdb = event.target.result;
|
|
17959
|
-
var db = new alasql.Database(dbid || ixdbid);
|
|
17960
|
-
db.engineid = 'INDEXEDDB';
|
|
17961
|
-
db.ixdbid = ixdbid;
|
|
17962
|
-
db.tables = [];
|
|
17963
|
-
var tblist = ixdb.objectStoreNames;
|
|
17964
|
-
for (var i = 0; i < tblist.length; i++) {
|
|
17965
|
-
db.tables[tblist[i]] = {};
|
|
17966
|
-
}
|
|
17967
|
-
|
|
17968
|
-
event.target.result.close();
|
|
17969
|
-
if (cb) cb(1);
|
|
17970
|
-
};
|
|
17971
|
-
};
|
|
17948
|
+
}
|
|
17972
17949
|
};
|
|
17973
17950
|
|
|
17974
|
-
IDB.
|
|
17975
|
-
|
|
17976
|
-
|
|
17977
|
-
|
|
17951
|
+
IDB.attachDatabase = async function (ixdbid, dbid, args, params, cb) {
|
|
17952
|
+
const found = await _databaseExists(ixdbid).catch((err) => {
|
|
17953
|
+
if (cb) cb(null, err);
|
|
17954
|
+
throw err;
|
|
17955
|
+
});
|
|
17978
17956
|
|
|
17979
|
-
|
|
17980
|
-
|
|
17981
|
-
|
|
17982
|
-
|
|
17983
|
-
|
|
17984
|
-
|
|
17985
|
-
|
|
17986
|
-
}
|
|
17987
|
-
var request2 = indexedDB.open(ixdbid);
|
|
17988
|
-
request2.onversionchange = function (event_) {
|
|
17957
|
+
if (!found) {
|
|
17958
|
+
const err = new Error(
|
|
17959
|
+
`IndexedDB: Cannot attach database "${ixdbid}" because it does not exist`
|
|
17960
|
+
);
|
|
17961
|
+
if (cb) cb(null, err);
|
|
17962
|
+
throw err;
|
|
17963
|
+
}
|
|
17989
17964
|
|
|
17990
|
-
|
|
17965
|
+
const stores = await new Promise((resolve, reject) => {
|
|
17966
|
+
const request = indexedDB.open(ixdbid);
|
|
17967
|
+
request.onsuccess = () => {
|
|
17968
|
+
resolve(request.result.objectStoreNames);
|
|
17969
|
+
request.result.close();
|
|
17991
17970
|
};
|
|
17992
|
-
|
|
17993
|
-
var version = event_.target.result.version;
|
|
17994
|
-
event_.target.result.close();
|
|
17971
|
+
});
|
|
17995
17972
|
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17973
|
+
const db = new alasql.Database(dbid || ixdbid);
|
|
17974
|
+
db.engineid = 'INDEXEDDB';
|
|
17975
|
+
db.ixdbid = ixdbid;
|
|
17976
|
+
db.tables = [];
|
|
17999
17977
|
|
|
18000
|
-
|
|
17978
|
+
for (var i = 0; i < stores.length; i++) {
|
|
17979
|
+
db.tables[stores[i]] = {};
|
|
17980
|
+
}
|
|
18001
17981
|
|
|
18002
|
-
|
|
18003
|
-
|
|
17982
|
+
if (cb) cb(1);
|
|
17983
|
+
};
|
|
18004
17984
|
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
|
|
18008
|
-
|
|
18009
|
-
|
|
17985
|
+
IDB.createTable = async function (databaseid, tableid, ifnotexists, cb) {
|
|
17986
|
+
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
17987
|
+
const found = await _databaseExists(ixdbid).catch((err) => {
|
|
17988
|
+
if (cb) cb(null, err);
|
|
17989
|
+
throw err;
|
|
17990
|
+
});
|
|
18010
17991
|
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
17992
|
+
if (!found) {
|
|
17993
|
+
const err = new Error(
|
|
17994
|
+
'IndexedDB: Cannot create table in database "' + ixdbid + '" because it does not exist'
|
|
17995
|
+
);
|
|
17996
|
+
if (cb) cb(null, err);
|
|
17997
|
+
throw err;
|
|
17998
|
+
}
|
|
18016
17999
|
|
|
18017
|
-
|
|
18018
|
-
|
|
18000
|
+
const request = indexedDB.open(ixdbid, found.version + 1);
|
|
18001
|
+
request.onupgradeneeded = function (event) {
|
|
18002
|
+
request.result.createObjectStore(tableid, {autoIncrement: true});
|
|
18003
|
+
};
|
|
18004
|
+
request.onsuccess = function (event) {
|
|
18005
|
+
request.result.close();
|
|
18006
|
+
if (cb) cb(1);
|
|
18007
|
+
};
|
|
18008
|
+
request.onerror = (evt) => {
|
|
18009
|
+
cb(null, evt);
|
|
18010
|
+
};
|
|
18011
|
+
request.onblocked = function (event) {
|
|
18012
|
+
cb(
|
|
18013
|
+
null,
|
|
18014
|
+
new Error(`Cannot create table "${tableid}" because database "${databaseid}" is blocked`)
|
|
18015
|
+
);
|
|
18019
18016
|
};
|
|
18020
18017
|
};
|
|
18021
18018
|
|
|
18022
|
-
IDB.dropTable = function (databaseid, tableid, ifexists, cb) {
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
var dblist = event.target.result;
|
|
18029
|
-
|
|
18030
|
-
if (!dblist.contains(ixdbid)) {
|
|
18031
|
-
throw new Error(
|
|
18032
|
-
'IndexedDB: Cannot drop table in database "' + ixdbid + '" because it does not exist'
|
|
18033
|
-
);
|
|
18034
|
-
}
|
|
18035
|
-
|
|
18036
|
-
var request2 = indexedDB.open(ixdbid);
|
|
18037
|
-
request2.onversionchange = function (event) {
|
|
18038
|
-
event.target.result.close();
|
|
18039
|
-
};
|
|
18040
|
-
|
|
18041
|
-
request2.onsuccess = function (event) {
|
|
18042
|
-
var version = event.target.result.version;
|
|
18043
|
-
event.target.result.close();
|
|
18044
|
-
|
|
18045
|
-
var request3 = indexedDB.open(ixdbid, version + 1);
|
|
18046
|
-
request3.onupgradeneeded = function (event) {
|
|
18047
|
-
var ixdb = event.target.result;
|
|
18048
|
-
if (ixdb.objectStoreNames.contains(tableid)) {
|
|
18049
|
-
ixdb.deleteObjectStore(tableid);
|
|
18050
|
-
delete alasql.databases[databaseid].tables[tableid];
|
|
18051
|
-
} else {
|
|
18052
|
-
if (!ifexists) {
|
|
18053
|
-
throw new Error(
|
|
18054
|
-
'IndexedDB: Cannot drop table "' + tableid + '" because it does not exist'
|
|
18055
|
-
);
|
|
18056
|
-
}
|
|
18057
|
-
}
|
|
18058
|
-
// var store = ixdb.createObjectStore(tableid);
|
|
18059
|
-
|
|
18060
|
-
};
|
|
18061
|
-
request3.onsuccess = function (event) {
|
|
18019
|
+
IDB.dropTable = async function (databaseid, tableid, ifexists, cb) {
|
|
18020
|
+
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18021
|
+
const found = await _databaseExists(ixdbid).catch((err) => {
|
|
18022
|
+
if (cb) cb(null, err);
|
|
18023
|
+
throw err;
|
|
18024
|
+
});
|
|
18062
18025
|
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
|
|
18066
|
-
|
|
18026
|
+
if (!found) {
|
|
18027
|
+
const err = new Error(
|
|
18028
|
+
'IndexedDB: Cannot drop table in database "' + ixdbid + '" because it does not exist'
|
|
18029
|
+
);
|
|
18030
|
+
if (cb) cb(null, err);
|
|
18031
|
+
throw err;
|
|
18032
|
+
}
|
|
18067
18033
|
|
|
18068
|
-
|
|
18069
|
-
};
|
|
18070
|
-
request3.onblocked = function (event) {
|
|
18071
|
-
throw new Error(
|
|
18072
|
-
'Cannot drop table "' + tableid + '" because database "' + databaseid + '" is blocked'
|
|
18073
|
-
);
|
|
18034
|
+
const request = indexedDB.open(ixdbid, found.version + 1);
|
|
18074
18035
|
|
|
18075
|
-
|
|
18076
|
-
|
|
18036
|
+
let err;
|
|
18037
|
+
request.onupgradeneeded = function (evt) {
|
|
18038
|
+
var ixdb = request.result;
|
|
18039
|
+
if (ixdb.objectStoreNames.contains(tableid)) {
|
|
18040
|
+
ixdb.deleteObjectStore(tableid);
|
|
18041
|
+
delete alasql.databases[databaseid].tables[tableid];
|
|
18042
|
+
} else {
|
|
18043
|
+
if (!ifexists) {
|
|
18044
|
+
err = new Error(`IndexedDB: Cannot drop table "${tableid}" because it does not exist`);
|
|
18045
|
+
evt.target.transaction.abort();
|
|
18046
|
+
}
|
|
18047
|
+
}
|
|
18048
|
+
};
|
|
18049
|
+
request.onsuccess = function (event) {
|
|
18050
|
+
request.result.close();
|
|
18051
|
+
if (cb) cb(1);
|
|
18052
|
+
};
|
|
18053
|
+
request.onerror = function (event) {
|
|
18054
|
+
cb && cb(null, err || event);
|
|
18055
|
+
};
|
|
18056
|
+
request.onblocked = function (event) {
|
|
18057
|
+
cb(
|
|
18058
|
+
null,
|
|
18059
|
+
new Error(`Cannot drop table "${tableid}" because database "${databaseid}" is blocked`)
|
|
18060
|
+
);
|
|
18077
18061
|
};
|
|
18078
18062
|
};
|
|
18079
18063
|
|
|
18080
18064
|
IDB.intoTable = function (databaseid, tableid, value, columns, cb) {
|
|
18065
|
+
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18066
|
+
const request = indexedDB.open(ixdbid);
|
|
18081
18067
|
|
|
18082
|
-
|
|
18068
|
+
request.onupgradeneeded = (evt) => {
|
|
18069
|
+
evt.target.transaction.abort();
|
|
18070
|
+
const err = new Error(
|
|
18071
|
+
`Cannot insert into table "${tableid}" because database "${databaseid}" does not exist`
|
|
18072
|
+
);
|
|
18073
|
+
if (cb) cb(null, err);
|
|
18074
|
+
};
|
|
18083
18075
|
|
|
18084
|
-
|
|
18085
|
-
|
|
18086
|
-
var request1 = indexedDB.open(ixdbid);
|
|
18087
|
-
request1.onsuccess = function (event) {
|
|
18088
|
-
var ixdb = event.target.result;
|
|
18076
|
+
request.onsuccess = () => {
|
|
18077
|
+
var ixdb = request.result;
|
|
18089
18078
|
var tx = ixdb.transaction([tableid], 'readwrite');
|
|
18090
18079
|
var tb = tx.objectStore(tableid);
|
|
18091
|
-
|
|
18092
18080
|
for (var i = 0, ilen = value.length; i < ilen; i++) {
|
|
18093
18081
|
tb.add(value[i]);
|
|
18094
18082
|
}
|
|
18095
18083
|
tx.oncomplete = function () {
|
|
18096
18084
|
ixdb.close();
|
|
18097
|
-
|
|
18098
18085
|
if (cb) cb(ilen);
|
|
18099
18086
|
};
|
|
18100
18087
|
};
|
|
18101
|
-
|
|
18102
18088
|
};
|
|
18103
18089
|
|
|
18104
18090
|
IDB.fromTable = function (databaseid, tableid, cb, idx, query) {
|
|
18091
|
+
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18092
|
+
const request = indexedDB.open(ixdbid);
|
|
18105
18093
|
|
|
18106
|
-
|
|
18107
|
-
|
|
18108
|
-
|
|
18109
|
-
|
|
18110
|
-
|
|
18111
|
-
|
|
18112
|
-
|
|
18113
|
-
|
|
18114
|
-
var tx = ixdb.transaction([tableid]);
|
|
18115
|
-
var store = tx.objectStore(tableid);
|
|
18116
|
-
var cur = store.openCursor();
|
|
18117
|
-
|
|
18118
|
-
cur.onblocked = function (event) {
|
|
18119
|
-
|
|
18120
|
-
};
|
|
18121
|
-
cur.onerror = function (event) {
|
|
18122
|
-
|
|
18123
|
-
};
|
|
18124
|
-
cur.onsuccess = function (event) {
|
|
18094
|
+
request.onupgradeneeded = (evt) => {
|
|
18095
|
+
evt.target.transaction.abort();
|
|
18096
|
+
const err = new Error(
|
|
18097
|
+
`Cannot select from table "${tableid}" because database "${databaseid}" does not exist`
|
|
18098
|
+
);
|
|
18099
|
+
if (cb) cb(null, err);
|
|
18100
|
+
};
|
|
18125
18101
|
|
|
18126
|
-
|
|
18102
|
+
request.onsuccess = () => {
|
|
18103
|
+
const res = [];
|
|
18104
|
+
const ixdb = request.result;
|
|
18105
|
+
const cur = ixdb.transaction([tableid]).objectStore(tableid).openCursor();
|
|
18127
18106
|
|
|
18107
|
+
cur.onsuccess = () => {
|
|
18108
|
+
const cursor = cur.result;
|
|
18128
18109
|
if (cursor) {
|
|
18129
18110
|
res.push(cursor.value);
|
|
18130
|
-
cursor
|
|
18111
|
+
cursor.continue();
|
|
18131
18112
|
} else {
|
|
18132
|
-
|
|
18133
18113
|
ixdb.close();
|
|
18134
18114
|
if (cb) cb(res, idx, query);
|
|
18135
18115
|
}
|
|
@@ -18138,39 +18118,23 @@ IDB.fromTable = function (databaseid, tableid, cb, idx, query) {
|
|
|
18138
18118
|
};
|
|
18139
18119
|
|
|
18140
18120
|
IDB.deleteFromTable = function (databaseid, tableid, wherefn, params, cb) {
|
|
18121
|
+
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18122
|
+
const request = indexedDB.open(ixdbid);
|
|
18141
18123
|
|
|
18142
|
-
|
|
18143
|
-
|
|
18144
|
-
|
|
18145
|
-
var request = indexedDB.open(ixdbid);
|
|
18146
|
-
request.onsuccess = function (event) {
|
|
18147
|
-
var res = [];
|
|
18148
|
-
var ixdb = event.target.result;
|
|
18149
|
-
|
|
18150
|
-
var tx = ixdb.transaction([tableid], 'readwrite');
|
|
18151
|
-
var store = tx.objectStore(tableid);
|
|
18152
|
-
var cur = store.openCursor();
|
|
18153
|
-
var num = 0;
|
|
18154
|
-
|
|
18155
|
-
cur.onblocked = function (event) {
|
|
18156
|
-
|
|
18157
|
-
};
|
|
18158
|
-
cur.onerror = function (event) {
|
|
18159
|
-
|
|
18160
|
-
};
|
|
18161
|
-
cur.onsuccess = function (event) {
|
|
18162
|
-
|
|
18163
|
-
var cursor = event.target.result;
|
|
18124
|
+
request.onsuccess = () => {
|
|
18125
|
+
const ixdb = request.result;
|
|
18126
|
+
const cur = ixdb.transaction([tableid], 'readwrite').objectStore(tableid).openCursor();
|
|
18164
18127
|
|
|
18128
|
+
let num = 0;
|
|
18129
|
+
cur.onsuccess = () => {
|
|
18130
|
+
var cursor = cur.result;
|
|
18165
18131
|
if (cursor) {
|
|
18166
|
-
if (!wherefn || wherefn(cursor.value, params)) {
|
|
18167
|
-
|
|
18168
|
-
cursor["delete"]();
|
|
18132
|
+
if (!wherefn || wherefn(cursor.value, params, alasql)) {
|
|
18133
|
+
cursor.delete();
|
|
18169
18134
|
num++;
|
|
18170
18135
|
}
|
|
18171
|
-
cursor
|
|
18136
|
+
cursor.continue();
|
|
18172
18137
|
} else {
|
|
18173
|
-
|
|
18174
18138
|
ixdb.close();
|
|
18175
18139
|
if (cb) cb(num);
|
|
18176
18140
|
}
|
|
@@ -18179,42 +18143,24 @@ IDB.deleteFromTable = function (databaseid, tableid, wherefn, params, cb) {
|
|
|
18179
18143
|
};
|
|
18180
18144
|
|
|
18181
18145
|
IDB.updateTable = function (databaseid, tableid, assignfn, wherefn, params, cb) {
|
|
18182
|
-
|
|
18183
|
-
|
|
18184
|
-
|
|
18185
|
-
|
|
18186
|
-
|
|
18187
|
-
|
|
18188
|
-
|
|
18189
|
-
|
|
18190
|
-
|
|
18191
|
-
var tx = ixdb.transaction([tableid], 'readwrite');
|
|
18192
|
-
var store = tx.objectStore(tableid);
|
|
18193
|
-
var cur = store.openCursor();
|
|
18194
|
-
var num = 0;
|
|
18195
|
-
|
|
18196
|
-
cur.onblocked = function (event) {
|
|
18197
|
-
|
|
18198
|
-
};
|
|
18199
|
-
cur.onerror = function (event) {
|
|
18200
|
-
|
|
18201
|
-
};
|
|
18202
|
-
cur.onsuccess = function (event) {
|
|
18203
|
-
|
|
18204
|
-
var cursor = event.target.result;
|
|
18205
|
-
|
|
18146
|
+
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18147
|
+
const request = indexedDB.open(ixdbid);
|
|
18148
|
+
request.onsuccess = function () {
|
|
18149
|
+
const ixdb = request.result;
|
|
18150
|
+
const cur = ixdb.transaction([tableid], 'readwrite').objectStore(tableid).openCursor();
|
|
18151
|
+
|
|
18152
|
+
let num = 0;
|
|
18153
|
+
cur.onsuccess = () => {
|
|
18154
|
+
var cursor = cur.result;
|
|
18206
18155
|
if (cursor) {
|
|
18207
18156
|
if (!wherefn || wherefn(cursor.value, params)) {
|
|
18208
|
-
|
|
18209
18157
|
var r = cursor.value;
|
|
18210
18158
|
assignfn(r, params);
|
|
18211
|
-
|
|
18212
18159
|
cursor.update(r);
|
|
18213
18160
|
num++;
|
|
18214
18161
|
}
|
|
18215
|
-
cursor
|
|
18162
|
+
cursor.continue();
|
|
18216
18163
|
} else {
|
|
18217
|
-
|
|
18218
18164
|
ixdb.close();
|
|
18219
18165
|
if (cb) cb(num);
|
|
18220
18166
|
}
|
|
@@ -19316,35 +19262,35 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
19316
19262
|
});
|
|
19317
19263
|
}
|
|
19318
19264
|
|
|
19319
|
-
/* eslint-disable */
|
|
19265
|
+
/* eslint-disable */
|
|
19320
19266
|
|
|
19321
|
-
/*
|
|
19322
|
-
//
|
|
19323
|
-
// Last part of Alasql.js
|
|
19324
|
-
// Date: 03.11.2014
|
|
19325
|
-
// (c) 2014, Andrey Gershun
|
|
19326
|
-
//
|
|
19327
|
-
*/
|
|
19267
|
+
/*
|
|
19268
|
+
//
|
|
19269
|
+
// Last part of Alasql.js
|
|
19270
|
+
// Date: 03.11.2014
|
|
19271
|
+
// (c) 2014, Andrey Gershun
|
|
19272
|
+
//
|
|
19273
|
+
*/
|
|
19328
19274
|
|
|
19329
|
-
// This is a final part of Alasql
|
|
19275
|
+
// This is a final part of Alasql
|
|
19330
19276
|
|
|
19331
|
-
//*only-for-browser/*
|
|
19332
|
-
if(utils.isCordova || utils.isMeteorServer || utils.isNode ){
|
|
19333
|
-
console.log('It looks like you are using the browser version of AlaSQL. Please use the alasql.fs.js file instead.')
|
|
19334
|
-
}
|
|
19335
|
-
//*/
|
|
19277
|
+
//*only-for-browser/*
|
|
19278
|
+
if(utils.isCordova || utils.isMeteorServer || utils.isNode ){
|
|
19279
|
+
console.log('It looks like you are using the browser version of AlaSQL. Please use the alasql.fs.js file instead.')
|
|
19280
|
+
}
|
|
19281
|
+
//*/
|
|
19336
19282
|
|
|
19337
|
-
// FileSaveAs
|
|
19338
|
-
alasql.utils.saveAs = saveAs;
|
|
19283
|
+
// FileSaveAs
|
|
19284
|
+
alasql.utils.saveAs = saveAs;
|
|
19339
19285
|
|
|
19340
|
-
};
|
|
19286
|
+
};
|
|
19341
19287
|
|
|
19342
|
-
// Create default database
|
|
19343
|
-
new Database("alasql");
|
|
19288
|
+
// Create default database
|
|
19289
|
+
new Database("alasql");
|
|
19344
19290
|
|
|
19345
|
-
// Set default database
|
|
19346
|
-
alasql.use("alasql");
|
|
19291
|
+
// Set default database
|
|
19292
|
+
alasql.use("alasql");
|
|
19347
19293
|
|
|
19348
|
-
return alasql;
|
|
19349
|
-
}));
|
|
19294
|
+
return alasql;
|
|
19295
|
+
}));
|
|
19350
19296
|
|