Skip to content

Commit 73c6f8c

Browse files
committed
Merge branch 'release/0.3.2'
2 parents 52036c0 + 07b9027 commit 73c6f8c

34 files changed

+3669
-2909
lines changed

CHANGELOG.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
# Changelog
2-
* Check https://trello.com/b/qxz65pVi/alasql-roadmap for roadmap
3-
4-
_0.3.2 "..." (18.08.2016)_
52

6-
* ...
3+
_0.3.3 "Makemo" (16.09.2016)_
4+
* ...
5+
6+
7+
### 0.3.2 "Maumu" (05.09.2016)
8+
* Added: Postgres arrays like array[] and text[]
9+
* Added: Allow non-reserved keywords as identifiers
10+
* Fix: tsv/csv can now be is an empty file
11+
* Fix: alasql.d.ts format
12+
* Fix: Better way to find out if indexedDB is present
13+
* Fix: `null = null` is (now) null, baby.
14+
* Update: Column names first for RECORDSETS
15+
716

817
### 0.3.1 "Taravao" (01.08.2016)
9-
* Allow unknown functions to be defined on alasql.fn afterwards
10-
* Easy access to AUTOINCREMENT values
11-
* MEDIAN will ignore null values
12-
* STDEV will ignore null values
18+
* Allow unknown functions to be defined on alasql.fn afterwards
19+
* Easy access to AUTOINCREMENT values
20+
* MEDIAN will ignore null values
21+
* STDEV will ignore null values
1322

1423

15-
## Version 0.3.0 "Papeete" (25.07.2016)_
24+
## Version 0.3.0 "Papeete" (25.07.2016)
1625
* Breaking change: CSVs with header will now default have BOM added (for better utf8 support)
1726
* Added: Constraint names will now be exported in error message
1827
* Added: Web worker now supports .promise notation
@@ -32,7 +41,6 @@ _0.3.2 "..." (18.08.2016)_
3241

3342

3443
### 0.2.6 "Frikes" (22.04.2016)
35-
3644
* Added: Progress callback
3745
* Change: CLI defaults to pretty print (with option for compressed output as original)
3846
* Fix: Declaring all variables

TESTLOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ It has not yet been possible to run the SQLlogic tests on the Chrakra engine.
2222

2323

2424
## Regression test
25-
The [regression tests for AlaSQL](https://github.com/agershun/alasql/tree/develop/test/) consists of more than 1000 test cases (hopefully) covering all of the functionality in the library. By executing `npm run test:only` the regression test will run via node. By executing `npm run test:browser` it will run in a browser.
25+
The [regression tests for AlaSQL](https://github.com/agershun/alasql/tree/develop/test/) consists of more than 1000 test casescovering [![Coverage]( https://img.shields.io/codecov/c/github/agershun/alasql/develop.svg)](https://rawgit.com/agershun/alasql/develop/test/coverage/lcov-report/dist/alasql.fs.js.html) of the functionality in the library. By executing `npm run test:only` the regression test will run via node. By executing `npm run test:browser` it will run in a browser.
2626

2727

2828
### Chrome 48

bin/alasql-cli.js

Lines changed: 97 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,141 @@
11
#!/usr/bin/env node
2-
//
2+
//
33
// Command line interface for Alasql
44
// Version: 0.2.2
55
// Date: 28.07.2015
66
// (c) 2014-2015, Andrey Gershun & M. Rangel Wulff
77
//
88

9-
var alasql = require('alasql');
10-
var path = require('path');
11-
var fs = require('fs');
12-
var yargs = require('yargs')
13-
.demand(1)
9+
let alasql = require('alasql');
10+
let path = require('path');
11+
let fs = require('fs');
12+
let stdin = process.openStdin();
13+
let yargs = require('yargs')
1414
.strict()
15-
.usage('AlaSQL command-line utility (version '+alasql.version+')\n\nUsage: $0 [options] [sql] [params]')
16-
17-
.example('$0 "sql-statement"', 'Run SQL statement and output result as JSON')
18-
.example('')
19-
.example('$0 \'value of select 2+?\' 40', 'Outputs 42')
20-
.example('')
15+
.usage('AlaSQL command-line utility (version ' + alasql.version + ')\n\nUsage: $0 [options] [sql] [params]')
16+
17+
.example('$0 "sql-statement"', 'Run SQL statement and output result as JSON')
18+
.example('')
19+
.example('$0 \'value of select 2+?\' 40', 'Outputs 42')
20+
.example('')
2121
.example('$0 \'select count(*) from txt()\' < city.txt', 'Count lines in city.txt')
22-
.example('')
22+
.example('')
2323
.example('$0 \'select * into xlsx("city.xlsx") from txt("city.txt")\'', 'Convert from txt to xlsx')
24-
.example('')
25-
.example('$0 --file file.sql France 1960', 'Run SQL from file with 2 parameters')
26-
27-
.version('v', 'Echo AlaSQL version', alasql.version)
28-
.alias('v', 'version')
24+
.example('')
25+
.example('$0 --file file.sql France 1960', 'Run SQL from file with 2 parameters')
26+
27+
.version('v', 'Echo AlaSQL version', alasql.version)
28+
.alias('v', 'version')
2929

30-
.boolean('m')
31-
.describe('m', 'Minify json output')
32-
.alias('m', 'minify')
30+
.boolean('m')
31+
.describe('m', 'Minify json output')
32+
.alias('m', 'minify')
3333

34-
.describe('f', 'Load SQL from file')
35-
.alias('f', 'file')
36-
.nargs('f', 1)
37-
.normalize('f')
34+
.describe('f', 'Load SQL from file')
35+
.alias('f', 'file')
36+
.nargs('f', 1)
37+
.normalize('f')
3838

39-
.help('h')
40-
.alias('h', 'help')
39+
.help('h')
40+
.alias('h', 'help')
4141

42-
.epilog('\nMore information about the library: www.alasql.org')
43-
var argv = yargs.argv;
44-
var sql = '';
45-
var params = [];
42+
.epilog('\nMore information about the library: www.alasql.org')
4643

44+
let argv = yargs.argv;
45+
let sql = '';
46+
let params = [];
47+
let pipedData = ''
48+
stdin.on('data', function (chunk) {
49+
pipedData += chunk;
50+
});
4751

48-
if(argv.v) {
49-
console.log(alasql.version);
52+
if (argv.v) {
53+
console.log(alasql.version);
5054
process.exit(0);
5155
}
5256

53-
if(argv.f) {
57+
if (argv.f) {
5458
if (!fs.existsSync(argv.f)) {
55-
console.log('Error: file not found');
59+
console.error('Error: file not found');
5660
process.exit(1);
57-
}
61+
}
5862

5963
if (isDirectory(argv.f)) {
60-
console.log('Error: file expected but directory found');
64+
console.error('Error: file expected but directory found');
6165
process.exit(1);
6266
}
6367

6468
sql = fs.readFileSync(argv.f, 'utf8').toString();
69+
execute(sql, argv._);
70+
6571
} else {
6672
sql = argv._.shift() || '';
73+
74+
// if data is not piped
75+
if (Boolean(process.stdin.isTTY)) {
76+
execute(sql, argv._);
77+
}
6778
}
6879

69-
params = argv._;
80+
// if data is piped
81+
stdin.on('end', function () {
82+
execute(pipedData, argv._);
83+
});
7084

71-
if(0===sql.trim().length){
72-
yargs.showHelp();
73-
process.exit(1);
74-
}
85+
/**
86+
* Execute SQL query
87+
*
88+
* @sql {String} SQL query
89+
* @param {String} Parameters
90+
* @returns {null} Result will be printet to console.log
91+
*/
92+
function execute(sql, params) {
7593

76-
for(var i=1;i<params.length;i++) {
77-
var a = params[i];
78-
if(a[0] !== '"' && a[0] !== "'") {
79-
if(+a == a){ // jshint ignore:line
80-
params[i] = +a;
81-
}
94+
if (0 === sql.trim().length) {
95+
console.error("\nNo SQL to process\n");
96+
yargs.showHelp();
97+
process.exit(1);
8298
}
83-
}
8499

85-
alasql.promise(sql,params)
86-
.then(function(res){
87-
if(!alasql.options.stdout){
88-
console.log(formatOutput(res));
100+
for (var i = 1; i < params.length; i++) {
101+
var a = params[i];
102+
if (a[0] !== '"' && a[0] !== "'") {
103+
if (+a == a) { // jshint ignore:line
104+
params[i] = +a;
105+
}
89106
}
90-
process.exit(0);
91-
}).catch(function(err){
92-
console.log(formatOutput({error:err}));
93-
process.exit(1);
94-
});
107+
}
95108

109+
alasql.promise(sql, params)
110+
.then(function (res) {
111+
if (!alasql.options.stdout) {
112+
console.log(formatOutput(res));
113+
}
114+
process.exit(0);
115+
}).catch(function (err) {
116+
let errorJsonObj = JSON.parse(JSON.stringify(err, Object.getOwnPropertyNames(err)));
117+
console.error(formatOutput({
118+
error: errorJsonObj
119+
}));
120+
process.exit(1);
121+
});
122+
}
96123

97124
/**
98-
* Is a Directory
125+
* Is this padh a Directory
99126
*
100127
* @param {String} filePath
101128
* @returns {Boolean}
102129
*/
103-
function isDirectory(filePath){
104-
var isDir = false;
105-
try {
106-
var absolutePath = path.resolve(filePath);
107-
isDir = fs.lstatSync(absolutePath).isDirectory();
108-
} catch (e) {
109-
isDir = e.code === 'ENOENT';
110-
}
111-
return isDir;
130+
function isDirectory(filePath) {
131+
var isDir = false;
132+
try {
133+
var absolutePath = path.resolve(filePath);
134+
isDir = fs.lstatSync(absolutePath).isDirectory();
135+
} catch (e) {
136+
isDir = e.code === 'ENOENT';
137+
}
138+
return isDir;
112139
}
113140

114141

@@ -118,12 +145,9 @@ function isDirectory(filePath){
118145
* @param {Object} Object to be formatted according to -p flag
119146
* @returns {JSON string}
120147
*/
121-
function formatOutput(obj){
122-
if(argv.m){
148+
function formatOutput(obj) {
149+
if (argv.m) {
123150
return JSON.stringify(obj);
124151
}
125152
return JSON.stringify(obj, null, 2);
126153
}
127-
128-
129-

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@
5858
"bin",
5959
"lib"
6060
],
61-
"version": "0.3.1"
61+
"version": "0.3.2"
6262
}

dist/alasql-worker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! AlaSQL v0.3.1 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
1+
//! AlaSQL v0.3.2 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
22
/*
33
@module alasql
4-
@version 0.3.1
4+
@version 0.3.2
55
66
AlaSQL - JavaScript SQL database
77
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff

dist/alasql-worker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/alasql.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ declare namespace alaSQLSpace {
7373
promise(sql: any, params?: any): Thenable<any>;
7474
fn: userDefinedFunctionLookUp;
7575
aggr: userAggregatorLookUp;
76-
autoval(tablename: string, colname: string, getNext=:boolean): number;
76+
autoval(tablename: string, colname: string, getNext?:boolean): number;
7777
}
7878
}
7979

dist/alasql.fs.js

Lines changed: 1115 additions & 931 deletions
Large diffs are not rendered by default.

dist/alasql.js

Lines changed: 1114 additions & 930 deletions
Large diffs are not rendered by default.

dist/alasql.min.js

Lines changed: 15 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)