alasql 0.5.10 → 0.5.12
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/bin/alasql-cli.js +1 -1
- package/dist/alasql-worker.js +2 -2
- package/dist/alasql-worker.min.js +1 -1
- package/dist/alasql.fs.js +19 -19
- package/dist/alasql.js +19 -19
- package/dist/alasql.min.js +2 -2
- package/package.json +1 -1
package/bin/alasql-cli.js
CHANGED
package/dist/alasql-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v0.5.
|
|
1
|
+
//! AlaSQL v0.5.12 | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 0.5.
|
|
4
|
+
@version 0.5.12
|
|
5
5
|
|
|
6
6
|
AlaSQL - JavaScript SQL database
|
|
7
7
|
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
//! AlaSQL v0.5.
|
|
1
|
+
//! AlaSQL v0.5.12 | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
!function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function a(r,e,t){"function"==typeof(e=e||[])&&(scope=t,t=e,e=[]),"object"!=typeof e&&(e=[e]);var o=a.lastid++;a.buffer[o]=t,a.webworker.postMessage({id:o,sql:r,params:e})}if(a.options={},a.options.progress=function(){},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)},a.promise=function(){throw new Error("Please include a Promise/A+ library")},"undefined"!=typeof Promise){function i(r,e,n,s){return new Promise(function(t,o){a(r,e,function(r,e){e?o(e):(n&&s&&!1!==a.options.progress&&a.options.progress(n,s),t(r))})})}a.promise=function(r,e){if("undefined"==typeof Promise)throw new Error("Please include a Promise/A+ library");if("string"==typeof r)return i(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=[],s=0;s<r.length;s++){if("string"==typeof(e=r[s])&&(e=[e]),!isArray(e)||e.length<1||2<e.length)throw new Error("Error in .promise parameter");t=e[0],o=e[1]||void 0,n.push(i(t,o,s,r.length))}return Promise.all(n)}}(r)}}if(!(a=a||!1))throw new Error("alasql was not found");return a.worker=function(){throw new Error("Can find webworker in this enviroment")},"undefined"!=typeof Worker&&(a.worker=function(r,e,t){if(!0===r&&(r=void 0),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");if(!1!==r){var 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});});}";var i=new Blob([s],{type:"text/plain"});if(a.webworker=new Worker(URL.createObjectURL(i)),a.webworker.onmessage=function(r){var e=r.data.id;a.buffer[e](r.data.data),delete a.buffer[e]},a.webworker.onerror=function(r){throw r},1<arguments.length)a("REQUIRE "+e.map(function(r){return'"'+r+'"'}).join(","),[],t)}else if(!1===r)return void delete a.webworker}),a.lastid=0,a.buffer={},a.worker(),a});
|
package/dist/alasql.fs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v0.5.
|
|
1
|
+
//! AlaSQL v0.5.12 | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 0.5.
|
|
4
|
+
@version 0.5.12
|
|
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 = '0.5.
|
|
145
|
+
alasql.version = '0.5.12';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -2483,7 +2483,7 @@ next:function () {
|
|
|
2483
2483
|
|
|
2484
2484
|
// return next match that has a token
|
|
2485
2485
|
lex:function lex() {
|
|
2486
|
-
var r = this.next();
|
|
2486
|
+
var r = this.next();if(r&&/^(N?['"]__proto__['"]|\[__proto__\]|`__proto__`|__proto__)$/i.test(this.yytext))throw new Error("__proto__ is not allowed");
|
|
2487
2487
|
if (r) {
|
|
2488
2488
|
return r;
|
|
2489
2489
|
} else {
|
|
@@ -4009,11 +4009,11 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
|
|
|
4009
4009
|
return new Date(obj);
|
|
4010
4010
|
}
|
|
4011
4011
|
|
|
4012
|
-
var temp = obj.constructor(); // changed
|
|
4012
|
+
var temp = (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
|
|
4013
4013
|
|
|
4014
4014
|
for (var key in obj) {
|
|
4015
4015
|
if (obj.hasOwnProperty(key)) {
|
|
4016
|
-
temp[key] = cloneDeep(obj[key]);
|
|
4016
|
+
/* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(temp, key, {value: cloneDeep(obj[key]), writable: true, enumerable: true, configurable: true}); } else { temp[key] = cloneDeep(obj[key]); }
|
|
4017
4017
|
}
|
|
4018
4018
|
}
|
|
4019
4019
|
return temp;
|
|
@@ -4085,7 +4085,7 @@ var extend = (utils.extend = function extend(a, b) {
|
|
|
4085
4085
|
a = a || {};
|
|
4086
4086
|
for (var key in b) {
|
|
4087
4087
|
if (b.hasOwnProperty(key)) {
|
|
4088
|
-
a[key] = b[key];
|
|
4088
|
+
/* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(a, key, {value: b[key], writable: true, enumerable: true, configurable: true}); } else { a[key] = b[key]; }
|
|
4089
4089
|
}
|
|
4090
4090
|
}
|
|
4091
4091
|
return a;
|
|
@@ -6963,7 +6963,7 @@ function queryfn3(query) {
|
|
|
6963
6963
|
|
|
6964
6964
|
// Prepare variables
|
|
6965
6965
|
query.data = [];
|
|
6966
|
-
query.xgroups
|
|
6966
|
+
query.xgroups=Object.create(null);
|
|
6967
6967
|
query.groups = [];
|
|
6968
6968
|
|
|
6969
6969
|
// Level of Joins
|
|
@@ -9124,7 +9124,7 @@ yy.Select.prototype.compileGroup = function(query) {
|
|
|
9124
9124
|
aft2 = '';
|
|
9125
9125
|
|
|
9126
9126
|
if (typeof query.groupStar !== 'undefined') {
|
|
9127
|
-
aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
|
|
9127
|
+
aft2 += "for(var f in p['" + query.groupStar + "']) {if(/^__proto__$/.test(f))Object.defineProperty(g,f,{writable:true,enumerable:true,configurable:true});g[f]=p['" + query.groupStar + "'][f];};";
|
|
9128
9128
|
}
|
|
9129
9129
|
|
|
9130
9130
|
/*
|
|
@@ -9439,7 +9439,7 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9439
9439
|
} else {
|
|
9440
9440
|
|
|
9441
9441
|
// if column not exist, then copy all
|
|
9442
|
-
sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
|
|
9442
|
+
sp += 'var w=p["' + alias + '"];for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
|
|
9443
9443
|
|
|
9444
9444
|
query.dirtyColumns = true;
|
|
9445
9445
|
}
|
|
@@ -9780,10 +9780,10 @@ yy.Select.prototype.compileSelectGroup1 = function(query) {
|
|
|
9780
9780
|
self.columns.forEach(function(col) {
|
|
9781
9781
|
|
|
9782
9782
|
if (col instanceof yy.Column && col.columnid === '*') {
|
|
9783
|
-
// s += 'for(var k in g){r[k]=g[k]};';
|
|
9783
|
+
// s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
|
|
9784
9784
|
// s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
|
|
9785
9785
|
|
|
9786
|
-
s += 'for(var k in g) {r[k]=g[k]};';
|
|
9786
|
+
s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
|
|
9787
9787
|
return '';
|
|
9788
9788
|
|
|
9789
9789
|
} else {
|
|
@@ -13109,7 +13109,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
13109
13109
|
|
|
13110
13110
|
table.update(
|
|
13111
13111
|
function (t) {
|
|
13112
|
-
for (var f in r) t[f] = r[f];
|
|
13112
|
+
for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
|
|
13113
13113
|
},
|
|
13114
13114
|
table.data.indexOf(toreplace),
|
|
13115
13115
|
params
|
|
@@ -14668,7 +14668,7 @@ yy.Insert.prototype.compile = function(databaseid) {
|
|
|
14668
14668
|
});
|
|
14669
14669
|
} else {
|
|
14670
14670
|
|
|
14671
|
-
// sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
|
|
14671
|
+
// sw = 'var w='+JSONtoJS(values)+';for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
|
|
14672
14672
|
sw = JSONtoJS(values);
|
|
14673
14673
|
}
|
|
14674
14674
|
}
|
|
@@ -15746,19 +15746,19 @@ yy.SetVariable.prototype.execute = function(databaseid, params, cb) {
|
|
|
15746
15746
|
}
|
|
15747
15747
|
if (this.props && this.props.length > 0) {
|
|
15748
15748
|
if (this.method == '@') {
|
|
15749
|
-
var fs = "alasql.vars['"
|
|
15749
|
+
var fs = "alasql.vars[k('"+this.variable+"')]";
|
|
15750
15750
|
} else {
|
|
15751
|
-
var fs = "params['"
|
|
15751
|
+
var fs = "params[k('"+this.variable+"')]";
|
|
15752
15752
|
}
|
|
15753
15753
|
fs += this.props
|
|
15754
15754
|
.map(function(prop) {
|
|
15755
15755
|
if (typeof prop == 'string') {
|
|
15756
|
-
return "['"
|
|
15756
|
+
return "[k('"+prop+"')]";
|
|
15757
15757
|
} else if (typeof prop == 'number') {
|
|
15758
15758
|
return '[' + prop + ']';
|
|
15759
15759
|
} else {
|
|
15760
15760
|
|
|
15761
|
-
return
|
|
15761
|
+
return "[k("+prop.toJS()+")]";
|
|
15762
15762
|
// } else {
|
|
15763
15763
|
|
|
15764
15764
|
// throw new Error('Wrong SET property');
|
|
@@ -15766,7 +15766,7 @@ yy.SetVariable.prototype.execute = function(databaseid, params, cb) {
|
|
|
15766
15766
|
})
|
|
15767
15767
|
.join();
|
|
15768
15768
|
|
|
15769
|
-
new Function('value,params,alasql', 'var y;
|
|
15769
|
+
new Function('value,params,alasql', 'var y;var k=function(x){if(x==="__proto__"||x==="constructor"||x==="prototype")throw new Error(x+" is not allowed");return x};'+fs+'=value')(res, params, alasql);
|
|
15770
15770
|
} else {
|
|
15771
15771
|
if (this.method == '@') {
|
|
15772
15772
|
alasql.vars[this.variable] = res;
|
package/dist/alasql.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v0.5.
|
|
1
|
+
//! AlaSQL v0.5.12 | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 0.5.
|
|
4
|
+
@version 0.5.12
|
|
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 = '0.5.
|
|
145
|
+
alasql.version = '0.5.12';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -2483,7 +2483,7 @@ next:function () {
|
|
|
2483
2483
|
|
|
2484
2484
|
// return next match that has a token
|
|
2485
2485
|
lex:function lex() {
|
|
2486
|
-
var r = this.next();
|
|
2486
|
+
var r = this.next();if(r&&/^(N?['"]__proto__['"]|\[__proto__\]|`__proto__`|__proto__)$/i.test(this.yytext))throw new Error("__proto__ is not allowed");
|
|
2487
2487
|
if (r) {
|
|
2488
2488
|
return r;
|
|
2489
2489
|
} else {
|
|
@@ -4004,11 +4004,11 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
|
|
|
4004
4004
|
return new Date(obj);
|
|
4005
4005
|
}
|
|
4006
4006
|
|
|
4007
|
-
var temp = obj.constructor(); // changed
|
|
4007
|
+
var temp = (Object.prototype.hasOwnProperty.call(obj, 'constructor') ? Object : obj.constructor)(); // changed
|
|
4008
4008
|
|
|
4009
4009
|
for (var key in obj) {
|
|
4010
4010
|
if (obj.hasOwnProperty(key)) {
|
|
4011
|
-
temp[key] = cloneDeep(obj[key]);
|
|
4011
|
+
/* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(temp, key, {value: cloneDeep(obj[key]), writable: true, enumerable: true, configurable: true}); } else { temp[key] = cloneDeep(obj[key]); }
|
|
4012
4012
|
}
|
|
4013
4013
|
}
|
|
4014
4014
|
return temp;
|
|
@@ -4080,7 +4080,7 @@ var extend = (utils.extend = function extend(a, b) {
|
|
|
4080
4080
|
a = a || {};
|
|
4081
4081
|
for (var key in b) {
|
|
4082
4082
|
if (b.hasOwnProperty(key)) {
|
|
4083
|
-
a[key] = b[key];
|
|
4083
|
+
/* A "__proto__" key from parsed data is copied as data, never as the prototype */ if (key === '__proto__') { Object.defineProperty(a, key, {value: b[key], writable: true, enumerable: true, configurable: true}); } else { a[key] = b[key]; }
|
|
4084
4084
|
}
|
|
4085
4085
|
}
|
|
4086
4086
|
return a;
|
|
@@ -6958,7 +6958,7 @@ function queryfn3(query) {
|
|
|
6958
6958
|
|
|
6959
6959
|
// Prepare variables
|
|
6960
6960
|
query.data = [];
|
|
6961
|
-
query.xgroups
|
|
6961
|
+
query.xgroups=Object.create(null);
|
|
6962
6962
|
query.groups = [];
|
|
6963
6963
|
|
|
6964
6964
|
// Level of Joins
|
|
@@ -9119,7 +9119,7 @@ yy.Select.prototype.compileGroup = function(query) {
|
|
|
9119
9119
|
aft2 = '';
|
|
9120
9120
|
|
|
9121
9121
|
if (typeof query.groupStar !== 'undefined') {
|
|
9122
|
-
aft2 += "for(var f in p['" + query.groupStar + "']) {g[f]=p['" + query.groupStar + "'][f];};";
|
|
9122
|
+
aft2 += "for(var f in p['" + query.groupStar + "']) {if(/^__proto__$/.test(f))Object.defineProperty(g,f,{writable:true,enumerable:true,configurable:true});g[f]=p['" + query.groupStar + "'][f];};";
|
|
9123
9123
|
}
|
|
9124
9124
|
|
|
9125
9125
|
/*
|
|
@@ -9434,7 +9434,7 @@ function compileSelectStar(query, aliases, joinstar) {
|
|
|
9434
9434
|
} else {
|
|
9435
9435
|
|
|
9436
9436
|
// if column not exist, then copy all
|
|
9437
|
-
sp += 'var w=p["' + alias + '"];for(var k in w){r[k]=w[k]};';
|
|
9437
|
+
sp += 'var w=p["' + alias + '"];for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
|
|
9438
9438
|
|
|
9439
9439
|
query.dirtyColumns = true;
|
|
9440
9440
|
}
|
|
@@ -9775,10 +9775,10 @@ yy.Select.prototype.compileSelectGroup1 = function(query) {
|
|
|
9775
9775
|
self.columns.forEach(function(col) {
|
|
9776
9776
|
|
|
9777
9777
|
if (col instanceof yy.Column && col.columnid === '*') {
|
|
9778
|
-
// s += 'for(var k in g){r[k]=g[k]};';
|
|
9778
|
+
// s += 'for(var k in g){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
|
|
9779
9779
|
// s += 'for(var k in this.query.groupColumns){r[k]=g[this.query.groupColumns[k]]};';
|
|
9780
9780
|
|
|
9781
|
-
s += 'for(var k in g) {r[k]=g[k]};';
|
|
9781
|
+
s += 'for(var k in g) {if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=g[k]};';
|
|
9782
9782
|
return '';
|
|
9783
9783
|
|
|
9784
9784
|
} else {
|
|
@@ -13104,7 +13104,7 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
13104
13104
|
|
|
13105
13105
|
table.update(
|
|
13106
13106
|
function (t) {
|
|
13107
|
-
for (var f in r) t[f] = r[f];
|
|
13107
|
+
for (var f in r) {if(/^__proto__$/.test(f))Object.defineProperty(t,f,{writable:true,enumerable:true,configurable:true});t[f] = r[f];}
|
|
13108
13108
|
},
|
|
13109
13109
|
table.data.indexOf(toreplace),
|
|
13110
13110
|
params
|
|
@@ -14663,7 +14663,7 @@ yy.Insert.prototype.compile = function(databaseid) {
|
|
|
14663
14663
|
});
|
|
14664
14664
|
} else {
|
|
14665
14665
|
|
|
14666
|
-
// sw = 'var w='+JSONtoJS(values)+';for(var k in w){r[k]=w[k]};';
|
|
14666
|
+
// sw = 'var w='+JSONtoJS(values)+';for(var k in w){if(/^__proto__$/.test(k))Object.defineProperty(r,k,{writable:true,enumerable:true,configurable:true});r[k]=w[k]};';
|
|
14667
14667
|
sw = JSONtoJS(values);
|
|
14668
14668
|
}
|
|
14669
14669
|
}
|
|
@@ -15741,19 +15741,19 @@ yy.SetVariable.prototype.execute = function(databaseid, params, cb) {
|
|
|
15741
15741
|
}
|
|
15742
15742
|
if (this.props && this.props.length > 0) {
|
|
15743
15743
|
if (this.method == '@') {
|
|
15744
|
-
var fs = "alasql.vars['"
|
|
15744
|
+
var fs = "alasql.vars[k('"+this.variable+"')]";
|
|
15745
15745
|
} else {
|
|
15746
|
-
var fs = "params['"
|
|
15746
|
+
var fs = "params[k('"+this.variable+"')]";
|
|
15747
15747
|
}
|
|
15748
15748
|
fs += this.props
|
|
15749
15749
|
.map(function(prop) {
|
|
15750
15750
|
if (typeof prop == 'string') {
|
|
15751
|
-
return "['"
|
|
15751
|
+
return "[k('"+prop+"')]";
|
|
15752
15752
|
} else if (typeof prop == 'number') {
|
|
15753
15753
|
return '[' + prop + ']';
|
|
15754
15754
|
} else {
|
|
15755
15755
|
|
|
15756
|
-
return
|
|
15756
|
+
return "[k("+prop.toJS()+")]";
|
|
15757
15757
|
// } else {
|
|
15758
15758
|
|
|
15759
15759
|
// throw new Error('Wrong SET property');
|
|
@@ -15761,7 +15761,7 @@ yy.SetVariable.prototype.execute = function(databaseid, params, cb) {
|
|
|
15761
15761
|
})
|
|
15762
15762
|
.join();
|
|
15763
15763
|
|
|
15764
|
-
new Function('value,params,alasql', 'var y;
|
|
15764
|
+
new Function('value,params,alasql', 'var y;var k=function(x){if(x==="__proto__"||x==="constructor"||x==="prototype")throw new Error(x+" is not allowed");return x};'+fs+'=value')(res, params, alasql);
|
|
15765
15765
|
} else {
|
|
15766
15766
|
if (this.method == '@') {
|
|
15767
15767
|
alasql.vars[this.variable] = res;
|