alasql 2.2.2 → 2.2.4
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 +1290 -1436
- package/dist/alasql.js +1566 -1704
- package/dist/alasql.min.js +7 -7
- package/package.json +5 -6
package/dist/alasql.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v2.2.
|
|
1
|
+
//! AlaSQL v2.2.3-develop-21117291 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 2.2.
|
|
4
|
+
@version 2.2.3-develop-21117291
|
|
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.3-develop-21117291';
|
|
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
5828
|
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
if (typeof r === 'undefined') {
|
|
5784
|
-
r = {status: 1, values: [value]};
|
|
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
|
-
|
|
5839
|
-
var fn = new Function('params,alasql', 'var y;return ' + as).bind(this);
|
|
5840
|
-
return fn(params, alasql);
|
|
5841
|
-
});
|
|
5842
5876
|
|
|
5843
|
-
|
|
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();
|
|
5844
5884
|
|
|
5845
|
-
|
|
5846
|
-
|
|
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
|
-
|
|
5881
|
-
res = processSelector(selectors, 0, fromdata);
|
|
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
5888
|
|
|
5912
|
-
|
|
5913
|
-
Search class
|
|
5914
|
-
@class
|
|
5915
|
-
@example
|
|
5916
|
-
SEARCH SUM(/a) FROM ? -- search over parameter object
|
|
5917
|
-
*/
|
|
5889
|
+
fromdata = alasql.from[this.from.funcid.toUpperCase()].apply(this, args);
|
|
5918
5890
|
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
}
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
return s;
|
|
5933
|
-
};
|
|
5934
|
-
|
|
5935
|
-
yy.Search.prototype.toJS = function (context) {
|
|
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();
|
|
5903
|
+
}
|
|
5936
5904
|
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
}
|
|
5905
|
+
// if(typeof fromdata == 'object' && Array.isArray(fromdata)) {
|
|
5906
|
+
// selectors.unshift({srchid:'CHILD'});
|
|
5907
|
+
// }
|
|
5908
|
+
}
|
|
5941
5909
|
|
|
5942
|
-
|
|
5943
|
-
var
|
|
5944
|
-
var
|
|
5910
|
+
// If source data is array than first step is to run over array
|
|
5911
|
+
// var selidx = 0;
|
|
5912
|
+
// var selvalue = fromdata;
|
|
5945
5913
|
|
|
5946
|
-
|
|
5914
|
+
if (selectors !== undefined && selectors.length > 0) {
|
|
5915
|
+
// Init variables for TO() selectors
|
|
5947
5916
|
|
|
5948
|
-
|
|
5949
|
-
|
|
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
|
+
});
|
|
5925
|
+
}
|
|
5950
5926
|
|
|
5951
|
-
res =
|
|
5927
|
+
res = processSelector(selectors, 0, fromdata);
|
|
5928
|
+
} else {
|
|
5929
|
+
res = fromdata;
|
|
5930
|
+
}
|
|
5952
5931
|
|
|
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);
|
|
5947
|
+
} else {
|
|
5948
|
+
if (stope.value && res.length > 0) {
|
|
5949
|
+
res = res[0];
|
|
5950
|
+
}
|
|
5953
5951
|
if (cb) {
|
|
5954
5952
|
res = cb(res);
|
|
5955
5953
|
}
|
|
5956
|
-
}
|
|
5957
|
-
|
|
5958
|
-
// if(cb) res = cb(res);
|
|
5954
|
+
}
|
|
5959
5955
|
return res;
|
|
5960
|
-
}
|
|
5961
|
-
statement.query = {};
|
|
5962
|
-
return statement;
|
|
5956
|
+
}
|
|
5963
5957
|
};
|
|
5964
5958
|
|
|
5965
5959
|
// List of search functions
|
|
5966
|
-
alasql.srch = {
|
|
5960
|
+
alasql.srch = {
|
|
5961
|
+
PROP(val, args, stope) {
|
|
5967
5962
|
|
|
5968
|
-
|
|
5963
|
+
if (stope.mode === 'XML') {
|
|
5964
|
+
const values = val.children.filter((v) => v.name.toUpperCase() === args[0].toUpperCase());
|
|
5969
5965
|
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
arr.push(v);
|
|
5975
|
-
}
|
|
5976
|
-
});
|
|
5977
|
-
if (arr.length > 0) {
|
|
5978
|
-
return {status: 1, values: arr};
|
|
5966
|
+
return {
|
|
5967
|
+
status: values.length ? 1 : -1,
|
|
5968
|
+
values,
|
|
5969
|
+
};
|
|
5979
5970
|
} else {
|
|
5980
|
-
|
|
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: []};
|
|
5978
|
+
} else {
|
|
5979
|
+
return {status: 1, values: [val[args[0]]]};
|
|
5980
|
+
}
|
|
5981
5981
|
}
|
|
5982
|
-
}
|
|
5982
|
+
},
|
|
5983
|
+
|
|
5984
|
+
APROP(val, args) {
|
|
5983
5985
|
if (
|
|
5984
5986
|
typeof val !== 'object' ||
|
|
5985
5987
|
val === null ||
|
|
5986
5988
|
typeof args !== 'object' ||
|
|
5987
5989
|
typeof val[args[0]] === 'undefined'
|
|
5988
5990
|
) {
|
|
5989
|
-
return {status:
|
|
5991
|
+
return {status: 1, values: [undefined]};
|
|
5990
5992
|
} else {
|
|
5991
5993
|
return {status: 1, values: [val[args[0]]]};
|
|
5992
5994
|
}
|
|
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
|
-
|
|
6009
|
-
// Test expression
|
|
6010
|
-
alasql.srch.EQ = function (val, args, stope, params) {
|
|
6011
|
-
var exprs = args[0].toJS('x', '');
|
|
6012
|
-
var exprfn = new Function('x,alasql,params', 'return ' + exprs);
|
|
6013
|
-
if (val === exprfn(val, alasql, params)) {
|
|
6014
|
-
return {status: 1, values: [val]};
|
|
6015
|
-
} else {
|
|
6016
|
-
return {status: -1, values: []};
|
|
6017
|
-
}
|
|
6018
|
-
};
|
|
5995
|
+
},
|
|
6019
5996
|
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
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
|
-
};
|
|
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
|
+
},
|
|
6041
6006
|
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
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]};
|
|
6046
6024
|
} else {
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6025
|
+
return {status: -1, values: []};
|
|
6026
|
+
}
|
|
6027
|
+
},
|
|
6028
|
+
|
|
6029
|
+
ATTR(val, args, stope) {
|
|
6030
|
+
if (stope.mode === 'XML') {
|
|
6031
|
+
if (typeof args === 'undefined') {
|
|
6032
|
+
return {status: 1, values: [val.attributes]};
|
|
6053
6033
|
} else {
|
|
6054
|
-
|
|
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
|
+
}
|
|
6055
6043
|
}
|
|
6044
|
+
} else {
|
|
6045
|
+
throw new Error('ATTR is not using in usual mode');
|
|
6056
6046
|
}
|
|
6057
|
-
}
|
|
6058
|
-
throw new Error('ATTR is not using in usual mode');
|
|
6059
|
-
}
|
|
6060
|
-
};
|
|
6047
|
+
},
|
|
6061
6048
|
|
|
6062
|
-
|
|
6063
|
-
|
|
6049
|
+
CONTENT(val, args, stope) {
|
|
6050
|
+
if (stope.mode !== 'XML') {
|
|
6051
|
+
throw new Error('ATTR is not using in usual mode');
|
|
6052
|
+
}
|
|
6064
6053
|
return {status: 1, values: [val.content]};
|
|
6065
|
-
}
|
|
6066
|
-
throw new Error('ATTR is not using in usual mode');
|
|
6067
|
-
}
|
|
6068
|
-
};
|
|
6054
|
+
},
|
|
6069
6055
|
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
} else {
|
|
6075
|
-
return {status: -1, values: []};
|
|
6076
|
-
}
|
|
6077
|
-
};
|
|
6078
|
-
|
|
6079
|
-
alasql.srch.PARENT = function (/*val,args,stope*/) {
|
|
6080
|
-
// TODO: implement
|
|
6081
|
-
console.error('PARENT not implemented', arguments);
|
|
6082
|
-
|
|
6083
|
-
return {status: -1, values: []};
|
|
6084
|
-
};
|
|
6085
|
-
|
|
6086
|
-
alasql.srch.CHILD = function (val, args, stope) {
|
|
6087
|
-
|
|
6088
|
-
if (typeof val === 'object') {
|
|
6089
|
-
if (Array.isArray(val)) {
|
|
6090
|
-
return {status: 1, values: val};
|
|
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]};
|
|
6091
6060
|
} else {
|
|
6092
|
-
|
|
6093
|
-
return {
|
|
6094
|
-
status: 1,
|
|
6095
|
-
values: Object.keys(val.children).map(function (key) {
|
|
6096
|
-
return val.children[key];
|
|
6097
|
-
}),
|
|
6098
|
-
};
|
|
6099
|
-
} else {
|
|
6100
|
-
return {
|
|
6101
|
-
status: 1,
|
|
6102
|
-
values: Object.keys(val).map(function (key) {
|
|
6103
|
-
return val[key];
|
|
6104
|
-
}),
|
|
6105
|
-
};
|
|
6106
|
-
}
|
|
6061
|
+
return {status: -1, values: []};
|
|
6107
6062
|
}
|
|
6108
|
-
}
|
|
6109
|
-
// If primitive value
|
|
6110
|
-
return {status: 1, values: []};
|
|
6111
|
-
}
|
|
6112
|
-
};
|
|
6113
|
-
|
|
6114
|
-
// Return all keys
|
|
6115
|
-
alasql.srch.KEYS = function (val) {
|
|
6116
|
-
if (typeof val === 'object' && val !== null) {
|
|
6117
|
-
return {status: 1, values: Object.keys(val)};
|
|
6118
|
-
} else {
|
|
6119
|
-
// If primitive value
|
|
6120
|
-
return {status: 1, values: []};
|
|
6121
|
-
}
|
|
6122
|
-
};
|
|
6123
|
-
|
|
6124
|
-
// Test expression
|
|
6125
|
-
alasql.srch.WHERE = function (val, args, stope, params) {
|
|
6126
|
-
var exprs = args[0].toJS('x', '');
|
|
6127
|
-
var exprfn = new Function('x,alasql,params', 'return ' + exprs);
|
|
6128
|
-
if (exprfn(val, alasql, params)) {
|
|
6129
|
-
return {status: 1, values: [val]};
|
|
6130
|
-
} else {
|
|
6131
|
-
return {status: -1, values: []};
|
|
6132
|
-
}
|
|
6133
|
-
};
|
|
6134
|
-
|
|
6135
|
-
alasql.srch.NAME = function (val, args) {
|
|
6136
|
-
if (val.name === args[0]) {
|
|
6137
|
-
return {status: 1, values: [val]};
|
|
6138
|
-
} else {
|
|
6139
|
-
return {status: -1, values: []};
|
|
6140
|
-
}
|
|
6141
|
-
};
|
|
6063
|
+
},
|
|
6142
6064
|
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
if (val.$class == args) {
|
|
6147
|
-
// jshint ignore:line
|
|
6148
|
-
return {status: 1, values: [val]};
|
|
6149
|
-
} else {
|
|
6150
|
-
return {status: -1, values: []};
|
|
6151
|
-
}
|
|
6152
|
-
};
|
|
6065
|
+
PARENT(/*val,args,stope*/) {
|
|
6066
|
+
// TODO: implement
|
|
6067
|
+
console.error('PARENT not implemented', arguments);
|
|
6153
6068
|
|
|
6154
|
-
// Transform expression
|
|
6155
|
-
alasql.srch.VERTEX = function (val) {
|
|
6156
|
-
if (val.$node === 'VERTEX') {
|
|
6157
|
-
return {status: 1, values: [val]};
|
|
6158
|
-
} else {
|
|
6159
6069
|
return {status: -1, values: []};
|
|
6160
|
-
}
|
|
6161
|
-
};
|
|
6070
|
+
},
|
|
6162
6071
|
|
|
6163
|
-
|
|
6164
|
-
alasql.srch.INSTANCEOF = function (val, args) {
|
|
6165
|
-
if (val instanceof alasql.fn[args[0]]) {
|
|
6166
|
-
return {status: 1, values: [val]};
|
|
6167
|
-
} else {
|
|
6168
|
-
return {status: -1, values: []};
|
|
6169
|
-
}
|
|
6170
|
-
};
|
|
6072
|
+
CHILD(val, args, stope) {
|
|
6171
6073
|
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
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
|
+
}
|
|
6093
|
+
}
|
|
6094
|
+
} else {
|
|
6095
|
+
// If primitive value
|
|
6096
|
+
return {status: 1, values: []};
|
|
6097
|
+
}
|
|
6098
|
+
},
|
|
6180
6099
|
|
|
6181
|
-
//
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
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
|
+
},
|
|
6187
6109
|
|
|
6188
|
-
//
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
res[arg.as] = exprfn(val, alasql, params);
|
|
6199
|
-
});
|
|
6200
|
-
}
|
|
6201
|
-
return {status: 1, values: [res]};
|
|
6202
|
-
};
|
|
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
|
+
},
|
|
6203
6120
|
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
}
|
|
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
|
+
},
|
|
6208
6128
|
|
|
6209
|
-
|
|
6210
|
-
alasql.srch.OUT = function (val) {
|
|
6211
|
-
if (val.$out && val.$out.length > 0) {
|
|
6212
|
-
var res = val.$out.map(function (v) {
|
|
6213
|
-
return alasql.databases[alasql.useid].objects[v];
|
|
6214
|
-
});
|
|
6215
|
-
return {status: 1, values: res};
|
|
6216
|
-
} else {
|
|
6217
|
-
return {status: -1, values: []};
|
|
6218
|
-
}
|
|
6219
|
-
};
|
|
6129
|
+
CLASS(val, args) {
|
|
6220
6130
|
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
});
|
|
6230
|
-
}
|
|
6231
|
-
});
|
|
6232
|
-
return {status: 1, values: res};
|
|
6233
|
-
} else {
|
|
6234
|
-
return {status: -1, values: []};
|
|
6235
|
-
}
|
|
6236
|
-
};
|
|
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
|
+
},
|
|
6237
6139
|
|
|
6238
|
-
// Transform expression
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
}
|
|
6246
|
-
return {status: -1, values: []};
|
|
6247
|
-
}
|
|
6248
|
-
};
|
|
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
|
+
},
|
|
6249
6148
|
|
|
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
|
-
};
|
|
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
|
+
},
|
|
6266
6157
|
|
|
6267
|
-
// Transform expression
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
}
|
|
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
|
+
},
|
|
6272
6189
|
|
|
6273
|
-
// Transform expression
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
};
|
|
6190
|
+
// Transform expression
|
|
6191
|
+
REF(val) {
|
|
6192
|
+
return {status: 1, values: [alasql.databases[alasql.useid].objects[val]]};
|
|
6193
|
+
},
|
|
6278
6194
|
|
|
6279
|
-
// Transform expression
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
};
|
|
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
|
+
},
|
|
6285
6206
|
|
|
6286
|
-
|
|
6287
|
-
|
|
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
|
+
},
|
|
6288
6223
|
|
|
6289
|
-
//
|
|
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() + ')';
|
|
@@ -10120,7 +10095,7 @@ yy.Select.prototype.compileDefCols = function (query, databaseid) {
|
|
|
10120
10095
|
// SELECT UNION statement
|
|
10121
10096
|
|
|
10122
10097
|
yy.Union = function (params) {
|
|
10123
|
-
return
|
|
10098
|
+
return Object.assign(this, params);
|
|
10124
10099
|
};
|
|
10125
10100
|
yy.Union.prototype.toString = function () {
|
|
10126
10101
|
return 'UNION';
|
|
@@ -10139,7 +10114,7 @@ yy.Union.prototype.compile = function (tableid) {
|
|
|
10139
10114
|
*/
|
|
10140
10115
|
|
|
10141
10116
|
yy.Apply = function (params) {
|
|
10142
|
-
return
|
|
10117
|
+
return Object.assign(this, params);
|
|
10143
10118
|
};
|
|
10144
10119
|
|
|
10145
10120
|
yy.Apply.prototype.toString = function () {
|
|
@@ -10159,7 +10134,7 @@ yy.Apply.prototype.toString = function () {
|
|
|
10159
10134
|
*/
|
|
10160
10135
|
|
|
10161
10136
|
yy.Over = function (params) {
|
|
10162
|
-
return
|
|
10137
|
+
return Object.assign(this, params);
|
|
10163
10138
|
};
|
|
10164
10139
|
yy.Over.prototype.toString = function () {
|
|
10165
10140
|
var s = 'OVER (';
|
|
@@ -10182,13 +10157,15 @@ yy.Over.prototype.toString = function () {
|
|
|
10182
10157
|
//
|
|
10183
10158
|
*/
|
|
10184
10159
|
|
|
10160
|
+
var assign = Object.assign;
|
|
10161
|
+
|
|
10185
10162
|
/**
|
|
10186
10163
|
Expression statement ( = 2*2; )
|
|
10187
10164
|
@class
|
|
10188
10165
|
@param {object} params Initial parameters
|
|
10189
10166
|
*/
|
|
10190
10167
|
yy.ExpressionStatement = function (params) {
|
|
10191
|
-
return
|
|
10168
|
+
return assign(this, params);
|
|
10192
10169
|
};
|
|
10193
10170
|
|
|
10194
10171
|
/**
|
|
@@ -10229,7 +10206,7 @@ yy.ExpressionStatement.prototype.execute = function (databaseid, params, cb) {
|
|
|
10229
10206
|
*/
|
|
10230
10207
|
|
|
10231
10208
|
yy.Expression = function (params) {
|
|
10232
|
-
return
|
|
10209
|
+
return assign(this, params);
|
|
10233
10210
|
};
|
|
10234
10211
|
|
|
10235
10212
|
/**
|
|
@@ -10301,7 +10278,7 @@ yy.Expression.prototype.compile = function (context, tableid, defcols) {
|
|
|
10301
10278
|
@class
|
|
10302
10279
|
*/
|
|
10303
10280
|
yy.JavaScript = function (params) {
|
|
10304
|
-
return
|
|
10281
|
+
return assign(this, params);
|
|
10305
10282
|
};
|
|
10306
10283
|
yy.JavaScript.prototype.toString = function () {
|
|
10307
10284
|
var s = '``' + this.value + '``';
|
|
@@ -10329,7 +10306,7 @@ yy.JavaScript.prototype.execute = function (databaseid, params, cb) {
|
|
|
10329
10306
|
*/
|
|
10330
10307
|
|
|
10331
10308
|
yy.Literal = function (params) {
|
|
10332
|
-
return
|
|
10309
|
+
return assign(this, params);
|
|
10333
10310
|
};
|
|
10334
10311
|
yy.Literal.prototype.toString = function () {
|
|
10335
10312
|
var s = this.value;
|
|
@@ -10346,7 +10323,7 @@ yy.Literal.prototype.toString = function () {
|
|
|
10346
10323
|
*/
|
|
10347
10324
|
|
|
10348
10325
|
yy.Join = function (params) {
|
|
10349
|
-
return
|
|
10326
|
+
return assign(this, params);
|
|
10350
10327
|
};
|
|
10351
10328
|
yy.Join.prototype.toString = function () {
|
|
10352
10329
|
var s = ' ';
|
|
@@ -10363,7 +10340,7 @@ yy.Join.prototype.toString = function () {
|
|
|
10363
10340
|
*/
|
|
10364
10341
|
|
|
10365
10342
|
yy.Table = function (params) {
|
|
10366
|
-
return
|
|
10343
|
+
return assign(this, params);
|
|
10367
10344
|
};
|
|
10368
10345
|
yy.Table.prototype.toString = function () {
|
|
10369
10346
|
var s = this.tableid;
|
|
@@ -10380,7 +10357,7 @@ yy.Table.prototype.toString = function () {
|
|
|
10380
10357
|
*/
|
|
10381
10358
|
|
|
10382
10359
|
yy.View = function (params) {
|
|
10383
|
-
return
|
|
10360
|
+
return assign(this, params);
|
|
10384
10361
|
};
|
|
10385
10362
|
yy.View.prototype.toString = function () {
|
|
10386
10363
|
var s = this.viewid;
|
|
@@ -10396,7 +10373,7 @@ yy.View.prototype.toString = function () {
|
|
|
10396
10373
|
@class
|
|
10397
10374
|
*/
|
|
10398
10375
|
yy.Op = function (params) {
|
|
10399
|
-
return
|
|
10376
|
+
return assign(this, params);
|
|
10400
10377
|
};
|
|
10401
10378
|
yy.Op.prototype.toString = function () {
|
|
10402
10379
|
if (this.op === 'IN' || this.op === 'NOT IN') {
|
|
@@ -10594,9 +10571,9 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10594
10571
|
||
|
|
10595
10572
|
(
|
|
10596
10573
|
${leftOperand} < 0
|
|
10597
|
-
&&
|
|
10598
|
-
true == ${rightOperand}
|
|
10599
|
-
)
|
|
10574
|
+
&&
|
|
10575
|
+
true == ${rightOperand}
|
|
10576
|
+
)
|
|
10600
10577
|
)`;
|
|
10601
10578
|
}
|
|
10602
10579
|
}
|
|
@@ -10782,7 +10759,7 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10782
10759
|
};
|
|
10783
10760
|
|
|
10784
10761
|
yy.VarValue = function (params) {
|
|
10785
|
-
return
|
|
10762
|
+
return assign(this, params);
|
|
10786
10763
|
};
|
|
10787
10764
|
yy.VarValue.prototype.toString = function () {
|
|
10788
10765
|
return '@' + this.variable;
|
|
@@ -10797,7 +10774,7 @@ yy.VarValue.prototype.toJS = function () {
|
|
|
10797
10774
|
};
|
|
10798
10775
|
|
|
10799
10776
|
yy.NumValue = function (params) {
|
|
10800
|
-
return
|
|
10777
|
+
return assign(this, params);
|
|
10801
10778
|
};
|
|
10802
10779
|
yy.NumValue.prototype.toString = function () {
|
|
10803
10780
|
return this.value.toString();
|
|
@@ -10812,7 +10789,7 @@ yy.NumValue.prototype.toJS = function () {
|
|
|
10812
10789
|
};
|
|
10813
10790
|
|
|
10814
10791
|
yy.StringValue = function (params) {
|
|
10815
|
-
return
|
|
10792
|
+
return assign(this, params);
|
|
10816
10793
|
};
|
|
10817
10794
|
yy.StringValue.prototype.toString = function () {
|
|
10818
10795
|
return "'" + this.value.toString() + "'";
|
|
@@ -10827,7 +10804,7 @@ yy.StringValue.prototype.toJS = function () {
|
|
|
10827
10804
|
};
|
|
10828
10805
|
|
|
10829
10806
|
yy.DomainValueValue = function (params) {
|
|
10830
|
-
return
|
|
10807
|
+
return assign(this, params);
|
|
10831
10808
|
};
|
|
10832
10809
|
yy.DomainValueValue.prototype.toString = function () {
|
|
10833
10810
|
return 'VALUE';
|
|
@@ -10844,7 +10821,7 @@ yy.DomainValueValue.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10844
10821
|
};
|
|
10845
10822
|
|
|
10846
10823
|
yy.ArrayValue = function (params) {
|
|
10847
|
-
return
|
|
10824
|
+
return assign(this, params);
|
|
10848
10825
|
};
|
|
10849
10826
|
yy.ArrayValue.prototype.toString = function () {
|
|
10850
10827
|
return 'ARRAY[]';
|
|
@@ -10867,7 +10844,7 @@ yy.ArrayValue.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10867
10844
|
};
|
|
10868
10845
|
|
|
10869
10846
|
yy.LogicValue = function (params) {
|
|
10870
|
-
return
|
|
10847
|
+
return assign(this, params);
|
|
10871
10848
|
};
|
|
10872
10849
|
yy.LogicValue.prototype.toString = function () {
|
|
10873
10850
|
return this.value ? 'TRUE' : 'FALSE';
|
|
@@ -10882,7 +10859,7 @@ yy.LogicValue.prototype.toJS = function () {
|
|
|
10882
10859
|
};
|
|
10883
10860
|
|
|
10884
10861
|
yy.NullValue = function (params) {
|
|
10885
|
-
return
|
|
10862
|
+
return assign(this, params);
|
|
10886
10863
|
};
|
|
10887
10864
|
yy.NullValue.prototype.toString = function () {
|
|
10888
10865
|
return 'NULL';
|
|
@@ -10893,7 +10870,7 @@ yy.NullValue.prototype.toJS = function () {
|
|
|
10893
10870
|
};
|
|
10894
10871
|
|
|
10895
10872
|
yy.ParamValue = function (params) {
|
|
10896
|
-
return
|
|
10873
|
+
return assign(this, params);
|
|
10897
10874
|
};
|
|
10898
10875
|
yy.ParamValue.prototype.toString = function () {
|
|
10899
10876
|
return '$' + this.param;
|
|
@@ -10907,7 +10884,7 @@ yy.ParamValue.prototype.toJS = function () {
|
|
|
10907
10884
|
};
|
|
10908
10885
|
|
|
10909
10886
|
yy.UniOp = function (params) {
|
|
10910
|
-
return
|
|
10887
|
+
return assign(this, params);
|
|
10911
10888
|
};
|
|
10912
10889
|
yy.UniOp.prototype.toString = function () {
|
|
10913
10890
|
var s;
|
|
@@ -10997,7 +10974,7 @@ yy.UniOp.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10997
10974
|
};
|
|
10998
10975
|
|
|
10999
10976
|
yy.Column = function (params) {
|
|
11000
|
-
return
|
|
10977
|
+
return assign(this, params);
|
|
11001
10978
|
};
|
|
11002
10979
|
yy.Column.prototype.toString = function () {
|
|
11003
10980
|
var s;
|
|
@@ -11078,7 +11055,7 @@ yy.Column.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11078
11055
|
};
|
|
11079
11056
|
|
|
11080
11057
|
yy.AggrValue = function (params) {
|
|
11081
|
-
return
|
|
11058
|
+
return assign(this, params);
|
|
11082
11059
|
};
|
|
11083
11060
|
yy.AggrValue.prototype.toString = function () {
|
|
11084
11061
|
var s = '';
|
|
@@ -11153,13 +11130,13 @@ yy.AggrValue.prototype.toJS = function () {
|
|
|
11153
11130
|
};
|
|
11154
11131
|
|
|
11155
11132
|
yy.OrderExpression = function (params) {
|
|
11156
|
-
return
|
|
11133
|
+
return assign(this, params);
|
|
11157
11134
|
};
|
|
11158
11135
|
|
|
11159
11136
|
yy.OrderExpression.prototype.toString = yy.Expression.prototype.toString;
|
|
11160
11137
|
|
|
11161
11138
|
yy.GroupExpression = function (params) {
|
|
11162
|
-
return
|
|
11139
|
+
return assign(this, params);
|
|
11163
11140
|
};
|
|
11164
11141
|
yy.GroupExpression.prototype.toString = function () {
|
|
11165
11142
|
return this.type + '(' + this.group.toString() + ')';
|
|
@@ -11340,7 +11317,7 @@ yy.Select.prototype.Where = function (expr) {
|
|
|
11340
11317
|
*/
|
|
11341
11318
|
|
|
11342
11319
|
yy.FuncValue = function (params) {
|
|
11343
|
-
return
|
|
11320
|
+
return Object.assign(this, params);
|
|
11344
11321
|
};
|
|
11345
11322
|
|
|
11346
11323
|
var re_invalidFnNameChars = /[^0-9A-Z_$]+/i;
|
|
@@ -11802,7 +11779,7 @@ stdfn.NEWID =
|
|
|
11802
11779
|
*/
|
|
11803
11780
|
|
|
11804
11781
|
yy.CaseValue = function (params) {
|
|
11805
|
-
return
|
|
11782
|
+
return Object.assign(this, params);
|
|
11806
11783
|
};
|
|
11807
11784
|
yy.CaseValue.prototype.toString = function () {
|
|
11808
11785
|
var s = 'CASE ';
|
|
@@ -11876,7 +11853,7 @@ yy.CaseValue.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11876
11853
|
*/
|
|
11877
11854
|
|
|
11878
11855
|
yy.Json = function (params) {
|
|
11879
|
-
return
|
|
11856
|
+
return Object.assign(this, params);
|
|
11880
11857
|
};
|
|
11881
11858
|
yy.Json.prototype.toString = function () {
|
|
11882
11859
|
var s = ''; // '@'
|
|
@@ -11985,7 +11962,7 @@ yy.Json.prototype.toJS = function (context, tableid, defcols) {
|
|
|
11985
11962
|
*/
|
|
11986
11963
|
|
|
11987
11964
|
yy.Convert = function (params) {
|
|
11988
|
-
return
|
|
11965
|
+
return Object.assign(this, params);
|
|
11989
11966
|
};
|
|
11990
11967
|
yy.Convert.prototype.toString = function () {
|
|
11991
11968
|
var s = 'CONVERT(';
|
|
@@ -12279,7 +12256,7 @@ alasql.stdfn.CONVERT = function (value, args) {
|
|
|
12279
12256
|
/* global alasql, yy, hash */
|
|
12280
12257
|
|
|
12281
12258
|
yy.ColumnDef = function (params) {
|
|
12282
|
-
return
|
|
12259
|
+
return Object.assign(this, params);
|
|
12283
12260
|
};
|
|
12284
12261
|
yy.ColumnDef.prototype.toString = function () {
|
|
12285
12262
|
var s = this.columnid;
|
|
@@ -12307,7 +12284,7 @@ yy.ColumnDef.prototype.toString = function () {
|
|
|
12307
12284
|
};
|
|
12308
12285
|
|
|
12309
12286
|
yy.CreateTable = function (params) {
|
|
12310
|
-
return
|
|
12287
|
+
return Object.assign(this, params);
|
|
12311
12288
|
};
|
|
12312
12289
|
yy.CreateTable.prototype.toString = function () {
|
|
12313
12290
|
var s = 'CREATE';
|
|
@@ -12318,7 +12295,7 @@ yy.CreateTable.prototype.toString = function () {
|
|
|
12318
12295
|
if (this.view) {
|
|
12319
12296
|
s += ' VIEW';
|
|
12320
12297
|
} else {
|
|
12321
|
-
s += ' ' + (this
|
|
12298
|
+
s += ' ' + (this.class ? 'CLASS' : 'TABLE');
|
|
12322
12299
|
}
|
|
12323
12300
|
if (this.ifnotexists) {
|
|
12324
12301
|
s += ' IF NOT EXISTS';
|
|
@@ -12387,7 +12364,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
12387
12364
|
|
|
12388
12365
|
var table = (db.tables[tableid] = new alasql.Table()); // TODO Can use special object?
|
|
12389
12366
|
// If this is a class
|
|
12390
|
-
if (this
|
|
12367
|
+
if (this.class) {
|
|
12391
12368
|
table.isclass = true;
|
|
12392
12369
|
}
|
|
12393
12370
|
|
|
@@ -12428,8 +12405,8 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
12428
12405
|
});
|
|
12429
12406
|
}
|
|
12430
12407
|
|
|
12431
|
-
if (col
|
|
12432
|
-
ss.push("'" + col.columnid + "':" + col
|
|
12408
|
+
if (col.default) {
|
|
12409
|
+
ss.push("'" + col.columnid + "':" + col.default.toJS('r', ''));
|
|
12433
12410
|
}
|
|
12434
12411
|
|
|
12435
12412
|
// Check for primary key
|
|
@@ -12758,7 +12735,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
12758
12735
|
alasql.inserted = oldinserted;
|
|
12759
12736
|
};
|
|
12760
12737
|
|
|
12761
|
-
table
|
|
12738
|
+
table.delete = function (index) {
|
|
12762
12739
|
var table = this;
|
|
12763
12740
|
var r = table.data[index];
|
|
12764
12741
|
|
|
@@ -13125,7 +13102,7 @@ function newDate(d) {
|
|
|
13125
13102
|
*/
|
|
13126
13103
|
|
|
13127
13104
|
yy.DropTable = function (params) {
|
|
13128
|
-
return
|
|
13105
|
+
return Object.assign(this, params);
|
|
13129
13106
|
};
|
|
13130
13107
|
yy.DropTable.prototype.toString = function () {
|
|
13131
13108
|
var s = 'DROP' + ' ';
|
|
@@ -13198,7 +13175,7 @@ yy.DropTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
13198
13175
|
};
|
|
13199
13176
|
|
|
13200
13177
|
yy.TruncateTable = function (params) {
|
|
13201
|
-
return
|
|
13178
|
+
return Object.assign(this, params);
|
|
13202
13179
|
};
|
|
13203
13180
|
yy.TruncateTable.prototype.toString = function () {
|
|
13204
13181
|
var s = 'TRUNCATE TABLE';
|
|
@@ -13234,12 +13211,12 @@ yy.TruncateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
13234
13211
|
*/
|
|
13235
13212
|
|
|
13236
13213
|
yy.CreateVertex = function (params) {
|
|
13237
|
-
return
|
|
13214
|
+
return Object.assign(this, params);
|
|
13238
13215
|
};
|
|
13239
13216
|
yy.CreateVertex.prototype.toString = function () {
|
|
13240
13217
|
var s = 'CREATE VERTEX ';
|
|
13241
|
-
if (this
|
|
13242
|
-
s += this
|
|
13218
|
+
if (this.class) {
|
|
13219
|
+
s += this.class + ' ';
|
|
13243
13220
|
}
|
|
13244
13221
|
if (this.sharp) {
|
|
13245
13222
|
s += '#' + this.sharp + ' ';
|
|
@@ -13317,13 +13294,13 @@ yy.CreateVertex.prototype.compile = function (databaseid) {
|
|
|
13317
13294
|
};
|
|
13318
13295
|
|
|
13319
13296
|
yy.CreateEdge = function (params) {
|
|
13320
|
-
return
|
|
13297
|
+
return Object.assign(this, params);
|
|
13321
13298
|
};
|
|
13322
13299
|
yy.CreateEdge.prototype.toString = function () {
|
|
13323
13300
|
|
|
13324
13301
|
var s = 'CREATE EDGE' + ' ';
|
|
13325
|
-
if (this
|
|
13326
|
-
s += this
|
|
13302
|
+
if (this.class) {
|
|
13303
|
+
s += this.class + ' ';
|
|
13327
13304
|
}
|
|
13328
13305
|
// todo: SET
|
|
13329
13306
|
// todo: CONTENT
|
|
@@ -13410,12 +13387,12 @@ yy.CreateEdge.prototype.compile = function (databaseid) {
|
|
|
13410
13387
|
};
|
|
13411
13388
|
|
|
13412
13389
|
yy.CreateGraph = function (params) {
|
|
13413
|
-
return
|
|
13390
|
+
return Object.assign(this, params);
|
|
13414
13391
|
};
|
|
13415
13392
|
yy.CreateGraph.prototype.toString = function () {
|
|
13416
13393
|
var s = 'CREATE GRAPH' + ' ';
|
|
13417
|
-
if (this
|
|
13418
|
-
s += this
|
|
13394
|
+
if (this.class) {
|
|
13395
|
+
s += this.class + ' ';
|
|
13419
13396
|
}
|
|
13420
13397
|
return s;
|
|
13421
13398
|
};
|
|
@@ -13448,8 +13425,8 @@ yy.CreateGraph.prototype.execute = function (databaseid, params, cb) {
|
|
|
13448
13425
|
if (typeof g.name !== 'undefined') {
|
|
13449
13426
|
e.name = g.name;
|
|
13450
13427
|
}
|
|
13451
|
-
if (typeof g
|
|
13452
|
-
e.$class = g
|
|
13428
|
+
if (typeof g.class !== 'undefined') {
|
|
13429
|
+
e.$class = g.class;
|
|
13453
13430
|
}
|
|
13454
13431
|
|
|
13455
13432
|
var db = alasql.databases[databaseid];
|
|
@@ -13577,8 +13554,8 @@ yy.CreateGraph.prototype.execute = function (databaseid, params, cb) {
|
|
|
13577
13554
|
if (typeof g.name !== 'undefined') {
|
|
13578
13555
|
v.name = g.name;
|
|
13579
13556
|
}
|
|
13580
|
-
if (typeof g
|
|
13581
|
-
v.$class = g
|
|
13557
|
+
if (typeof g.class !== 'undefined') {
|
|
13558
|
+
v.$class = g.class;
|
|
13582
13559
|
}
|
|
13583
13560
|
|
|
13584
13561
|
var db = alasql.databases[databaseid];
|
|
@@ -13675,7 +13652,7 @@ yy.CreateGraph.prototype.compile1 = function (databaseid) {
|
|
|
13675
13652
|
|
|
13676
13653
|
// ALTER TABLE table1 RENAME TO table2
|
|
13677
13654
|
yy.AlterTable = function (params) {
|
|
13678
|
-
return
|
|
13655
|
+
return Object.assign(this, params);
|
|
13679
13656
|
};
|
|
13680
13657
|
yy.AlterTable.prototype.toString = function () {
|
|
13681
13658
|
var s = 'ALTER TABLE ' + this.table.toString();
|
|
@@ -13852,7 +13829,7 @@ yy.AlterTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
13852
13829
|
*/
|
|
13853
13830
|
|
|
13854
13831
|
yy.CreateIndex = function (params) {
|
|
13855
|
-
return
|
|
13832
|
+
return Object.assign(this, params);
|
|
13856
13833
|
};
|
|
13857
13834
|
yy.CreateIndex.prototype.toString = function () {
|
|
13858
13835
|
var s = 'CREATE';
|
|
@@ -13915,7 +13892,7 @@ yy.CreateIndex.prototype.execute = function (databaseid, params, cb) {
|
|
|
13915
13892
|
};
|
|
13916
13893
|
|
|
13917
13894
|
yy.Reindex = function (params) {
|
|
13918
|
-
return
|
|
13895
|
+
return Object.assign(this, params);
|
|
13919
13896
|
};
|
|
13920
13897
|
yy.Reindex.prototype.toString = function () {
|
|
13921
13898
|
var s = 'REINDEX ' + this.indexid;
|
|
@@ -13945,7 +13922,7 @@ yy.Reindex.prototype.execute = function (databaseid, params, cb) {
|
|
|
13945
13922
|
*/
|
|
13946
13923
|
|
|
13947
13924
|
yy.DropIndex = function (params) {
|
|
13948
|
-
return
|
|
13925
|
+
return Object.assign(this, params);
|
|
13949
13926
|
};
|
|
13950
13927
|
yy.DropIndex.prototype.toString = function () {
|
|
13951
13928
|
return 'DROP INDEX' + this.indexid;
|
|
@@ -13968,7 +13945,7 @@ yy.DropIndex.prototype.compile = function (db) {
|
|
|
13968
13945
|
*/
|
|
13969
13946
|
|
|
13970
13947
|
yy.WithSelect = function (params) {
|
|
13971
|
-
return
|
|
13948
|
+
return Object.assign(this, params);
|
|
13972
13949
|
};
|
|
13973
13950
|
yy.WithSelect.prototype.toString = function () {
|
|
13974
13951
|
var s = 'WITH ';
|
|
@@ -14017,7 +13994,7 @@ yy.WithSelect.prototype.execute = function (databaseid, params, cb) {
|
|
|
14017
13994
|
*/
|
|
14018
13995
|
|
|
14019
13996
|
yy.If = function (params) {
|
|
14020
|
-
return
|
|
13997
|
+
return Object.assign(this, params);
|
|
14021
13998
|
};
|
|
14022
13999
|
yy.If.prototype.toString = function () {
|
|
14023
14000
|
var s = 'IF' + ' ';
|
|
@@ -14057,7 +14034,7 @@ yy.If.prototype.execute = function (databaseid, params, cb) {
|
|
|
14057
14034
|
*/
|
|
14058
14035
|
|
|
14059
14036
|
yy.While = function (params) {
|
|
14060
|
-
return
|
|
14037
|
+
return Object.assign(this, params);
|
|
14061
14038
|
};
|
|
14062
14039
|
yy.While.prototype.toString = function () {
|
|
14063
14040
|
var s = 'WHILE ';
|
|
@@ -14099,7 +14076,7 @@ yy.While.prototype.execute = function (databaseid, params, cb) {
|
|
|
14099
14076
|
};
|
|
14100
14077
|
|
|
14101
14078
|
yy.Break = function (params) {
|
|
14102
|
-
return
|
|
14079
|
+
return Object.assign(this, params);
|
|
14103
14080
|
};
|
|
14104
14081
|
yy.Break.prototype.toString = function () {
|
|
14105
14082
|
var s = 'BREAK';
|
|
@@ -14113,7 +14090,7 @@ yy.Break.prototype.execute = function (databaseid, params, cb, scope) {
|
|
|
14113
14090
|
};
|
|
14114
14091
|
|
|
14115
14092
|
yy.Continue = function (params) {
|
|
14116
|
-
return
|
|
14093
|
+
return Object.assign(this, params);
|
|
14117
14094
|
};
|
|
14118
14095
|
yy.Continue.prototype.toString = function () {
|
|
14119
14096
|
var s = 'CONTINUE';
|
|
@@ -14127,7 +14104,7 @@ yy.Continue.prototype.execute = function (databaseid, params, cb, scope) {
|
|
|
14127
14104
|
};
|
|
14128
14105
|
|
|
14129
14106
|
yy.BeginEnd = function (params) {
|
|
14130
|
-
return
|
|
14107
|
+
return Object.assign(this, params);
|
|
14131
14108
|
};
|
|
14132
14109
|
yy.BeginEnd.prototype.toString = function () {
|
|
14133
14110
|
var s = 'BEGIN ' + this.statements.toString() + ' END';
|
|
@@ -14161,7 +14138,7 @@ yy.BeginEnd.prototype.execute = function (databaseid, params, cb, scope) {
|
|
|
14161
14138
|
|
|
14162
14139
|
/* global yy alasql*/
|
|
14163
14140
|
yy.Insert = function (params) {
|
|
14164
|
-
return
|
|
14141
|
+
return Object.assign(this, params);
|
|
14165
14142
|
};
|
|
14166
14143
|
yy.Insert.prototype.toString = function () {
|
|
14167
14144
|
var s = 'INSERT ';
|
|
@@ -14377,7 +14354,7 @@ yy.Insert.prototype.compile = function (databaseid) {
|
|
|
14377
14354
|
else return res.length;
|
|
14378
14355
|
};
|
|
14379
14356
|
}
|
|
14380
|
-
} else if (this
|
|
14357
|
+
} else if (this.default) {
|
|
14381
14358
|
var insertfns = "db.tables['" + tableid + "'].data.push({" + table.defaultfns + '});return 1;';
|
|
14382
14359
|
var insertfn = new Function('db,params,alasql', insertfns);
|
|
14383
14360
|
} else {
|
|
@@ -14429,7 +14406,7 @@ yy.Insert.prototype.execute = function (databaseid, params, cb) {
|
|
|
14429
14406
|
*/
|
|
14430
14407
|
|
|
14431
14408
|
yy.CreateTrigger = function (params) {
|
|
14432
|
-
return
|
|
14409
|
+
return Object.assign(this, params);
|
|
14433
14410
|
};
|
|
14434
14411
|
yy.CreateTrigger.prototype.toString = function () {
|
|
14435
14412
|
var s = 'CREATE TRIGGER ' + this.trigger + ' ';
|
|
@@ -14482,7 +14459,7 @@ yy.CreateTrigger.prototype.execute = function (databaseid, params, cb) {
|
|
|
14482
14459
|
};
|
|
14483
14460
|
|
|
14484
14461
|
yy.DropTrigger = function (params) {
|
|
14485
|
-
return
|
|
14462
|
+
return Object.assign(this, params);
|
|
14486
14463
|
};
|
|
14487
14464
|
yy.DropTrigger.prototype.toString = function () {
|
|
14488
14465
|
var s = 'DROP TRIGGER ' + this.trigger;
|
|
@@ -14541,7 +14518,7 @@ yy.DropTrigger.prototype.execute = function (databaseid, params, cb) {
|
|
|
14541
14518
|
*/
|
|
14542
14519
|
|
|
14543
14520
|
yy.Delete = function (params) {
|
|
14544
|
-
return
|
|
14521
|
+
return Object.assign(this, params);
|
|
14545
14522
|
};
|
|
14546
14523
|
yy.Delete.prototype.toString = function () {
|
|
14547
14524
|
var s = 'DELETE FROM ' + this.table.toString();
|
|
@@ -14611,8 +14588,8 @@ yy.Delete.prototype.compile = function (databaseid) {
|
|
|
14611
14588
|
for (var i = 0, ilen = table.data.length; i < ilen; i++) {
|
|
14612
14589
|
if (wherefn(table.data[i], params, alasql)) {
|
|
14613
14590
|
// Check for transaction - if it is not possible then return all back
|
|
14614
|
-
if (table
|
|
14615
|
-
table
|
|
14591
|
+
if (table.delete) {
|
|
14592
|
+
table.delete(i, params, alasql);
|
|
14616
14593
|
} else {
|
|
14617
14594
|
// Simply do not push
|
|
14618
14595
|
}
|
|
@@ -14700,7 +14677,7 @@ yy.Delete.prototype.execute = function (databaseid, params, cb) {
|
|
|
14700
14677
|
/* global yy alasql */
|
|
14701
14678
|
|
|
14702
14679
|
yy.Update = function (params) {
|
|
14703
|
-
return
|
|
14680
|
+
return Object.assign(this, params);
|
|
14704
14681
|
};
|
|
14705
14682
|
yy.Update.prototype.toString = function () {
|
|
14706
14683
|
var s = 'UPDATE ' + this.table.toString();
|
|
@@ -14710,7 +14687,7 @@ yy.Update.prototype.toString = function () {
|
|
|
14710
14687
|
};
|
|
14711
14688
|
|
|
14712
14689
|
yy.SetColumn = function (params) {
|
|
14713
|
-
return
|
|
14690
|
+
return Object.assign(this, params);
|
|
14714
14691
|
};
|
|
14715
14692
|
yy.SetColumn.prototype.toString = function () {
|
|
14716
14693
|
return this.column.toString() + '=' + this.expression.toString();
|
|
@@ -14812,7 +14789,7 @@ yy.Update.prototype.execute = function (databaseid, params, cb) {
|
|
|
14812
14789
|
/* global alasql, yy */
|
|
14813
14790
|
|
|
14814
14791
|
yy.Merge = function (params) {
|
|
14815
|
-
return
|
|
14792
|
+
return Object.assign(this, params);
|
|
14816
14793
|
};
|
|
14817
14794
|
yy.Merge.prototype.toString = function () {
|
|
14818
14795
|
var s = 'MERGE ';
|
|
@@ -14829,7 +14806,7 @@ yy.Merge.prototype.toString = function () {
|
|
|
14829
14806
|
if (m.bysource) s += 'BY SOURCE ';
|
|
14830
14807
|
if (m.expr) s += 'AND' + ' ' + m.expr.toString() + ' ';
|
|
14831
14808
|
s += 'THEN ';
|
|
14832
|
-
if (m.action
|
|
14809
|
+
if (m.action.delete) s += 'DELETE ';
|
|
14833
14810
|
if (m.action.insert) {
|
|
14834
14811
|
s += 'INSERT ';
|
|
14835
14812
|
if (m.action.columns) s += '(' + m.action.columns.toString() + ') ';
|
|
@@ -14870,7 +14847,7 @@ yy.Merge.prototype.execute = function (databaseid, params, cb) {
|
|
|
14870
14847
|
|
|
14871
14848
|
// CREATE DATABASE databaseid
|
|
14872
14849
|
yy.CreateDatabase = function (params) {
|
|
14873
|
-
return
|
|
14850
|
+
return Object.assign(this, params);
|
|
14874
14851
|
};
|
|
14875
14852
|
yy.CreateDatabase.prototype.toString = function () {
|
|
14876
14853
|
var s = 'CREATE';
|
|
@@ -14923,7 +14900,7 @@ yy.CreateDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
14923
14900
|
|
|
14924
14901
|
// CREATE DATABASE databaseid
|
|
14925
14902
|
yy.AttachDatabase = function (params) {
|
|
14926
|
-
return
|
|
14903
|
+
return Object.assign(this, params);
|
|
14927
14904
|
};
|
|
14928
14905
|
yy.AttachDatabase.prototype.toString = function (args) {
|
|
14929
14906
|
var s = 'ATTACH';
|
|
@@ -14961,7 +14938,7 @@ yy.AttachDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
14961
14938
|
|
|
14962
14939
|
// CREATE DATABASE databaseid
|
|
14963
14940
|
yy.DetachDatabase = function (params) {
|
|
14964
|
-
return
|
|
14941
|
+
return Object.assign(this, params);
|
|
14965
14942
|
};
|
|
14966
14943
|
yy.DetachDatabase.prototype.toString = function () {
|
|
14967
14944
|
var s = 'DETACH';
|
|
@@ -15022,7 +14999,7 @@ yy.DetachDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
15022
14999
|
// USE DATABSE databaseid
|
|
15023
15000
|
// USE databaseid
|
|
15024
15001
|
yy.UseDatabase = function (params) {
|
|
15025
|
-
return
|
|
15002
|
+
return Object.assign(this, params);
|
|
15026
15003
|
};
|
|
15027
15004
|
yy.UseDatabase.prototype.toString = function () {
|
|
15028
15005
|
return 'USE' + ' ' + 'DATABASE' + ' ' + this.databaseid;
|
|
@@ -15041,7 +15018,7 @@ yy.UseDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
15041
15018
|
|
|
15042
15019
|
// DROP DATABASE databaseid
|
|
15043
15020
|
yy.DropDatabase = function (params) {
|
|
15044
|
-
return
|
|
15021
|
+
return Object.assign(this, params);
|
|
15045
15022
|
};
|
|
15046
15023
|
yy.DropDatabase.prototype.toString = function () {
|
|
15047
15024
|
var s = 'DROP';
|
|
@@ -15091,7 +15068,7 @@ yy.DropDatabase.prototype.execute = function (databaseid, params, cb) {
|
|
|
15091
15068
|
*/
|
|
15092
15069
|
|
|
15093
15070
|
yy.Declare = function (params) {
|
|
15094
|
-
return
|
|
15071
|
+
return Object.assign(this, params);
|
|
15095
15072
|
};
|
|
15096
15073
|
yy.Declare.prototype.toString = function () {
|
|
15097
15074
|
var s = 'DECLARE ';
|
|
@@ -15163,7 +15140,7 @@ yy.Declare.prototype.execute = function (databaseid, params, cb) {
|
|
|
15163
15140
|
*/
|
|
15164
15141
|
|
|
15165
15142
|
yy.ShowDatabases = function (params) {
|
|
15166
|
-
return
|
|
15143
|
+
return Object.assign(this, params);
|
|
15167
15144
|
};
|
|
15168
15145
|
yy.ShowDatabases.prototype.toString = function () {
|
|
15169
15146
|
var s = 'SHOW DATABASES';
|
|
@@ -15191,7 +15168,7 @@ yy.ShowDatabases.prototype.execute = function (databaseid, params, cb) {
|
|
|
15191
15168
|
};
|
|
15192
15169
|
|
|
15193
15170
|
yy.ShowTables = function (params) {
|
|
15194
|
-
return
|
|
15171
|
+
return Object.assign(this, params);
|
|
15195
15172
|
};
|
|
15196
15173
|
yy.ShowTables.prototype.toString = function () {
|
|
15197
15174
|
var s = 'SHOW TABLES';
|
|
@@ -15218,7 +15195,7 @@ yy.ShowTables.prototype.execute = function (databaseid, params, cb) {
|
|
|
15218
15195
|
};
|
|
15219
15196
|
|
|
15220
15197
|
yy.ShowColumns = function (params) {
|
|
15221
|
-
return
|
|
15198
|
+
return Object.assign(this, params);
|
|
15222
15199
|
};
|
|
15223
15200
|
yy.ShowColumns.prototype.toString = function () {
|
|
15224
15201
|
var s = 'SHOW COLUMNS';
|
|
@@ -15244,7 +15221,7 @@ yy.ShowColumns.prototype.execute = function (databaseid, params, cb) {
|
|
|
15244
15221
|
};
|
|
15245
15222
|
|
|
15246
15223
|
yy.ShowIndex = function (params) {
|
|
15247
|
-
return
|
|
15224
|
+
return Object.assign(this, params);
|
|
15248
15225
|
};
|
|
15249
15226
|
yy.ShowIndex.prototype.toString = function () {
|
|
15250
15227
|
var s = 'SHOW INDEX';
|
|
@@ -15267,7 +15244,7 @@ yy.ShowIndex.prototype.execute = function (databaseid, params, cb) {
|
|
|
15267
15244
|
};
|
|
15268
15245
|
|
|
15269
15246
|
yy.ShowCreateTable = function (params) {
|
|
15270
|
-
return
|
|
15247
|
+
return Object.assign(this, params);
|
|
15271
15248
|
};
|
|
15272
15249
|
yy.ShowCreateTable.prototype.toString = function () {
|
|
15273
15250
|
var s = 'SHOW CREATE TABLE ' + this.table.tableid;
|
|
@@ -15306,7 +15283,7 @@ yy.ShowCreateTable.prototype.execute = function (databaseid) {
|
|
|
15306
15283
|
*/
|
|
15307
15284
|
|
|
15308
15285
|
yy.SetVariable = function (params) {
|
|
15309
|
-
return
|
|
15286
|
+
return Object.assign(this, params);
|
|
15310
15287
|
};
|
|
15311
15288
|
yy.SetVariable.prototype.toString = function () {
|
|
15312
15289
|
var s = 'SET ';
|
|
@@ -15697,7 +15674,7 @@ alasql.prompt = function (el, useidel, firstsql) {
|
|
|
15697
15674
|
//
|
|
15698
15675
|
*/
|
|
15699
15676
|
yy.BeginTransaction = function (params) {
|
|
15700
|
-
return
|
|
15677
|
+
return Object.assign(this, params);
|
|
15701
15678
|
};
|
|
15702
15679
|
yy.BeginTransaction.prototype.toString = function () {
|
|
15703
15680
|
return 'BEGIN TRANSACTION';
|
|
@@ -15715,7 +15692,7 @@ yy.BeginTransaction.prototype.execute = function (databaseid, params, cb) {
|
|
|
15715
15692
|
};
|
|
15716
15693
|
|
|
15717
15694
|
yy.CommitTransaction = function (params) {
|
|
15718
|
-
return
|
|
15695
|
+
return Object.assign(this, params);
|
|
15719
15696
|
};
|
|
15720
15697
|
yy.CommitTransaction.prototype.toString = function () {
|
|
15721
15698
|
return 'COMMIT TRANSACTION';
|
|
@@ -15733,7 +15710,7 @@ yy.CommitTransaction.prototype.execute = function (databaseid, params, cb) {
|
|
|
15733
15710
|
};
|
|
15734
15711
|
|
|
15735
15712
|
yy.RollbackTransaction = function (params) {
|
|
15736
|
-
return
|
|
15713
|
+
return Object.assign(this, params);
|
|
15737
15714
|
};
|
|
15738
15715
|
yy.RollbackTransaction.prototype.toString = function () {
|
|
15739
15716
|
return 'ROLLBACK TRANSACTION';
|
|
@@ -17166,7 +17143,7 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
|
|
|
17166
17143
|
return EOF;
|
|
17167
17144
|
}
|
|
17168
17145
|
if (eol) {
|
|
17169
|
-
return (eol = false, EOL
|
|
17146
|
+
return (eol = false), EOL;
|
|
17170
17147
|
}
|
|
17171
17148
|
var j = I;
|
|
17172
17149
|
if (text.charCodeAt(j) === quoteCode) {
|
|
@@ -17602,7 +17579,7 @@ alasql.from.GEXF = function (filename, opts, cb, idx, query) {
|
|
|
17602
17579
|
/* globals: alasql, yy */
|
|
17603
17580
|
|
|
17604
17581
|
/**
|
|
17605
|
-
Print statement
|
|
17582
|
+
Print statement
|
|
17606
17583
|
@class
|
|
17607
17584
|
@param {object} params Initial setup properties
|
|
17608
17585
|
*/
|
|
@@ -17610,11 +17587,11 @@ alasql.from.GEXF = function (filename, opts, cb, idx, query) {
|
|
|
17610
17587
|
/* global alasql, yy */
|
|
17611
17588
|
|
|
17612
17589
|
yy.Print = function (params) {
|
|
17613
|
-
return
|
|
17590
|
+
return Object.assign(this, params);
|
|
17614
17591
|
};
|
|
17615
17592
|
|
|
17616
|
-
/**
|
|
17617
|
-
Generate SQL string
|
|
17593
|
+
/**
|
|
17594
|
+
Generate SQL string
|
|
17618
17595
|
@this Print statement object
|
|
17619
17596
|
*/
|
|
17620
17597
|
yy.Print.prototype.toString = function () {
|
|
@@ -17627,7 +17604,7 @@ yy.Print.prototype.toString = function () {
|
|
|
17627
17604
|
Print result of select statement or expression
|
|
17628
17605
|
@param {string} databaseid Database identificator
|
|
17629
17606
|
@param {object} params Query parameters
|
|
17630
|
-
@param {statement-callback} cb Callback function
|
|
17607
|
+
@param {statement-callback} cb Callback function
|
|
17631
17608
|
@this Print statement object
|
|
17632
17609
|
*/
|
|
17633
17610
|
yy.Print.prototype.execute = function (databaseid, params, cb) {
|
|
@@ -17668,7 +17645,7 @@ yy.Print.prototype.execute = function (databaseid, params, cb) {
|
|
|
17668
17645
|
*/
|
|
17669
17646
|
|
|
17670
17647
|
yy.Source = function (params) {
|
|
17671
|
-
return
|
|
17648
|
+
return Object.assign(this, params);
|
|
17672
17649
|
};
|
|
17673
17650
|
yy.Source.prototype.toString = function () {
|
|
17674
17651
|
var s = 'SOURCE';
|
|
@@ -17708,7 +17685,7 @@ yy.Source.prototype.execute = function (databaseid, params, cb) {
|
|
|
17708
17685
|
/* global alasql, yy */
|
|
17709
17686
|
|
|
17710
17687
|
yy.Require = function (params) {
|
|
17711
|
-
return
|
|
17688
|
+
return Object.assign(this, params);
|
|
17712
17689
|
};
|
|
17713
17690
|
yy.Require.prototype.toString = function () {
|
|
17714
17691
|
var s = 'REQUIRE';
|
|
@@ -17780,7 +17757,7 @@ yy.Require.prototype.execute = function (databaseid, params, cb) {
|
|
|
17780
17757
|
*/
|
|
17781
17758
|
|
|
17782
17759
|
yy.Assert = function (params) {
|
|
17783
|
-
return
|
|
17760
|
+
return Object.assign(this, params);
|
|
17784
17761
|
};
|
|
17785
17762
|
yy.Source.prototype.toString = function () {
|
|
17786
17763
|
var s = 'ASSERT';
|
|
@@ -17857,29 +17834,46 @@ var IDB = (alasql.engines.INDEXEDDB = function () {
|
|
|
17857
17834
|
'';
|
|
17858
17835
|
});
|
|
17859
17836
|
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
17869
|
-
var result = {
|
|
17870
|
-
contains: function (name) {
|
|
17871
|
-
return true; // Always return true
|
|
17872
|
-
},
|
|
17873
|
-
notsupported: true,
|
|
17874
|
-
};
|
|
17875
|
-
setTimeout(function () {
|
|
17876
|
-
var event = {target: {result: result}};
|
|
17877
|
-
request.onsuccess(event);
|
|
17878
|
-
}, 0);
|
|
17879
|
-
return request;
|
|
17880
|
-
};
|
|
17881
|
-
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');
|
|
17882
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
|
+
});
|
|
17883
17877
|
}
|
|
17884
17878
|
|
|
17885
17879
|
//
|
|
@@ -17887,333 +17881,235 @@ if (utils.hasIndexedDB) {
|
|
|
17887
17881
|
// work only in chrome
|
|
17888
17882
|
//
|
|
17889
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');
|
|
17890
17892
|
|
|
17891
|
-
var request = IDB.getDatabaseNames();
|
|
17892
|
-
request.onsuccess = function (event) {
|
|
17893
|
-
var dblist = event.target.result;
|
|
17894
|
-
if (IDB.getDatabaseNamesNotSupported) {
|
|
17895
|
-
throw new Error('SHOW DATABASE is not supported in this browser');
|
|
17896
|
-
}
|
|
17897
|
-
var res = [];
|
|
17898
|
-
if (like) {
|
|
17899
|
-
var relike = new RegExp(like.value.replace(/\%/g, '.*'), 'g');
|
|
17900
|
-
}
|
|
17901
17893
|
for (var i = 0; i < dblist.length; i++) {
|
|
17902
|
-
if (!like || dblist[i].match(relike)) {
|
|
17903
|
-
res.push({databaseid: dblist[i]});
|
|
17894
|
+
if (!like || dblist[i].name.match(relike)) {
|
|
17895
|
+
res.push({databaseid: dblist[i].name});
|
|
17904
17896
|
}
|
|
17905
17897
|
}
|
|
17898
|
+
|
|
17906
17899
|
cb(res);
|
|
17907
|
-
};
|
|
17900
|
+
});
|
|
17908
17901
|
};
|
|
17909
17902
|
|
|
17910
|
-
IDB.createDatabase = function (ixdbid, args, ifnotexists, dbid, cb) {
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
request2.onsuccess = function (event) {
|
|
17916
|
-
event.target.result.close();
|
|
17917
|
-
if (cb) cb(1);
|
|
17918
|
-
};
|
|
17919
|
-
} else {
|
|
17920
|
-
var request1 = indexedDB.open(ixdbid, 1);
|
|
17921
|
-
request1.onupgradeneeded = function (e) {
|
|
17922
|
-
|
|
17923
|
-
e.target.transaction.abort();
|
|
17924
|
-
};
|
|
17925
|
-
request1.onsuccess = function (e) {
|
|
17926
|
-
|
|
17927
|
-
if (ifnotexists) {
|
|
17928
|
-
if (cb) cb(0);
|
|
17929
|
-
} else {
|
|
17930
|
-
throw new Error(
|
|
17931
|
-
'IndexedDB: Cannot create new database "' + ixdbid + '" because it already exists'
|
|
17932
|
-
);
|
|
17933
|
-
}
|
|
17934
|
-
};
|
|
17935
|
-
}
|
|
17936
|
-
|
|
17937
|
-
};
|
|
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
|
+
});
|
|
17938
17908
|
|
|
17939
|
-
|
|
17940
|
-
var indexedDB = utils.global.indexedDB;
|
|
17941
|
-
if (IDB.getDatabaseNamesNotSupported) {
|
|
17942
|
-
// Hack for Firefox
|
|
17909
|
+
if (found) {
|
|
17943
17910
|
if (ifnotexists) {
|
|
17944
|
-
|
|
17945
|
-
var dbExists = true;
|
|
17946
|
-
var request2 = indexedDB.open(ixdbid);
|
|
17947
|
-
|
|
17948
|
-
request2.onupgradeneeded = function (e) {
|
|
17949
|
-
|
|
17950
|
-
dbExists = false;
|
|
17951
|
-
// e.target.transaction.abort();
|
|
17952
|
-
// cb(0);
|
|
17953
|
-
};
|
|
17954
|
-
request2.onsuccess = function (event) {
|
|
17955
|
-
|
|
17956
|
-
event.target.result.close();
|
|
17957
|
-
if (dbExists) {
|
|
17958
|
-
if (cb) cb(0);
|
|
17959
|
-
} else {
|
|
17960
|
-
if (cb) cb(1);
|
|
17961
|
-
}
|
|
17962
|
-
};
|
|
17911
|
+
cb && cb(0);
|
|
17963
17912
|
} else {
|
|
17964
|
-
|
|
17965
|
-
|
|
17966
|
-
|
|
17967
|
-
|
|
17968
|
-
};
|
|
17969
|
-
request1.onabort = function (event) {
|
|
17970
|
-
if (cb) cb(1);
|
|
17971
|
-
};
|
|
17972
|
-
request1.onsuccess = function (event) {
|
|
17973
|
-
event.target.result.close();
|
|
17974
|
-
throw new Error(
|
|
17975
|
-
'IndexedDB: Cannot create new database "' + ixdbid + '" because it already exists'
|
|
17976
|
-
);
|
|
17977
|
-
// cb(0);
|
|
17978
|
-
};
|
|
17913
|
+
const err = new Error(
|
|
17914
|
+
`IndexedDB: Cannot create new database "${ixdbid}" because it already exists`
|
|
17915
|
+
);
|
|
17916
|
+
if (cb) cb(null, err);
|
|
17979
17917
|
}
|
|
17980
17918
|
} else {
|
|
17981
|
-
|
|
17982
|
-
|
|
17983
|
-
|
|
17984
|
-
|
|
17985
|
-
if (ifnotexists) {
|
|
17986
|
-
if (cb) cb(0);
|
|
17987
|
-
return;
|
|
17988
|
-
} else {
|
|
17989
|
-
throw new Error(
|
|
17990
|
-
'IndexedDB: Cannot create new database "' + ixdbid + '" because it already exists'
|
|
17991
|
-
);
|
|
17992
|
-
}
|
|
17993
|
-
}
|
|
17994
|
-
|
|
17995
|
-
var request2 = indexedDB.open(ixdbid, 1);
|
|
17996
|
-
request2.onsuccess = function (event) {
|
|
17997
|
-
event.target.result.close();
|
|
17998
|
-
if (cb) cb(1);
|
|
17999
|
-
};
|
|
17919
|
+
const request = indexedDB.open(ixdbid, 1);
|
|
17920
|
+
request.onsuccess = () => {
|
|
17921
|
+
request.result.close();
|
|
17922
|
+
cb(1);
|
|
18000
17923
|
};
|
|
18001
17924
|
}
|
|
18002
17925
|
};
|
|
18003
17926
|
|
|
18004
|
-
IDB.dropDatabase = function (ixdbid, ifexists, cb) {
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
|
|
18008
|
-
|
|
18009
|
-
if (!dblist.contains(ixdbid)) {
|
|
18010
|
-
if (ifexists) {
|
|
18011
|
-
if (cb) cb(0);
|
|
18012
|
-
return;
|
|
18013
|
-
} else {
|
|
18014
|
-
throw new Error(
|
|
18015
|
-
'IndexedDB: Cannot drop new database "' + ixdbid + '" because it does not exist'
|
|
18016
|
-
);
|
|
18017
|
-
}
|
|
18018
|
-
}
|
|
18019
|
-
var request2 = indexedDB.deleteDatabase(ixdbid);
|
|
18020
|
-
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
|
+
});
|
|
18021
17932
|
|
|
17933
|
+
if (found) {
|
|
17934
|
+
const request = indexedDB.deleteDatabase(ixdbid);
|
|
17935
|
+
request.onsuccess = () => {
|
|
18022
17936
|
if (cb) cb(1);
|
|
18023
17937
|
};
|
|
18024
|
-
}
|
|
18025
|
-
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
|
|
18032
|
-
|
|
18033
|
-
request1.onsuccess = function (event) {
|
|
18034
|
-
var dblist = event.target.result;
|
|
18035
|
-
if (!dblist.contains(ixdbid)) {
|
|
18036
|
-
throw new Error(
|
|
18037
|
-
'IndexedDB: Cannot attach database "' + ixdbid + '" because it does not exist'
|
|
18038
|
-
);
|
|
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
|
+
);
|
|
18039
17947
|
}
|
|
18040
|
-
|
|
18041
|
-
request2.onsuccess = function (event) {
|
|
18042
|
-
var ixdb = event.target.result;
|
|
18043
|
-
var db = new alasql.Database(dbid || ixdbid);
|
|
18044
|
-
db.engineid = 'INDEXEDDB';
|
|
18045
|
-
db.ixdbid = ixdbid;
|
|
18046
|
-
db.tables = [];
|
|
18047
|
-
var tblist = ixdb.objectStoreNames;
|
|
18048
|
-
for (var i = 0; i < tblist.length; i++) {
|
|
18049
|
-
db.tables[tblist[i]] = {};
|
|
18050
|
-
}
|
|
18051
|
-
|
|
18052
|
-
event.target.result.close();
|
|
18053
|
-
if (cb) cb(1);
|
|
18054
|
-
};
|
|
18055
|
-
};
|
|
17948
|
+
}
|
|
18056
17949
|
};
|
|
18057
17950
|
|
|
18058
|
-
IDB.
|
|
18059
|
-
|
|
18060
|
-
|
|
18061
|
-
|
|
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
|
+
});
|
|
18062
17956
|
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
}
|
|
18071
|
-
var request2 = indexedDB.open(ixdbid);
|
|
18072
|
-
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
|
+
}
|
|
18073
17964
|
|
|
18074
|
-
|
|
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();
|
|
18075
17970
|
};
|
|
18076
|
-
|
|
18077
|
-
var version = event_.target.result.version;
|
|
18078
|
-
event_.target.result.close();
|
|
17971
|
+
});
|
|
18079
17972
|
|
|
18080
|
-
|
|
18081
|
-
|
|
18082
|
-
|
|
17973
|
+
const db = new alasql.Database(dbid || ixdbid);
|
|
17974
|
+
db.engineid = 'INDEXEDDB';
|
|
17975
|
+
db.ixdbid = ixdbid;
|
|
17976
|
+
db.tables = [];
|
|
18083
17977
|
|
|
18084
|
-
|
|
17978
|
+
for (var i = 0; i < stores.length; i++) {
|
|
17979
|
+
db.tables[stores[i]] = {};
|
|
17980
|
+
}
|
|
18085
17981
|
|
|
18086
|
-
|
|
18087
|
-
|
|
17982
|
+
if (cb) cb(1);
|
|
17983
|
+
};
|
|
18088
17984
|
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
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
|
+
});
|
|
18094
17991
|
|
|
18095
|
-
|
|
18096
|
-
|
|
18097
|
-
|
|
18098
|
-
|
|
18099
|
-
|
|
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
|
+
}
|
|
18100
17999
|
|
|
18101
|
-
|
|
18102
|
-
|
|
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
|
+
);
|
|
18103
18016
|
};
|
|
18104
18017
|
};
|
|
18105
18018
|
|
|
18106
|
-
IDB.dropTable = function (databaseid, tableid, ifexists, cb) {
|
|
18107
|
-
|
|
18108
|
-
|
|
18109
|
-
|
|
18110
|
-
|
|
18111
|
-
|
|
18112
|
-
var dblist = event.target.result;
|
|
18113
|
-
|
|
18114
|
-
if (!dblist.contains(ixdbid)) {
|
|
18115
|
-
throw new Error(
|
|
18116
|
-
'IndexedDB: Cannot drop table in database "' + ixdbid + '" because it does not exist'
|
|
18117
|
-
);
|
|
18118
|
-
}
|
|
18119
|
-
|
|
18120
|
-
var request2 = indexedDB.open(ixdbid);
|
|
18121
|
-
request2.onversionchange = function (event) {
|
|
18122
|
-
event.target.result.close();
|
|
18123
|
-
};
|
|
18124
|
-
|
|
18125
|
-
request2.onsuccess = function (event) {
|
|
18126
|
-
var version = event.target.result.version;
|
|
18127
|
-
event.target.result.close();
|
|
18128
|
-
|
|
18129
|
-
var request3 = indexedDB.open(ixdbid, version + 1);
|
|
18130
|
-
request3.onupgradeneeded = function (event) {
|
|
18131
|
-
var ixdb = event.target.result;
|
|
18132
|
-
if (ixdb.objectStoreNames.contains(tableid)) {
|
|
18133
|
-
ixdb.deleteObjectStore(tableid);
|
|
18134
|
-
delete alasql.databases[databaseid].tables[tableid];
|
|
18135
|
-
} else {
|
|
18136
|
-
if (!ifexists) {
|
|
18137
|
-
throw new Error(
|
|
18138
|
-
'IndexedDB: Cannot drop table "' + tableid + '" because it does not exist'
|
|
18139
|
-
);
|
|
18140
|
-
}
|
|
18141
|
-
}
|
|
18142
|
-
// var store = ixdb.createObjectStore(tableid);
|
|
18143
|
-
|
|
18144
|
-
};
|
|
18145
|
-
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
|
+
});
|
|
18146
18025
|
|
|
18147
|
-
|
|
18148
|
-
|
|
18149
|
-
|
|
18150
|
-
|
|
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
|
+
}
|
|
18151
18033
|
|
|
18152
|
-
|
|
18153
|
-
};
|
|
18154
|
-
request3.onblocked = function (event) {
|
|
18155
|
-
throw new Error(
|
|
18156
|
-
'Cannot drop table "' + tableid + '" because database "' + databaseid + '" is blocked'
|
|
18157
|
-
);
|
|
18034
|
+
const request = indexedDB.open(ixdbid, found.version + 1);
|
|
18158
18035
|
|
|
18159
|
-
|
|
18160
|
-
|
|
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
|
+
);
|
|
18161
18061
|
};
|
|
18162
18062
|
};
|
|
18163
18063
|
|
|
18164
18064
|
IDB.intoTable = function (databaseid, tableid, value, columns, cb) {
|
|
18065
|
+
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18066
|
+
const request = indexedDB.open(ixdbid);
|
|
18165
18067
|
|
|
18166
|
-
|
|
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
|
+
};
|
|
18167
18075
|
|
|
18168
|
-
|
|
18169
|
-
|
|
18170
|
-
var request1 = indexedDB.open(ixdbid);
|
|
18171
|
-
request1.onsuccess = function (event) {
|
|
18172
|
-
var ixdb = event.target.result;
|
|
18076
|
+
request.onsuccess = () => {
|
|
18077
|
+
var ixdb = request.result;
|
|
18173
18078
|
var tx = ixdb.transaction([tableid], 'readwrite');
|
|
18174
18079
|
var tb = tx.objectStore(tableid);
|
|
18175
|
-
|
|
18176
18080
|
for (var i = 0, ilen = value.length; i < ilen; i++) {
|
|
18177
18081
|
tb.add(value[i]);
|
|
18178
18082
|
}
|
|
18179
18083
|
tx.oncomplete = function () {
|
|
18180
18084
|
ixdb.close();
|
|
18181
|
-
|
|
18182
18085
|
if (cb) cb(ilen);
|
|
18183
18086
|
};
|
|
18184
18087
|
};
|
|
18185
|
-
|
|
18186
18088
|
};
|
|
18187
18089
|
|
|
18188
18090
|
IDB.fromTable = function (databaseid, tableid, cb, idx, query) {
|
|
18091
|
+
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18092
|
+
const request = indexedDB.open(ixdbid);
|
|
18189
18093
|
|
|
18190
|
-
|
|
18191
|
-
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
|
|
18198
|
-
var tx = ixdb.transaction([tableid]);
|
|
18199
|
-
var store = tx.objectStore(tableid);
|
|
18200
|
-
var cur = store.openCursor();
|
|
18201
|
-
|
|
18202
|
-
cur.onblocked = function (event) {
|
|
18203
|
-
|
|
18204
|
-
};
|
|
18205
|
-
cur.onerror = function (event) {
|
|
18206
|
-
|
|
18207
|
-
};
|
|
18208
|
-
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
|
+
};
|
|
18209
18101
|
|
|
18210
|
-
|
|
18102
|
+
request.onsuccess = () => {
|
|
18103
|
+
const res = [];
|
|
18104
|
+
const ixdb = request.result;
|
|
18105
|
+
const cur = ixdb.transaction([tableid]).objectStore(tableid).openCursor();
|
|
18211
18106
|
|
|
18107
|
+
cur.onsuccess = () => {
|
|
18108
|
+
const cursor = cur.result;
|
|
18212
18109
|
if (cursor) {
|
|
18213
18110
|
res.push(cursor.value);
|
|
18214
|
-
cursor
|
|
18111
|
+
cursor.continue();
|
|
18215
18112
|
} else {
|
|
18216
|
-
|
|
18217
18113
|
ixdb.close();
|
|
18218
18114
|
if (cb) cb(res, idx, query);
|
|
18219
18115
|
}
|
|
@@ -18222,39 +18118,23 @@ IDB.fromTable = function (databaseid, tableid, cb, idx, query) {
|
|
|
18222
18118
|
};
|
|
18223
18119
|
|
|
18224
18120
|
IDB.deleteFromTable = function (databaseid, tableid, wherefn, params, cb) {
|
|
18121
|
+
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18122
|
+
const request = indexedDB.open(ixdbid);
|
|
18225
18123
|
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
var request = indexedDB.open(ixdbid);
|
|
18230
|
-
request.onsuccess = function (event) {
|
|
18231
|
-
var res = [];
|
|
18232
|
-
var ixdb = event.target.result;
|
|
18233
|
-
|
|
18234
|
-
var tx = ixdb.transaction([tableid], 'readwrite');
|
|
18235
|
-
var store = tx.objectStore(tableid);
|
|
18236
|
-
var cur = store.openCursor();
|
|
18237
|
-
var num = 0;
|
|
18238
|
-
|
|
18239
|
-
cur.onblocked = function (event) {
|
|
18240
|
-
|
|
18241
|
-
};
|
|
18242
|
-
cur.onerror = function (event) {
|
|
18243
|
-
|
|
18244
|
-
};
|
|
18245
|
-
cur.onsuccess = function (event) {
|
|
18246
|
-
|
|
18247
|
-
var cursor = event.target.result;
|
|
18124
|
+
request.onsuccess = () => {
|
|
18125
|
+
const ixdb = request.result;
|
|
18126
|
+
const cur = ixdb.transaction([tableid], 'readwrite').objectStore(tableid).openCursor();
|
|
18248
18127
|
|
|
18128
|
+
let num = 0;
|
|
18129
|
+
cur.onsuccess = () => {
|
|
18130
|
+
var cursor = cur.result;
|
|
18249
18131
|
if (cursor) {
|
|
18250
|
-
if (!wherefn || wherefn(cursor.value, params)) {
|
|
18251
|
-
|
|
18252
|
-
cursor["delete"]();
|
|
18132
|
+
if (!wherefn || wherefn(cursor.value, params, alasql)) {
|
|
18133
|
+
cursor.delete();
|
|
18253
18134
|
num++;
|
|
18254
18135
|
}
|
|
18255
|
-
cursor
|
|
18136
|
+
cursor.continue();
|
|
18256
18137
|
} else {
|
|
18257
|
-
|
|
18258
18138
|
ixdb.close();
|
|
18259
18139
|
if (cb) cb(num);
|
|
18260
18140
|
}
|
|
@@ -18263,42 +18143,24 @@ IDB.deleteFromTable = function (databaseid, tableid, wherefn, params, cb) {
|
|
|
18263
18143
|
};
|
|
18264
18144
|
|
|
18265
18145
|
IDB.updateTable = function (databaseid, tableid, assignfn, wherefn, params, cb) {
|
|
18266
|
-
|
|
18267
|
-
|
|
18268
|
-
|
|
18269
|
-
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
|
|
18274
|
-
|
|
18275
|
-
var tx = ixdb.transaction([tableid], 'readwrite');
|
|
18276
|
-
var store = tx.objectStore(tableid);
|
|
18277
|
-
var cur = store.openCursor();
|
|
18278
|
-
var num = 0;
|
|
18279
|
-
|
|
18280
|
-
cur.onblocked = function (event) {
|
|
18281
|
-
|
|
18282
|
-
};
|
|
18283
|
-
cur.onerror = function (event) {
|
|
18284
|
-
|
|
18285
|
-
};
|
|
18286
|
-
cur.onsuccess = function (event) {
|
|
18287
|
-
|
|
18288
|
-
var cursor = event.target.result;
|
|
18289
|
-
|
|
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;
|
|
18290
18155
|
if (cursor) {
|
|
18291
18156
|
if (!wherefn || wherefn(cursor.value, params)) {
|
|
18292
|
-
|
|
18293
18157
|
var r = cursor.value;
|
|
18294
18158
|
assignfn(r, params);
|
|
18295
|
-
|
|
18296
18159
|
cursor.update(r);
|
|
18297
18160
|
num++;
|
|
18298
18161
|
}
|
|
18299
|
-
cursor
|
|
18162
|
+
cursor.continue();
|
|
18300
18163
|
} else {
|
|
18301
|
-
|
|
18302
18164
|
ixdb.close();
|
|
18303
18165
|
if (cb) cb(num);
|
|
18304
18166
|
}
|
|
@@ -19400,35 +19262,35 @@ if (typeof module !== 'undefined' && module.exports) {
|
|
|
19400
19262
|
});
|
|
19401
19263
|
}
|
|
19402
19264
|
|
|
19403
|
-
/* eslint-disable */
|
|
19265
|
+
/* eslint-disable */
|
|
19404
19266
|
|
|
19405
|
-
/*
|
|
19406
|
-
//
|
|
19407
|
-
// Last part of Alasql.js
|
|
19408
|
-
// Date: 03.11.2014
|
|
19409
|
-
// (c) 2014, Andrey Gershun
|
|
19410
|
-
//
|
|
19411
|
-
*/
|
|
19267
|
+
/*
|
|
19268
|
+
//
|
|
19269
|
+
// Last part of Alasql.js
|
|
19270
|
+
// Date: 03.11.2014
|
|
19271
|
+
// (c) 2014, Andrey Gershun
|
|
19272
|
+
//
|
|
19273
|
+
*/
|
|
19412
19274
|
|
|
19413
|
-
// This is a final part of Alasql
|
|
19275
|
+
// This is a final part of Alasql
|
|
19414
19276
|
|
|
19415
|
-
//*only-for-browser/*
|
|
19416
|
-
if(utils.isCordova || utils.isMeteorServer || utils.isNode ){
|
|
19417
|
-
console.log('It looks like you are using the browser version of AlaSQL. Please use the alasql.fs.js file instead.')
|
|
19418
|
-
}
|
|
19419
|
-
//*/
|
|
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
|
+
//*/
|
|
19420
19282
|
|
|
19421
|
-
// FileSaveAs
|
|
19422
|
-
alasql.utils.saveAs = saveAs;
|
|
19283
|
+
// FileSaveAs
|
|
19284
|
+
alasql.utils.saveAs = saveAs;
|
|
19423
19285
|
|
|
19424
|
-
};
|
|
19286
|
+
};
|
|
19425
19287
|
|
|
19426
|
-
// Create default database
|
|
19427
|
-
new Database("alasql");
|
|
19288
|
+
// Create default database
|
|
19289
|
+
new Database("alasql");
|
|
19428
19290
|
|
|
19429
|
-
// Set default database
|
|
19430
|
-
alasql.use("alasql");
|
|
19291
|
+
// Set default database
|
|
19292
|
+
alasql.use("alasql");
|
|
19431
19293
|
|
|
19432
|
-
return alasql;
|
|
19433
|
-
}));
|
|
19294
|
+
return alasql;
|
|
19295
|
+
}));
|
|
19434
19296
|
|