Skip to content

Commit

Permalink
Merge branch 'release/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasrw committed Aug 1, 2016
2 parents d065c8a + 22d35f6 commit 52036c0
Show file tree
Hide file tree
Showing 31 changed files with 13,382 additions and 30,380 deletions.
18 changes: 14 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
# Changelog
* Check https://trello.com/b/qxz65pVi/alasql-roadmap for roadmap

_0.3.1 "..." (?.08.2016)_

* ...
_0.3.2 "..." (18.08.2016)_

* ...

### 0.3.1 "Taravao" (01.08.2016)
* Allow unknown functions to be defined on alasql.fn afterwards
* Easy access to AUTOINCREMENT values
* MEDIAN will ignore null values
* STDEV will ignore null values


## Version 0.3.0 "Papeete" (25.07.2016)_
* Breaking change: CSVs with header will now default have BOM added (for better utf8 support)
* Added: Constraint names will now be exported in error message
* Added: Constraint names will now be exported in error message
* Added: Web worker now supports .promise notation
* Added: Postgres-specific aliases and fixes
* Added: Make converting to an unknown type result in a noop rather than an error
* Added: Support column types consisting of more than 2 words


### 0.2.7 "Corinth" (30.05.2016)
* Added: Now supports Node 6.0
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ npm install -g alasql # command line
For the browser: include [alasql.min.js](http://cdn.jsdelivr.net/alasql/latest/alasql.min.js)

```html
<script src="http://cdn.jsdelivr.net/alasql/0.2/alasql.min.js"></script>
<script src="http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js"></script>
```


Expand Down Expand Up @@ -529,7 +529,7 @@ var IgnorePlugin = require("webpack").IgnorePlugin;
module.exports = {
...
//Will ignore the modules fs, path, xlsx, xls
plugins:[new IgnorePlugin(/(^fs$|xlsx|xls ... |^path$)/)]
plugins:[new IgnorePlugin(/(^fs$|cptable|jszip|xlsx|xls|^es6-promise$|^net$|^tls$|^forever-agent$|^tough-cookie$|cpexcel|^path$)/)]
};
```
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
"bin",
"lib"
],
"version": "0.3.0"
"version": "0.3.1"
}
4 changes: 2 additions & 2 deletions dist/alasql-worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! AlaSQL v0.3.0 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
//! AlaSQL v0.3.1 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
/*
@module alasql
@version 0.3.0
@version 0.3.1
AlaSQL - JavaScript SQL database
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
Expand Down
2 changes: 1 addition & 1 deletion dist/alasql-worker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/alasql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ declare namespace alaSQLSpace {
promise(sql: any, params?: any): Thenable<any>;
fn: userDefinedFunctionLookUp;
aggr: userAggregatorLookUp;
autoval(tablename: string, colname: string, getNext=:boolean): number;
}
}

Expand Down
115 changes: 77 additions & 38 deletions dist/alasql.fs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! AlaSQL v0.3.0 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
//! AlaSQL v0.3.1 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
/*
@module alasql
@version 0.3.0
@version 0.3.1

AlaSQL - JavaScript SQL database
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
Expand Down Expand Up @@ -140,7 +140,7 @@ var alasql = function(sql, params, cb, scope) {
Current version of alasql
@constant {string}
*/
alasql.version = '0.3.0';
alasql.version = '0.3.1';

/**
Debug flag
Expand Down Expand Up @@ -4292,6 +4292,26 @@ alasql.use = function (databaseid) {

};

alasql.autoval = function(tablename, colname, getNext, databaseid){

var db = databaseid?alasql.databases[databaseid]:alasql.databases[alasql.useid];

if(!db.tables[tablename]){
throw new Error('Tablename not found: '+tablename);
}

if(!db.tables[tablename].identities[colname]){
throw new Error('Colname not found: '+colname);
}

if(getNext){
return db.tables[tablename].identities[colname].value || null;
}

return (db.tables[tablename].identities[colname].value - db.tables[tablename].identities[colname].step) || null

}

/**
Run single SQL statement on current database
*/
Expand Down Expand Up @@ -4665,6 +4685,10 @@ Database.prototype.exec = function(sql, params, cb) {
return alasql.dexec(this.databaseid, sql, params, cb);
};

Database.prototype.autoval = function(tablename, colname, getNext) {
return alasql.autoval(tablename, colname, getNext, this.databaseid);
};

// Aliases like MS SQL

/*
Expand Down Expand Up @@ -6219,7 +6243,7 @@ function queryfn3(query) {
ilen=nd.data.length
for(var i=0;i<ilen;i++) {
var r = {};
for(var j=0,jlen=Math.min(query.columns.length,nd.columns.length);j<jlen;j++) {
for(var j=Math.min(query.columns.length,nd.columns.length)-1;0<=j;j--) {
r[query.columns[j].columnid] = nd.data[i][nd.columns[j].columnid];
}
ud.push(r);
Expand Down Expand Up @@ -6258,7 +6282,7 @@ function queryfn3(query) {
var ud = [];
for(var i=0,ilen=nd.data.length;i<ilen;i++) {
var r = {};
for(var j=0,jlen=Math.min(query.columns.length,nd.columns.length);j<jlen;j++) {
for(var j=Math.min(query.columns.length,nd.columns.length)-1;0<=j;j--) {
r[query.columns[j].columnid] = nd.data[i][nd.columns[j].columnid];
}
ud.push(r);
Expand Down Expand Up @@ -6424,7 +6448,9 @@ function doDistinct (query) {
uniq[uix] = query.data[i];
}
query.data = [];
for(var key in uniq) query.data.push(uniq[key]);
for(var key in uniq){
query.data.push(uniq[key]);
}
}
}

Expand Down Expand Up @@ -7145,7 +7171,7 @@ function modify(query, res) { // jshint ignore:line
// Try to create columns
if(res.length > 0) {
var allcol = {};
for(var i=0;i<Math.min(res.length,alasql.options.columnlookup||10);i++) {
for(var i=Math.min(res.length,alasql.options.columnlookup||10)-1;0<=i;i--) {
for(var key in res[i]) {
allcol[key] = true;
}
Expand Down Expand Up @@ -8903,7 +8929,8 @@ var rollup = function (a,query) {
var cube = function (a,query) {
var rr = [];
var glen = a.length;
for(var g=0;g<(1<<glen);g++) {
var glenCube = 1<<glen;
for(var g=0;g<(glenCube);g++) {
var ss = [];
for(var i=0;i<glen;i++) {
if(g&(1<<i)) //ss.push(a[i]);
Expand Down Expand Up @@ -10264,26 +10291,13 @@ yy.FuncValue.prototype.toJS = function(context, tableid, defcols) {
var s = '';
var funcid = this.funcid;
// IF this is standard compile functions
if(alasql.fn[funcid]) {
// This is user-defined run-time function
// TODO arguments!!!

if(this.newid) s+= 'new ';
s += 'alasql.fn.'+this.funcid+'(';

if(this.args && this.args.length > 0) {
s += this.args.map(function(arg){
return arg.toJS(context, tableid, defcols);
}).join(',');
};
s += ')';
} else if(alasql.stdlib[funcid.toUpperCase()]) {
if(!alasql.fn[funcid] && alasql.stdlib[funcid.toUpperCase()]) {
if(this.args && this.args.length > 0) {
s += alasql.stdlib[funcid.toUpperCase()].apply(this, this.args.map(function(arg) {return arg.toJS(context, tableid)}));
} else {
s += alasql.stdlib[funcid.toUpperCase()]();
}
} else if(alasql.stdfn[funcid.toUpperCase()]) {
} else if(!alasql.fn[funcid] && alasql.stdfn[funcid.toUpperCase()]) {
if(this.newid) s+= 'new ';
s += 'alasql.stdfn.'+this.funcid.toUpperCase()+'(';

Expand All @@ -10294,7 +10308,18 @@ yy.FuncValue.prototype.toJS = function(context, tableid, defcols) {
};
s += ')';
} else {
// Aggregator
// This is user-defined run-time function
// TODO arguments!!!

if(this.newid) s+= 'new ';
s += 'alasql.fn.'+this.funcid+'(';

if(this.args && this.args.length > 0) {
s += this.args.map(function(arg){
return arg.toJS(context, tableid, defcols);
}).join(',');
};
s += ')';
}

// if(this.alias) s += ' AS '+this.alias;
Expand Down Expand Up @@ -10412,22 +10437,34 @@ alasql.aggr.GROUP_CONCAT = function(v,s,stage){
// };

alasql.aggr.MEDIAN = function(v,s,stage){
if(stage == 1) {
return [v];
} else if(stage == 2) {
s.push(v);
return s;
} else {
var p = s.sort();
return p[(p.length/2)|0];
};
if(stage === 2) {
if(v === null){
return s;
}
s.push(v);
return s;
} else if(stage === 1) {
if(v === null){
return [];
}
return [v];
} else {
var p = s.sort();
return p[(p.length/2)|0];
};
};

// Standard deviation
alasql.aggr.VAR = function(v,s,stage){
if(stage == 1) {
if(stage === 1) {
if(v === null){
return {arr:[],sum:0};
}
return {arr:[v],sum:v};
} else if(stage == 2) {
} else if(stage === 2) {
if(v === null){
return s;
}
s.arr.push(v);
s.sum += v;
return s;
Expand All @@ -10444,7 +10481,7 @@ alasql.aggr.VAR = function(v,s,stage){
};

alasql.aggr.STDEV = function(v,s,stage){
if(stage == 1 || stage == 2 ) {
if(stage === 1 || stage === 2 ) {
return alasql.aggr.VAR(v,s,stage);
} else {
return Math.sqrt(alasql.aggr.VAR(v,s,stage));
Expand Down Expand Up @@ -15379,7 +15416,9 @@ function XLSXLSX(X,filename, opts, cb, idx, query) {
var row1 = +rg[1].match(/[0-9]+/)[0];

var hh = {};
for(var j=alasql.utils.xlscn(col0);j<=alasql.utils.xlscn(col1);j++){
var xlscnCol0 = alasql.utils.xlscn(col0);
var xlscnCol1 = alasql.utils.xlscn(col1);
for(var j=xlscnCol0;j<=xlscnCol1;j++){
var col = alasql.utils.xlsnc(j);
if(opt.headers) {
if(workbook.Sheets[sheetid][col+""+row0]) {
Expand All @@ -15397,7 +15436,7 @@ function XLSXLSX(X,filename, opts, cb, idx, query) {
}
for(var i=row0;i<=row1;i++) {
var row = {};
for(var j=alasql.utils.xlscn(col0);j<=alasql.utils.xlscn(col1);j++){
for(var j=xlscnCol0;j<=xlscnCol1;j++){
var col = alasql.utils.xlsnc(j);
if(workbook.Sheets[sheetid][col+""+i]) {
row[hh[col]] = workbook.Sheets[sheetid][col+""+i].v;
Expand Down
Loading

0 comments on commit 52036c0

Please sign in to comment.