alasql 1.7.4 → 1.7.5
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/.github/workflows/nodejs.yml +1 -1
- package/README.md +7 -9
- package/dist/alasql-worker.js +2 -2
- package/dist/alasql-worker.min.js +2 -2
- package/dist/alasql.fs.js +63 -47
- package/dist/alasql.js +63 -47
- package/dist/alasql.min.js +2 -2
- package/package/dist/alasql-echo.js +20 -0
- package/package/dist/alasql-prolog.js +51 -0
- package/package/dist/alasql-worker.js +245 -0
- package/package/dist/alasql-worker.min.js +2 -0
- package/package/dist/alasql.d.ts +88 -0
- package/package/dist/alasql.fs.js +19728 -0
- package/package/dist/alasql.js +19723 -0
- package/package/dist/alasql.min.js +2 -0
- package/package.json +16 -15
- package/yarn-error.log +3004 -1800
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<h2>
|
|
2
|
+
Please use version 1.x as prior versions has a security flaw if you use user generated data to concat your SQL strings instead of providing them as a parameters to AlaSQL.
|
|
3
|
+
</h2>
|
|
4
|
+
|
|
1
5
|
_AlaSQL is an open source project used on more than two million page views per month - and we appreciate any and all contributions we can get. [Please help out](https://github.com/agershun/alasql/labels/Please%20help%20out%21)._
|
|
2
6
|
|
|
3
7
|
_Have a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask?tags=AlaSQL) using the "alasql" tag._
|
|
@@ -471,7 +475,7 @@ var b = browserify("./main.js").bundle();
|
|
|
471
475
|
|
|
472
476
|
#### Vue
|
|
473
477
|
|
|
474
|
-
For some frameworks (lige Vue) alasql cant access XLSX by it self. We recommend
|
|
478
|
+
For some frameworks (lige Vue) alasql cant access XLSX by it self. We recommend handeling it by including AlaSQL the following way:
|
|
475
479
|
|
|
476
480
|
```import alasql from 'alasql';
|
|
477
481
|
import XLSX from 'xlsx';
|
|
@@ -601,15 +605,9 @@ The testruns can be found in the [testlog](TESTLOG.md).
|
|
|
601
605
|
|
|
602
606
|
|
|
603
607
|
|
|
604
|
-
##
|
|
605
|
-
|
|
606
|
-
See [Contributing](CONTRIBUTING.md) for details.
|
|
607
|
-
|
|
608
|
-
Thanks to all the people who already contributed!
|
|
608
|
+
## Bleeding Edge
|
|
609
609
|
|
|
610
|
-
|
|
611
|
-
<img src="https://contributors-img.web.app/image?repo=agershun/alasql" />
|
|
612
|
-
</a>
|
|
610
|
+
If you want to try the most recent development version of the library please download [this file](https://rawgit.com/agershun/alasql/develop/dist/alasql.fs.js) or visit the [testbench](https://rawgit.com/agershun/alasql/develop/utils/testbench.html) to play around in the browser console.
|
|
613
611
|
|
|
614
612
|
|
|
615
613
|
## License
|
package/dist/alasql-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v1.7.
|
|
1
|
+
//! AlaSQL v1.7.5-v1-hotfix-95227342undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 1.7.
|
|
4
|
+
@version 1.7.5-v1-hotfix-95227342undefined
|
|
5
5
|
|
|
6
6
|
AlaSQL - JavaScript SQL database
|
|
7
7
|
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
//! AlaSQL v1.7.
|
|
2
|
-
!function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function i(r,e,
|
|
1
|
+
//! AlaSQL v1.7.5-v1-hotfix-95227342undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
|
+
!function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function i(r,e,t){"function"==typeof(e=e||[])&&(scope=t,t=e,e=[]),"object"!=typeof e&&(e=[e]);var o=i.lastid++;i.buffer[o]=t,i.webworker.postMessage({id:o,sql:r,params:e})}var s;if(i.options={},i.options.progress=function(){},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)},i.promise=function(){throw new Error("Please include a Promise/A+ library")},"undefined"!=typeof Promise&&(s=function(r,e,n,s){return new Promise(function(t,o){i(r,e,function(r,e){e?o(e):(n&&s&&!1!==i.options.progress&&i.options.progress(n,s),t(r))})})},i.promise=function(r,e){if("undefined"==typeof Promise)throw new Error("Please include a Promise/A+ library");if("string"==typeof r)return s(r,e);if(!isArray(r)||r.length<1||void 0!==e)throw new Error("Error in .promise parameters");return function(r){if(!(r.length<1)){for(var e,t,o=[],n=0;n<r.length;n++){if("string"==typeof(t=r[n])&&(t=[t]),!isArray(t)||t.length<1||2<t.length)throw new Error("Error in .promise parameter");e=t[0],t=t[1]||void 0,o.push(s(e,t,n,r.length))}return Promise.all(o)}}(r)}),!(i=i||!1))throw new Error("alasql was not found");return i.worker=function(){throw new Error("Can find webworker in this enviroment")},"undefined"!=typeof Worker&&(i.worker=function(r,e,t){if(void 0===(r=!0===r?void 0:r))for(var o=document.getElementsByTagName("script"),n=0;n<o.length;n++){if("alasql-worker.js"===o[n].src.substr(-16).toLowerCase()){r=o[n].src.substr(0,o[n].src.length-16)+"alasql.js";break}if("alasql-worker.min.js"===o[n].src.substr(-20).toLowerCase()){r=o[n].src.substr(0,o[n].src.length-20)+"alasql.min.js";break}if("alasql.js"===o[n].src.substr(-9).toLowerCase()){r=o[n].src;break}if("alasql.min.js"===o[n].src.substr(-13).toLowerCase()){r=o[n].src.substr(0,o[n].src.length-13)+"alasql.min.js";break}}if(void 0===r)throw new Error("Path to alasql.js is not specified");var s;!1!==r?(s="importScripts('",s+=r,s+="');self.onmessage = function(event) {alasql(event.data.sql,event.data.params, function(data){postMessage({id:event.data.id, data:data});});}",s=new Blob([s],{type:"text/plain"}),i.webworker=new Worker(URL.createObjectURL(s)),i.webworker.onmessage=function(r){var e=r.data.id;i.buffer[e](r.data.data),delete i.buffer[e]},i.webworker.onerror=function(r){throw r},1<arguments.length&&i("REQUIRE "+e.map(function(r){return'"'+r+'"'}).join(","),[],t)):!1===r&&delete i.webworker}),i.lastid=0,i.buffer={},i.worker(),i});
|
package/dist/alasql.fs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v1.7.
|
|
1
|
+
//! AlaSQL v1.7.5-v1-hotfix-95227342undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 1.7.
|
|
4
|
+
@version 1.7.5-v1-hotfix-95227342undefined
|
|
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 = '1.7.
|
|
145
|
+
alasql.version = '1.7.5-v1-hotfix-95227342undefined';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -4328,6 +4328,12 @@ var getXLSX = function () {
|
|
|
4328
4328
|
return XLSX;
|
|
4329
4329
|
};
|
|
4330
4330
|
|
|
4331
|
+
var jss = JSON.stringify;
|
|
4332
|
+
var reName = /[^a-z\d@-_]+/gi;
|
|
4333
|
+
var nss = (e) => e.replace(reName, '');
|
|
4334
|
+
var reTick = /`/g;
|
|
4335
|
+
var tss = (e) => e.replace(reTick, '');
|
|
4336
|
+
|
|
4331
4337
|
// set AlaSQl path
|
|
4332
4338
|
alasql.path = alasql.utils.findAlaSQLPath();
|
|
4333
4339
|
|
|
@@ -6308,7 +6314,7 @@ yy.Search.prototype.toString = function () {
|
|
|
6308
6314
|
|
|
6309
6315
|
yy.Search.prototype.toJS = function (context) {
|
|
6310
6316
|
|
|
6311
|
-
var s = 'this.queriesfn[' + (this.queriesidx - 1) + '](this.params,null,' + context + ')';
|
|
6317
|
+
var s = 'this.queriesfn[' + jss(this.queriesidx - 1) + '](this.params,null,' + jss(context) + ')';
|
|
6312
6318
|
// var s = '';
|
|
6313
6319
|
return s;
|
|
6314
6320
|
};
|
|
@@ -6669,11 +6675,11 @@ alasql.srch.SET = function (val, args, stope, params) {
|
|
|
6669
6675
|
.map(function (st) {
|
|
6670
6676
|
|
|
6671
6677
|
if (st.method === '@') {
|
|
6672
|
-
return
|
|
6678
|
+
return 'alasql.vars[' + jss(st.variable) + ']=' + st.expression.toJS('x', '');
|
|
6673
6679
|
} else if (st.method === '$') {
|
|
6674
|
-
return
|
|
6680
|
+
return 'params[' + jss(st.variable) + ']=' + st.expression.toJS('x', '');
|
|
6675
6681
|
} else {
|
|
6676
|
-
return
|
|
6682
|
+
return 'x[' + jss(st.column.columnid) + ']=' + st.expression.toJS('x', '');
|
|
6677
6683
|
}
|
|
6678
6684
|
})
|
|
6679
6685
|
.join(';');
|
|
@@ -6760,17 +6766,26 @@ var compileSearchOrder = function (order) {
|
|
|
6760
6766
|
s += 'if(a' + dg + '==b' + dg + '){';
|
|
6761
6767
|
} else {
|
|
6762
6768
|
s +=
|
|
6763
|
-
|
|
6764
|
-
columnid +
|
|
6765
|
-
"
|
|
6769
|
+
'if((a[' +
|
|
6770
|
+
jss(columnid) +
|
|
6771
|
+
"]||'')" +
|
|
6766
6772
|
dg +
|
|
6767
6773
|
(ord.direction === 'ASC' ? '>' : '<') +
|
|
6768
|
-
|
|
6769
|
-
columnid +
|
|
6770
|
-
"
|
|
6774
|
+
'(b[' +
|
|
6775
|
+
jss(columnid) +
|
|
6776
|
+
"]||'')" +
|
|
6771
6777
|
dg +
|
|
6772
6778
|
')return 1;';
|
|
6773
|
-
s +=
|
|
6779
|
+
s +=
|
|
6780
|
+
'if((a[' +
|
|
6781
|
+
jss(columnid) +
|
|
6782
|
+
"]||'')" +
|
|
6783
|
+
dg +
|
|
6784
|
+
'==(b[' +
|
|
6785
|
+
jss(columnid) +
|
|
6786
|
+
"]||'')" +
|
|
6787
|
+
dg +
|
|
6788
|
+
'){';
|
|
6774
6789
|
}
|
|
6775
6790
|
} else {
|
|
6776
6791
|
dg = '.valueOf()';
|
|
@@ -9334,9 +9349,10 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9334
9349
|
|
|
9335
9350
|
if (columns && columns.length > 0) {
|
|
9336
9351
|
columns.forEach(function (tcol) {
|
|
9352
|
+
var escapedColumnId = escapeq(tcol.columnid);
|
|
9337
9353
|
if (joinstar && alasql.options.joinstar == 'underscore') {
|
|
9338
9354
|
ss.push(
|
|
9339
|
-
"'" + alias + '_' +
|
|
9355
|
+
"'" + alias + '_' + escapedColumnId + "':p['" + alias + "']['" + escapedColumnId + "']"
|
|
9340
9356
|
);
|
|
9341
9357
|
} else if (joinstar && alasql.options.joinstar == 'json') {
|
|
9342
9358
|
// ss.push('\''+alias+'_'+tcol.columnid+'\':p[\''+alias+'\'][\''+tcol.columnid+'\']');
|
|
@@ -9344,16 +9360,16 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9344
9360
|
"r['" +
|
|
9345
9361
|
alias +
|
|
9346
9362
|
"']['" +
|
|
9347
|
-
|
|
9363
|
+
escapedColumnId +
|
|
9348
9364
|
"']=p['" +
|
|
9349
9365
|
alias +
|
|
9350
9366
|
"']['" +
|
|
9351
|
-
|
|
9367
|
+
escapedColumnId +
|
|
9352
9368
|
"'];";
|
|
9353
9369
|
} else {
|
|
9354
|
-
var value = "p['" + alias + "']['" +
|
|
9370
|
+
var value = "p['" + alias + "']['" + escapedColumnId + "']";
|
|
9355
9371
|
if (!columnIds[tcol.columnid]) {
|
|
9356
|
-
var key = "'" +
|
|
9372
|
+
var key = "'" + escapedColumnId + "':";
|
|
9357
9373
|
ss.push(key + value);
|
|
9358
9374
|
columnIds[tcol.columnid] = {
|
|
9359
9375
|
id: ss.length - 1,
|
|
@@ -9392,7 +9408,7 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9392
9408
|
|
|
9393
9409
|
});
|
|
9394
9410
|
|
|
9395
|
-
return {s: ss.join(','), sp: sp};
|
|
9411
|
+
return { s: ss.join(','), sp: sp };
|
|
9396
9412
|
}
|
|
9397
9413
|
|
|
9398
9414
|
yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
@@ -9443,14 +9459,14 @@ yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
|
9443
9459
|
if (false && tbid && !query.defcols['.'][col.tableid] && !query.defcols[col.columnid]) {
|
|
9444
9460
|
ss.push(
|
|
9445
9461
|
"'" +
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9462
|
+
escapeq(col.as || col.columnid) +
|
|
9463
|
+
"':p['" +
|
|
9464
|
+
query.defaultTableid +
|
|
9465
|
+
"']['" +
|
|
9466
|
+
col.tableid +
|
|
9467
|
+
"']['" +
|
|
9468
|
+
col.columnid +
|
|
9469
|
+
"']"
|
|
9454
9470
|
);
|
|
9455
9471
|
} else {
|
|
9456
9472
|
// workaround for multisheet xlsx export with custom COLUMNS
|
|
@@ -9485,12 +9501,12 @@ yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
|
9485
9501
|
} else {
|
|
9486
9502
|
ss.push(
|
|
9487
9503
|
"'" +
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9504
|
+
escapeq(col.as || col.columnid) +
|
|
9505
|
+
"':p['" +
|
|
9506
|
+
tbid +
|
|
9507
|
+
"']['" +
|
|
9508
|
+
col.columnid +
|
|
9509
|
+
"']"
|
|
9494
9510
|
);
|
|
9495
9511
|
}
|
|
9496
9512
|
}
|
|
@@ -9575,9 +9591,9 @@ yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
|
9575
9591
|
) {
|
|
9576
9592
|
ss.push(
|
|
9577
9593
|
"'" +
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9594
|
+
escapeq(col.as) +
|
|
9595
|
+
"':" +
|
|
9596
|
+
n2u(col.expression.toJS('p', query.defaultTableid, query.defcols))
|
|
9581
9597
|
);
|
|
9582
9598
|
} else if (col.aggregatorid === 'COUNT') {
|
|
9583
9599
|
ss.push("'" + escapeq(col.as) + "':1");
|
|
@@ -9607,9 +9623,9 @@ yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
|
9607
9623
|
|
|
9608
9624
|
ss.push(
|
|
9609
9625
|
"'" +
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9626
|
+
escapeq(col.as || col.columnid || col.toString()) +
|
|
9627
|
+
"':" +
|
|
9628
|
+
n2u(col.toJS('p', query.defaultTableid, query.defcols))
|
|
9613
9629
|
);
|
|
9614
9630
|
// ss.push('\''+escapeq(col.toString())+'\':'+col.toJS("p",query.defaultTableid));
|
|
9615
9631
|
//if(col instanceof yy.Expression) {
|
|
@@ -10462,8 +10478,8 @@ yy.Over.prototype.toString = function () {
|
|
|
10462
10478
|
*/
|
|
10463
10479
|
|
|
10464
10480
|
/**
|
|
10465
|
-
|
|
10466
|
-
|
|
10481
|
+
Expression statement ( = 2*2; )
|
|
10482
|
+
@class
|
|
10467
10483
|
@param {object} params Initial parameters
|
|
10468
10484
|
*/
|
|
10469
10485
|
yy.ExpressionStatement = function (params) {
|
|
@@ -10838,7 +10854,7 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10838
10854
|
var ljs = '(' + leftJS() + '||{})';
|
|
10839
10855
|
|
|
10840
10856
|
if (typeof this.right === 'string') {
|
|
10841
|
-
s = ljs + '["' + this.right + '"]';
|
|
10857
|
+
s = ljs + '["' + escapeq(this.right) + '"]';
|
|
10842
10858
|
} else if (typeof this.right === 'number') {
|
|
10843
10859
|
s = ljs + '[' + this.right + ']';
|
|
10844
10860
|
} else if (this.right instanceof yy.FuncValue) {
|
|
@@ -11069,7 +11085,7 @@ yy.VarValue.prototype.toType = function () {
|
|
|
11069
11085
|
};
|
|
11070
11086
|
|
|
11071
11087
|
yy.VarValue.prototype.toJS = function () {
|
|
11072
|
-
return "alasql.vars['" + this.variable + "']";
|
|
11088
|
+
return "alasql.vars['" + escapeq(this.variable) + "']";
|
|
11073
11089
|
};
|
|
11074
11090
|
|
|
11075
11091
|
yy.NumValue = function (params) {
|
|
@@ -11463,7 +11479,7 @@ yy.AggrValue.prototype.toJS = function (/*context, tableid, defcols*/) {
|
|
|
11463
11479
|
|
|
11464
11480
|
var colas = this.nick;
|
|
11465
11481
|
if (colas === undefined) {
|
|
11466
|
-
colas = this.toString();
|
|
11482
|
+
colas = escapeq(this.toString());
|
|
11467
11483
|
}
|
|
11468
11484
|
return "g['" + colas + "']";
|
|
11469
11485
|
};
|
|
@@ -17175,8 +17191,7 @@ alasql.into.XLSX = function (filename, opts, data, columns, cb) {
|
|
|
17175
17191
|
var colm = 1,
|
|
17176
17192
|
rowm = 1;
|
|
17177
17193
|
}
|
|
17178
|
-
var
|
|
17179
|
-
var colmax = Math.max(col0 + columns.length - 1 + zeroColumnFix, colm);
|
|
17194
|
+
var colmax = Math.max(col0 + columns.length, colm);
|
|
17180
17195
|
var rowmax = Math.max(row0 + dataLength + 2, rowm);
|
|
17181
17196
|
|
|
17182
17197
|
var i = row0 + 1;
|
|
@@ -18765,6 +18780,7 @@ LS.dropDatabase = function (lsdbid, ifexists, cb) {
|
|
|
18765
18780
|
|
|
18766
18781
|
LS.attachDatabase = function (lsdbid, databaseid, args, params, cb) {
|
|
18767
18782
|
var res = 1;
|
|
18783
|
+
// console.warn({lsdbid, databaseid, args, params, cb, dbs: Object.keys(alasql.databases)})
|
|
18768
18784
|
if (alasql.databases[databaseid]) {
|
|
18769
18785
|
throw new Error('Unable to attach database as "' + databaseid + '" because it already exists');
|
|
18770
18786
|
}
|
package/dist/alasql.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v1.7.
|
|
1
|
+
//! AlaSQL v1.7.5-v1-hotfix-95227342undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 1.7.
|
|
4
|
+
@version 1.7.5-v1-hotfix-95227342undefined
|
|
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 = '1.7.
|
|
145
|
+
alasql.version = '1.7.5-v1-hotfix-95227342undefined';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -4323,6 +4323,12 @@ var getXLSX = function () {
|
|
|
4323
4323
|
return XLSX;
|
|
4324
4324
|
};
|
|
4325
4325
|
|
|
4326
|
+
var jss = JSON.stringify;
|
|
4327
|
+
var reName = /[^a-z\d@-_]+/gi;
|
|
4328
|
+
var nss = (e) => e.replace(reName, '');
|
|
4329
|
+
var reTick = /`/g;
|
|
4330
|
+
var tss = (e) => e.replace(reTick, '');
|
|
4331
|
+
|
|
4326
4332
|
// set AlaSQl path
|
|
4327
4333
|
alasql.path = alasql.utils.findAlaSQLPath();
|
|
4328
4334
|
|
|
@@ -6303,7 +6309,7 @@ yy.Search.prototype.toString = function () {
|
|
|
6303
6309
|
|
|
6304
6310
|
yy.Search.prototype.toJS = function (context) {
|
|
6305
6311
|
|
|
6306
|
-
var s = 'this.queriesfn[' + (this.queriesidx - 1) + '](this.params,null,' + context + ')';
|
|
6312
|
+
var s = 'this.queriesfn[' + jss(this.queriesidx - 1) + '](this.params,null,' + jss(context) + ')';
|
|
6307
6313
|
// var s = '';
|
|
6308
6314
|
return s;
|
|
6309
6315
|
};
|
|
@@ -6664,11 +6670,11 @@ alasql.srch.SET = function (val, args, stope, params) {
|
|
|
6664
6670
|
.map(function (st) {
|
|
6665
6671
|
|
|
6666
6672
|
if (st.method === '@') {
|
|
6667
|
-
return
|
|
6673
|
+
return 'alasql.vars[' + jss(st.variable) + ']=' + st.expression.toJS('x', '');
|
|
6668
6674
|
} else if (st.method === '$') {
|
|
6669
|
-
return
|
|
6675
|
+
return 'params[' + jss(st.variable) + ']=' + st.expression.toJS('x', '');
|
|
6670
6676
|
} else {
|
|
6671
|
-
return
|
|
6677
|
+
return 'x[' + jss(st.column.columnid) + ']=' + st.expression.toJS('x', '');
|
|
6672
6678
|
}
|
|
6673
6679
|
})
|
|
6674
6680
|
.join(';');
|
|
@@ -6755,17 +6761,26 @@ var compileSearchOrder = function (order) {
|
|
|
6755
6761
|
s += 'if(a' + dg + '==b' + dg + '){';
|
|
6756
6762
|
} else {
|
|
6757
6763
|
s +=
|
|
6758
|
-
|
|
6759
|
-
columnid +
|
|
6760
|
-
"
|
|
6764
|
+
'if((a[' +
|
|
6765
|
+
jss(columnid) +
|
|
6766
|
+
"]||'')" +
|
|
6761
6767
|
dg +
|
|
6762
6768
|
(ord.direction === 'ASC' ? '>' : '<') +
|
|
6763
|
-
|
|
6764
|
-
columnid +
|
|
6765
|
-
"
|
|
6769
|
+
'(b[' +
|
|
6770
|
+
jss(columnid) +
|
|
6771
|
+
"]||'')" +
|
|
6766
6772
|
dg +
|
|
6767
6773
|
')return 1;';
|
|
6768
|
-
s +=
|
|
6774
|
+
s +=
|
|
6775
|
+
'if((a[' +
|
|
6776
|
+
jss(columnid) +
|
|
6777
|
+
"]||'')" +
|
|
6778
|
+
dg +
|
|
6779
|
+
'==(b[' +
|
|
6780
|
+
jss(columnid) +
|
|
6781
|
+
"]||'')" +
|
|
6782
|
+
dg +
|
|
6783
|
+
'){';
|
|
6769
6784
|
}
|
|
6770
6785
|
} else {
|
|
6771
6786
|
dg = '.valueOf()';
|
|
@@ -9329,9 +9344,10 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9329
9344
|
|
|
9330
9345
|
if (columns && columns.length > 0) {
|
|
9331
9346
|
columns.forEach(function (tcol) {
|
|
9347
|
+
var escapedColumnId = escapeq(tcol.columnid);
|
|
9332
9348
|
if (joinstar && alasql.options.joinstar == 'underscore') {
|
|
9333
9349
|
ss.push(
|
|
9334
|
-
"'" + alias + '_' +
|
|
9350
|
+
"'" + alias + '_' + escapedColumnId + "':p['" + alias + "']['" + escapedColumnId + "']"
|
|
9335
9351
|
);
|
|
9336
9352
|
} else if (joinstar && alasql.options.joinstar == 'json') {
|
|
9337
9353
|
// ss.push('\''+alias+'_'+tcol.columnid+'\':p[\''+alias+'\'][\''+tcol.columnid+'\']');
|
|
@@ -9339,16 +9355,16 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9339
9355
|
"r['" +
|
|
9340
9356
|
alias +
|
|
9341
9357
|
"']['" +
|
|
9342
|
-
|
|
9358
|
+
escapedColumnId +
|
|
9343
9359
|
"']=p['" +
|
|
9344
9360
|
alias +
|
|
9345
9361
|
"']['" +
|
|
9346
|
-
|
|
9362
|
+
escapedColumnId +
|
|
9347
9363
|
"'];";
|
|
9348
9364
|
} else {
|
|
9349
|
-
var value = "p['" + alias + "']['" +
|
|
9365
|
+
var value = "p['" + alias + "']['" + escapedColumnId + "']";
|
|
9350
9366
|
if (!columnIds[tcol.columnid]) {
|
|
9351
|
-
var key = "'" +
|
|
9367
|
+
var key = "'" + escapedColumnId + "':";
|
|
9352
9368
|
ss.push(key + value);
|
|
9353
9369
|
columnIds[tcol.columnid] = {
|
|
9354
9370
|
id: ss.length - 1,
|
|
@@ -9387,7 +9403,7 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9387
9403
|
|
|
9388
9404
|
});
|
|
9389
9405
|
|
|
9390
|
-
return {s: ss.join(','), sp: sp};
|
|
9406
|
+
return { s: ss.join(','), sp: sp };
|
|
9391
9407
|
}
|
|
9392
9408
|
|
|
9393
9409
|
yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
@@ -9438,14 +9454,14 @@ yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
|
9438
9454
|
if (false && tbid && !query.defcols['.'][col.tableid] && !query.defcols[col.columnid]) {
|
|
9439
9455
|
ss.push(
|
|
9440
9456
|
"'" +
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9457
|
+
escapeq(col.as || col.columnid) +
|
|
9458
|
+
"':p['" +
|
|
9459
|
+
query.defaultTableid +
|
|
9460
|
+
"']['" +
|
|
9461
|
+
col.tableid +
|
|
9462
|
+
"']['" +
|
|
9463
|
+
col.columnid +
|
|
9464
|
+
"']"
|
|
9449
9465
|
);
|
|
9450
9466
|
} else {
|
|
9451
9467
|
// workaround for multisheet xlsx export with custom COLUMNS
|
|
@@ -9480,12 +9496,12 @@ yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
|
9480
9496
|
} else {
|
|
9481
9497
|
ss.push(
|
|
9482
9498
|
"'" +
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9499
|
+
escapeq(col.as || col.columnid) +
|
|
9500
|
+
"':p['" +
|
|
9501
|
+
tbid +
|
|
9502
|
+
"']['" +
|
|
9503
|
+
col.columnid +
|
|
9504
|
+
"']"
|
|
9489
9505
|
);
|
|
9490
9506
|
}
|
|
9491
9507
|
}
|
|
@@ -9570,9 +9586,9 @@ yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
|
9570
9586
|
) {
|
|
9571
9587
|
ss.push(
|
|
9572
9588
|
"'" +
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9589
|
+
escapeq(col.as) +
|
|
9590
|
+
"':" +
|
|
9591
|
+
n2u(col.expression.toJS('p', query.defaultTableid, query.defcols))
|
|
9576
9592
|
);
|
|
9577
9593
|
} else if (col.aggregatorid === 'COUNT') {
|
|
9578
9594
|
ss.push("'" + escapeq(col.as) + "':1");
|
|
@@ -9602,9 +9618,9 @@ yy.Select.prototype.compileSelect1 = function (query, params) {
|
|
|
9602
9618
|
|
|
9603
9619
|
ss.push(
|
|
9604
9620
|
"'" +
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9621
|
+
escapeq(col.as || col.columnid || col.toString()) +
|
|
9622
|
+
"':" +
|
|
9623
|
+
n2u(col.toJS('p', query.defaultTableid, query.defcols))
|
|
9608
9624
|
);
|
|
9609
9625
|
// ss.push('\''+escapeq(col.toString())+'\':'+col.toJS("p",query.defaultTableid));
|
|
9610
9626
|
//if(col instanceof yy.Expression) {
|
|
@@ -10457,8 +10473,8 @@ yy.Over.prototype.toString = function () {
|
|
|
10457
10473
|
*/
|
|
10458
10474
|
|
|
10459
10475
|
/**
|
|
10460
|
-
|
|
10461
|
-
|
|
10476
|
+
Expression statement ( = 2*2; )
|
|
10477
|
+
@class
|
|
10462
10478
|
@param {object} params Initial parameters
|
|
10463
10479
|
*/
|
|
10464
10480
|
yy.ExpressionStatement = function (params) {
|
|
@@ -10833,7 +10849,7 @@ yy.Op.prototype.toJS = function (context, tableid, defcols) {
|
|
|
10833
10849
|
var ljs = '(' + leftJS() + '||{})';
|
|
10834
10850
|
|
|
10835
10851
|
if (typeof this.right === 'string') {
|
|
10836
|
-
s = ljs + '["' + this.right + '"]';
|
|
10852
|
+
s = ljs + '["' + escapeq(this.right) + '"]';
|
|
10837
10853
|
} else if (typeof this.right === 'number') {
|
|
10838
10854
|
s = ljs + '[' + this.right + ']';
|
|
10839
10855
|
} else if (this.right instanceof yy.FuncValue) {
|
|
@@ -11064,7 +11080,7 @@ yy.VarValue.prototype.toType = function () {
|
|
|
11064
11080
|
};
|
|
11065
11081
|
|
|
11066
11082
|
yy.VarValue.prototype.toJS = function () {
|
|
11067
|
-
return "alasql.vars['" + this.variable + "']";
|
|
11083
|
+
return "alasql.vars['" + escapeq(this.variable) + "']";
|
|
11068
11084
|
};
|
|
11069
11085
|
|
|
11070
11086
|
yy.NumValue = function (params) {
|
|
@@ -11458,7 +11474,7 @@ yy.AggrValue.prototype.toJS = function (/*context, tableid, defcols*/) {
|
|
|
11458
11474
|
|
|
11459
11475
|
var colas = this.nick;
|
|
11460
11476
|
if (colas === undefined) {
|
|
11461
|
-
colas = this.toString();
|
|
11477
|
+
colas = escapeq(this.toString());
|
|
11462
11478
|
}
|
|
11463
11479
|
return "g['" + colas + "']";
|
|
11464
11480
|
};
|
|
@@ -17170,8 +17186,7 @@ alasql.into.XLSX = function (filename, opts, data, columns, cb) {
|
|
|
17170
17186
|
var colm = 1,
|
|
17171
17187
|
rowm = 1;
|
|
17172
17188
|
}
|
|
17173
|
-
var
|
|
17174
|
-
var colmax = Math.max(col0 + columns.length - 1 + zeroColumnFix, colm);
|
|
17189
|
+
var colmax = Math.max(col0 + columns.length, colm);
|
|
17175
17190
|
var rowmax = Math.max(row0 + dataLength + 2, rowm);
|
|
17176
17191
|
|
|
17177
17192
|
var i = row0 + 1;
|
|
@@ -18760,6 +18775,7 @@ LS.dropDatabase = function (lsdbid, ifexists, cb) {
|
|
|
18760
18775
|
|
|
18761
18776
|
LS.attachDatabase = function (lsdbid, databaseid, args, params, cb) {
|
|
18762
18777
|
var res = 1;
|
|
18778
|
+
// console.warn({lsdbid, databaseid, args, params, cb, dbs: Object.keys(alasql.databases)})
|
|
18763
18779
|
if (alasql.databases[databaseid]) {
|
|
18764
18780
|
throw new Error('Unable to attach database as "' + databaseid + '" because it already exists');
|
|
18765
18781
|
}
|