alasql 0.6.3 → 0.6.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/.github/dependabot.yml +8 -0
- package/.github/workflows/nodejs.yml +1 -2
- package/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/bin/alaserver.js +17 -15
- package/bin/alasql-cli.js +31 -22
- package/dist/alasql-echo.js +10 -8
- package/dist/alasql-prolog.js +29 -18
- package/dist/alasql-worker.js +2 -2
- package/dist/alasql-worker.min.js +1 -1
- package/dist/alasql.fs.js +28 -11
- package/dist/alasql.js +28 -11
- package/dist/alasql.min.js +2 -2
- package/package.json +14 -14
- package/.dependabot/config.yml +0 -8
|
@@ -21,9 +21,8 @@ jobs:
|
|
|
21
21
|
uses: actions/setup-node@v1
|
|
22
22
|
with:
|
|
23
23
|
node-version: ${{ matrix.node-version }}
|
|
24
|
-
- run: npx yarn install
|
|
24
|
+
- run: npx yarn install --frozen-lockfile
|
|
25
25
|
- run: npx prettier src/*.js --list-different || (echo 'Please correct file formatting using `yarn format` and try again.' && exit 1)
|
|
26
|
-
- run: npx yarn test-only
|
|
27
26
|
- run: npx yarn test
|
|
28
27
|
|
|
29
28
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### 0.6.4 (24.09.2020)
|
|
4
|
+
|
|
5
|
+
- Add: String and Number objects supported as values
|
|
6
|
+
- Add: `JOIN USING` now supports String and Number objects
|
|
7
|
+
- Fix: File naming when exporting to Exel
|
|
8
|
+
|
|
3
9
|
|
|
4
10
|
### 0.6.2 (31.05.2020)
|
|
5
11
|
|
|
@@ -105,7 +111,7 @@
|
|
|
105
111
|
* Fix: missing ORDER BY direction when calling toString on AST (#970)
|
|
106
112
|
* Fix: Converting the syntax tree back to SQL with multple joins (#972)
|
|
107
113
|
|
|
108
|
-
### 0.4.4 "Alsowm" (03.
|
|
114
|
+
### 0.4.4 "Alsowm" (03.12.2017)
|
|
109
115
|
|
|
110
116
|
* Better: Better usage via unpkg.com
|
|
111
117
|
* Better: Better usage via jsdelivr.com
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ _AlaSQL is an open source project used on more than two million page views per m
|
|
|
3
3
|
_Have a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask?tags=AlaSQL) using the "alasql" tag._
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
[](https://github.com/agershun/alasql/actions)
|
|
7
7
|
[](https://npm-stat.com/charts.html?package=alasql)
|
|
8
8
|
[](http://open-oss.com)
|
|
9
9
|
[](https://www.npmjs.com/package/alasql)
|
package/bin/alaserver.js
CHANGED
|
@@ -8,21 +8,23 @@
|
|
|
8
8
|
var alasql = require('alasql');
|
|
9
9
|
var http = require('http');
|
|
10
10
|
var url = require('url');
|
|
11
|
-
var port = (process.argv[2] || 1337)|0;
|
|
12
|
-
if(!port) {
|
|
13
|
-
throw new Error('Wrong port number '+process.argv[3]);
|
|
11
|
+
var port = (process.argv[2] || 1337) | 0;
|
|
12
|
+
if (!port) {
|
|
13
|
+
throw new Error('Wrong port number ' + process.argv[3]);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
http
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
http
|
|
17
|
+
.createServer(function (req, res) {
|
|
18
|
+
var sql = decodeURI(url.parse(req.url).search).substr(1);
|
|
19
|
+
var a = '';
|
|
20
|
+
try {
|
|
21
|
+
a = alasql(sql);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
a = err.toString();
|
|
24
|
+
}
|
|
25
|
+
res.writeHead(200, {'Content-Type': 'application/json'});
|
|
26
|
+
res.end(JSON.stringify(a));
|
|
27
|
+
})
|
|
28
|
+
.listen(port, '127.0.0.1');
|
|
27
29
|
|
|
28
|
-
console.log('Server running at http://127.0.0.1:'+port+'/');
|
|
30
|
+
console.log('Server running at http://127.0.0.1:' + port + '/');
|
package/bin/alasql-cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
//
|
|
3
3
|
// Command line interface for Alasql
|
|
4
4
|
// Version: 0.2.2
|
|
5
5
|
// Date: 28.07.2015
|
|
@@ -12,39 +12,46 @@ let fs = require('fs');
|
|
|
12
12
|
let stdin = process.openStdin();
|
|
13
13
|
let yargs = require('yargs')
|
|
14
14
|
.strict()
|
|
15
|
-
.usage(
|
|
15
|
+
.usage(
|
|
16
|
+
'AlaSQL command-line utility (version ' +
|
|
17
|
+
alasql.version +
|
|
18
|
+
')\n\nUsage: $0 [options] [sql] [params]'
|
|
19
|
+
)
|
|
16
20
|
|
|
17
|
-
.example('$0 "sql-statement"', 'Run SQL statement and output result as JSON')
|
|
21
|
+
.example('$0 "sql-statement"', 'Run SQL statement and output result as JSON')
|
|
18
22
|
.example('')
|
|
19
|
-
.example(
|
|
23
|
+
.example("$0 'value of select 2+?' 40", 'Outputs 42')
|
|
20
24
|
.example('')
|
|
21
|
-
.example(
|
|
25
|
+
.example("$0 'select count(*) from txt()' < city.txt", 'Count lines in city.txt')
|
|
22
26
|
.example('')
|
|
23
|
-
.example(
|
|
27
|
+
.example(
|
|
28
|
+
'$0 \'select * into xlsx("city.xlsx") from txt("city.txt")\'',
|
|
29
|
+
'Convert from txt to xlsx'
|
|
30
|
+
)
|
|
24
31
|
.example('')
|
|
25
32
|
.example('$0 --file file.sql France 1960', 'Run SQL from file with 2 parameters')
|
|
26
33
|
|
|
27
|
-
.version('v', 'Echo AlaSQL version', alasql.version)
|
|
34
|
+
.version('v', 'Echo AlaSQL version', alasql.version)
|
|
28
35
|
.alias('v', 'version')
|
|
29
36
|
|
|
30
|
-
.boolean('m')
|
|
37
|
+
.boolean('m')
|
|
31
38
|
.describe('m', 'Minify json output')
|
|
32
39
|
.alias('m', 'minify')
|
|
33
40
|
|
|
34
|
-
.describe('f', 'Load SQL from file')
|
|
41
|
+
.describe('f', 'Load SQL from file')
|
|
35
42
|
.alias('f', 'file')
|
|
36
43
|
.nargs('f', 1)
|
|
37
44
|
.normalize('f')
|
|
38
45
|
|
|
39
|
-
.help('h')
|
|
46
|
+
.help('h')
|
|
40
47
|
.alias('h', 'help')
|
|
41
48
|
|
|
42
|
-
.epilog('\nMore information about the library: www.alasql.org')
|
|
49
|
+
.epilog('\nMore information about the library: www.alasql.org');
|
|
43
50
|
|
|
44
51
|
let argv = yargs.argv;
|
|
45
52
|
let sql = '';
|
|
46
53
|
let params = [];
|
|
47
|
-
let pipedData = ''
|
|
54
|
+
let pipedData = '';
|
|
48
55
|
stdin.on('data', function (chunk) {
|
|
49
56
|
pipedData += chunk;
|
|
50
57
|
});
|
|
@@ -67,7 +74,6 @@ if (argv.f) {
|
|
|
67
74
|
|
|
68
75
|
sql = fs.readFileSync(argv.f, 'utf8').toString();
|
|
69
76
|
execute(sql, argv._);
|
|
70
|
-
|
|
71
77
|
} else {
|
|
72
78
|
sql = argv._.shift() || '';
|
|
73
79
|
|
|
@@ -90,9 +96,8 @@ stdin.on('end', function () {
|
|
|
90
96
|
* @returns {null} Result will be printet to console.log
|
|
91
97
|
*/
|
|
92
98
|
function execute(sql, params) {
|
|
93
|
-
|
|
94
99
|
if (0 === sql.trim().length) {
|
|
95
|
-
console.error(
|
|
100
|
+
console.error('\nNo SQL to process\n');
|
|
96
101
|
yargs.showHelp();
|
|
97
102
|
process.exit(1);
|
|
98
103
|
}
|
|
@@ -100,23 +105,28 @@ function execute(sql, params) {
|
|
|
100
105
|
for (var i = 1; i < params.length; i++) {
|
|
101
106
|
var a = params[i];
|
|
102
107
|
if (a[0] !== '"' && a[0] !== "'") {
|
|
103
|
-
if (+a == a) {
|
|
108
|
+
if (+a == a) {
|
|
109
|
+
// jshint ignore:line
|
|
104
110
|
params[i] = +a;
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
|
|
109
|
-
alasql
|
|
115
|
+
alasql
|
|
116
|
+
.promise(sql, params)
|
|
110
117
|
.then(function (res) {
|
|
111
118
|
if (!alasql.options.stdout) {
|
|
112
119
|
console.log(formatOutput(res));
|
|
113
120
|
}
|
|
114
121
|
process.exit(0);
|
|
115
|
-
})
|
|
122
|
+
})
|
|
123
|
+
.catch(function (err) {
|
|
116
124
|
let errorJsonObj = JSON.parse(JSON.stringify(err, Object.getOwnPropertyNames(err)));
|
|
117
|
-
console.error(
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
console.error(
|
|
126
|
+
formatOutput({
|
|
127
|
+
error: errorJsonObj,
|
|
128
|
+
})
|
|
129
|
+
);
|
|
120
130
|
process.exit(1);
|
|
121
131
|
});
|
|
122
132
|
}
|
|
@@ -138,7 +148,6 @@ function isDirectory(filePath) {
|
|
|
138
148
|
return isDir;
|
|
139
149
|
}
|
|
140
150
|
|
|
141
|
-
|
|
142
151
|
/**
|
|
143
152
|
* Format output
|
|
144
153
|
*
|
package/dist/alasql-echo.js
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var yy = alasql.yy;
|
|
4
4
|
|
|
5
|
-
yy.Echo = function (params) {
|
|
6
|
-
yy.
|
|
7
|
-
|
|
5
|
+
yy.Echo = function (params) {
|
|
6
|
+
return yy.extend(this, params);
|
|
7
|
+
};
|
|
8
|
+
yy.Echo.prototype.toString = function () {
|
|
9
|
+
var s = 'TEST ' + this.expr.toString();
|
|
8
10
|
return s;
|
|
9
|
-
}
|
|
11
|
+
};
|
|
10
12
|
|
|
11
13
|
yy.Echo.prototype.execute = function (databaseid, params, cb) {
|
|
12
|
-
// var self = this;
|
|
14
|
+
// var self = this;
|
|
13
15
|
// console.log(76336,this.expr.toJS());
|
|
14
|
-
var fn = new Function('params, alasql','return '+this.expr.toJS());
|
|
16
|
+
var fn = new Function('params, alasql', 'return ' + this.expr.toJS());
|
|
15
17
|
var res = fn(params, alasql);
|
|
16
|
-
if(cb) res = cb(res);
|
|
18
|
+
if (cb) res = cb(res);
|
|
17
19
|
return res;
|
|
18
|
-
}
|
|
20
|
+
};
|
package/dist/alasql-prolog.js
CHANGED
|
@@ -2,39 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
var yy = alasql.yy;
|
|
4
4
|
|
|
5
|
-
yy.Term = function (params) {
|
|
6
|
-
yy.
|
|
5
|
+
yy.Term = function (params) {
|
|
6
|
+
return yy.extend(this, params);
|
|
7
|
+
};
|
|
8
|
+
yy.Term.prototype.toString = function () {
|
|
7
9
|
var s = this.termid;
|
|
8
|
-
if(this.args && this.args.length > 0) {
|
|
9
|
-
s +=
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
if (this.args && this.args.length > 0) {
|
|
11
|
+
s +=
|
|
12
|
+
'(' +
|
|
13
|
+
this.args.map(function (arg) {
|
|
14
|
+
return arg.toString();
|
|
15
|
+
}) +
|
|
16
|
+
')';
|
|
12
17
|
}
|
|
13
18
|
return s;
|
|
14
19
|
};
|
|
15
20
|
|
|
16
|
-
yy.AddRule = function (params) {
|
|
17
|
-
yy.
|
|
21
|
+
yy.AddRule = function (params) {
|
|
22
|
+
return yy.extend(this, params);
|
|
23
|
+
};
|
|
24
|
+
yy.AddRule.prototype.toString = function () {
|
|
18
25
|
var s = '';
|
|
19
|
-
if(this.left) s += this.left.toString();
|
|
26
|
+
if (this.left) s += this.left.toString();
|
|
20
27
|
s += ':-';
|
|
21
|
-
s += this.right
|
|
28
|
+
s += this.right
|
|
29
|
+
.map(function (r) {
|
|
30
|
+
return r.toString();
|
|
31
|
+
})
|
|
32
|
+
.join(',');
|
|
22
33
|
return s;
|
|
23
34
|
};
|
|
24
35
|
|
|
25
36
|
yy.AddRule.prototype.execute = function (databaseid, params, cb) {
|
|
26
|
-
// var self = this;
|
|
27
|
-
// console.log(this.expr.toJS());
|
|
28
|
-
// var fn = new Function('params, alasql','return '+this.expr.toJS());
|
|
29
|
-
// var res = fn(params, alasql);
|
|
37
|
+
// var self = this;
|
|
38
|
+
// console.log(this.expr.toJS());
|
|
39
|
+
// var fn = new Function('params, alasql','return '+this.expr.toJS());
|
|
40
|
+
// var res = fn(params, alasql);
|
|
30
41
|
var res = 1;
|
|
31
42
|
var objects = alasql.databases[databaseid].objects;
|
|
32
43
|
var rule = {};
|
|
33
|
-
if(!this.left) {
|
|
34
|
-
this.right.forEach(function(term){
|
|
44
|
+
if (!this.left) {
|
|
45
|
+
this.right.forEach(function (term) {
|
|
35
46
|
rule.$class = term.termid;
|
|
36
47
|
});
|
|
37
48
|
}
|
|
38
|
-
if(cb) res = cb(res);
|
|
49
|
+
if (cb) res = cb(res);
|
|
39
50
|
return res;
|
|
40
|
-
};
|
|
51
|
+
};
|
package/dist/alasql-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v0.6.
|
|
1
|
+
//! AlaSQL v0.6.4-develop-2311b55fundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 0.6.
|
|
4
|
+
@version 0.6.4-develop-2311b55fundefined
|
|
5
5
|
|
|
6
6
|
AlaSQL - JavaScript SQL database
|
|
7
7
|
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
//! AlaSQL v0.6.
|
|
1
|
+
//! AlaSQL v0.6.4-develop-2311b55fundefined | © 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})}var i;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&&(i=function(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)}),!(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"});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.6.
|
|
1
|
+
//! AlaSQL v0.6.4-develop-2311b55fundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 0.6.
|
|
4
|
+
@version 0.6.4-develop-2311b55fundefined
|
|
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.6.
|
|
145
|
+
alasql.version = '0.6.4-develop-2311b55fundefined';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -4019,6 +4019,14 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
|
|
|
4019
4019
|
return new Date(obj);
|
|
4020
4020
|
}
|
|
4021
4021
|
|
|
4022
|
+
if (obj instanceof String) {
|
|
4023
|
+
return obj.toString();
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
if (obj instanceof Number) {
|
|
4027
|
+
return +obj;
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4022
4030
|
var temp = obj.constructor(); // changed
|
|
4023
4031
|
|
|
4024
4032
|
for (var key in obj) {
|
|
@@ -7501,12 +7509,18 @@ function doJoin(query, scope, h) {
|
|
|
7501
7509
|
if (!opt && source.getfn && !source.dontcache) data[i] = dataw;
|
|
7502
7510
|
|
|
7503
7511
|
scope[tableid] = dataw;
|
|
7512
|
+
|
|
7504
7513
|
// Reduce with ON and USING clause
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
source.onleftfn(scope, query.params, alasql)
|
|
7508
|
-
|
|
7509
|
-
|
|
7514
|
+
var usingPassed = !source.onleftfn;
|
|
7515
|
+
if (!usingPassed) {
|
|
7516
|
+
var left = source.onleftfn(scope, query.params, alasql);
|
|
7517
|
+
var right = source.onrightfn(scope, query.params, alasql);
|
|
7518
|
+
if (left instanceof String || left instanceof Number) left = left.valueOf();
|
|
7519
|
+
if (right instanceof String || right instanceof Number) right = left.valueOf();
|
|
7520
|
+
usingPassed = left == right;
|
|
7521
|
+
}
|
|
7522
|
+
|
|
7523
|
+
if (usingPassed) {
|
|
7510
7524
|
// For all non-standard JOINs like a-b=0
|
|
7511
7525
|
if (source.onmiddlefn(scope, query.params, alasql)) {
|
|
7512
7526
|
// Recursively call new join
|
|
@@ -11901,11 +11915,12 @@ alasql.aggr.MEDIAN = function (v, s, stage) {
|
|
|
11901
11915
|
return r[p - 1];
|
|
11902
11916
|
}
|
|
11903
11917
|
|
|
11904
|
-
|
|
11905
|
-
|
|
11918
|
+
var value = r[Math.floor(p - 1)];
|
|
11919
|
+
if (typeof value !== 'number' && !(value instanceof Number)) {
|
|
11920
|
+
return value;
|
|
11906
11921
|
}
|
|
11907
11922
|
|
|
11908
|
-
return (
|
|
11923
|
+
return (value + r[Math.ceil(p - 1)]) / 2;
|
|
11909
11924
|
}
|
|
11910
11925
|
};
|
|
11911
11926
|
|
|
@@ -17023,6 +17038,7 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
|
|
|
17023
17038
|
alasql.into.XLSX = function (filename, opts, data, columns, cb) {
|
|
17024
17039
|
/** @type {number} result */
|
|
17025
17040
|
var res = 1;
|
|
17041
|
+
opts = opts || {};
|
|
17026
17042
|
|
|
17027
17043
|
if (deepEqual(columns, [{columnid: '_'}])) {
|
|
17028
17044
|
data = data.map(function (dat) {
|
|
@@ -17040,6 +17056,7 @@ alasql.into.XLSX = function (filename, opts, data, columns, cb) {
|
|
|
17040
17056
|
|
|
17041
17057
|
/* If called without filename, use opts */
|
|
17042
17058
|
if (typeof filename == 'object') {
|
|
17059
|
+
// todo: check if data, clumns and cb also should be shifted.
|
|
17043
17060
|
opts = filename;
|
|
17044
17061
|
filename = undefined;
|
|
17045
17062
|
}
|
package/dist/alasql.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v0.6.
|
|
1
|
+
//! AlaSQL v0.6.4-develop-2311b55fundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 0.6.
|
|
4
|
+
@version 0.6.4-develop-2311b55fundefined
|
|
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.6.
|
|
145
|
+
alasql.version = '0.6.4-develop-2311b55fundefined';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -4014,6 +4014,14 @@ var cloneDeep = (utils.cloneDeep = function cloneDeep(obj) {
|
|
|
4014
4014
|
return new Date(obj);
|
|
4015
4015
|
}
|
|
4016
4016
|
|
|
4017
|
+
if (obj instanceof String) {
|
|
4018
|
+
return obj.toString();
|
|
4019
|
+
}
|
|
4020
|
+
|
|
4021
|
+
if (obj instanceof Number) {
|
|
4022
|
+
return +obj;
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4017
4025
|
var temp = obj.constructor(); // changed
|
|
4018
4026
|
|
|
4019
4027
|
for (var key in obj) {
|
|
@@ -7496,12 +7504,18 @@ function doJoin(query, scope, h) {
|
|
|
7496
7504
|
if (!opt && source.getfn && !source.dontcache) data[i] = dataw;
|
|
7497
7505
|
|
|
7498
7506
|
scope[tableid] = dataw;
|
|
7507
|
+
|
|
7499
7508
|
// Reduce with ON and USING clause
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
source.onleftfn(scope, query.params, alasql)
|
|
7503
|
-
|
|
7504
|
-
|
|
7509
|
+
var usingPassed = !source.onleftfn;
|
|
7510
|
+
if (!usingPassed) {
|
|
7511
|
+
var left = source.onleftfn(scope, query.params, alasql);
|
|
7512
|
+
var right = source.onrightfn(scope, query.params, alasql);
|
|
7513
|
+
if (left instanceof String || left instanceof Number) left = left.valueOf();
|
|
7514
|
+
if (right instanceof String || right instanceof Number) right = left.valueOf();
|
|
7515
|
+
usingPassed = left == right;
|
|
7516
|
+
}
|
|
7517
|
+
|
|
7518
|
+
if (usingPassed) {
|
|
7505
7519
|
// For all non-standard JOINs like a-b=0
|
|
7506
7520
|
if (source.onmiddlefn(scope, query.params, alasql)) {
|
|
7507
7521
|
// Recursively call new join
|
|
@@ -11896,11 +11910,12 @@ alasql.aggr.MEDIAN = function (v, s, stage) {
|
|
|
11896
11910
|
return r[p - 1];
|
|
11897
11911
|
}
|
|
11898
11912
|
|
|
11899
|
-
|
|
11900
|
-
|
|
11913
|
+
var value = r[Math.floor(p - 1)];
|
|
11914
|
+
if (typeof value !== 'number' && !(value instanceof Number)) {
|
|
11915
|
+
return value;
|
|
11901
11916
|
}
|
|
11902
11917
|
|
|
11903
|
-
return (
|
|
11918
|
+
return (value + r[Math.ceil(p - 1)]) / 2;
|
|
11904
11919
|
}
|
|
11905
11920
|
};
|
|
11906
11921
|
|
|
@@ -17018,6 +17033,7 @@ alasql.into.XLSXML = function (filename, opts, data, columns, cb) {
|
|
|
17018
17033
|
alasql.into.XLSX = function (filename, opts, data, columns, cb) {
|
|
17019
17034
|
/** @type {number} result */
|
|
17020
17035
|
var res = 1;
|
|
17036
|
+
opts = opts || {};
|
|
17021
17037
|
|
|
17022
17038
|
if (deepEqual(columns, [{columnid: '_'}])) {
|
|
17023
17039
|
data = data.map(function (dat) {
|
|
@@ -17035,6 +17051,7 @@ alasql.into.XLSX = function (filename, opts, data, columns, cb) {
|
|
|
17035
17051
|
|
|
17036
17052
|
/* If called without filename, use opts */
|
|
17037
17053
|
if (typeof filename == 'object') {
|
|
17054
|
+
// todo: check if data, clumns and cb also should be shifted.
|
|
17038
17055
|
opts = filename;
|
|
17039
17056
|
filename = undefined;
|
|
17040
17057
|
}
|