Skip to content

Commit

Permalink
Merge branch 'release/0.0.48'
Browse files Browse the repository at this point in the history
  • Loading branch information
agershun committed Apr 19, 2015
2 parents e06a149 + b4f9dd8 commit 6951162
Show file tree
Hide file tree
Showing 37 changed files with 5,663 additions and 18,472 deletions.
4 changes: 2 additions & 2 deletions bower.json → .bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alasql",
"description":"JavaScript SQL database library",
"version": "0.0.38",
"description":"AlaSQL - JavaScript SQL database library",
"version": "0.0.48",
"license": "MIT",
"keywords": ["javascript","sql","database","indexeddb","excel","localstorage"],
"authors": ["Andrey Gershun <[email protected]>"],
Expand Down
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
alacon.js text eol=lf
alaserver.js text eol=lf

alasql.js binary
alasql.js.map binary
alasql.min.js binary

*.xlsx binary
*.xls binary
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### 0.0.48 "Amsterdam" (18.04.2015 - 19.04.2015)
* Fixed bug indexedDB.webGetDatabaseNames in Firefox
* Some bugs from Sqllogictest fixed (see test258)
* Bower package registered
* Fixed CASE bonding query to this error

### 0.0.47 "Antalya" (16.04.2015 - 18.04.2015)
* Added CORRESPONDING keyword to the grammas
* Fixed export to Excel - with data types
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AlaSQL.js - JavaScript SQL database library with support of localStorage, IndexedDB, and Excel

Version: 0.0.47 "Antalya" Date: April 18, 2015 [Change log](CHANGELOG.md), [Release plan](RELEASES.md)
Version: 0.0.48 "Amsterdam" Date: April 19, 2015 [Change log](CHANGELOG.md), [Release plan](RELEASES.md)

Please use [AlaSQL Forum](https://groups.google.com/d/forum/alasql) for discussions or [Issues](https://github.com/agershun/alasql/issues) to report bugs.

Expand Down
861 changes: 448 additions & 413 deletions alasql.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions console/alasql.min.js

Large diffs are not rendered by default.

21,817 changes: 4,310 additions & 17,507 deletions dist/alasql.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/alasql.js.map

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions dist/alasql.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alasql",
"description": "AlaSQL - JavaScript SQL database and data manipulation library",
"version": "0.0.47",
"version": "0.0.48",
"author": "Andrey Gershun <[email protected]>",
"directories": {
"example": "examples",
Expand Down
4 changes: 2 additions & 2 deletions src/05copyright.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//
// alasql.js
// AlaSQL - JavaScript SQL database
// Date: 16.04.2015
// Version: 0.0.47
// Date: 19.04.2015
// Version: 0.0.48
// (ñ) 2014-2015, Andrey Gershun
//

Expand Down
2 changes: 1 addition & 1 deletion src/10start.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ var alasql = function(sql, params, cb, scope) {
};

/** Current version of alasql */
alasql.version = "0.0.47";
alasql.version = "0.0.48";

3 changes: 3 additions & 0 deletions src/38query.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Main query procedure
function queryfn(query,oldscope,cb, A,B) {

// console.log(query.queriesfn);

var ms;
query.sourceslen = query.sources.length;
var slen = query.sourceslen;
Expand Down
2 changes: 2 additions & 0 deletions src/39dojoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ function doJoin (query, scope, h) {
if(query.groupfn) {
query.groupfn(scope, query.params, query.alasql)
} else {
// query.qwerty = 999;
//console.log(query.qwerty, query.queriesfn && query.queriesfn.length,2);
query.data.push(query.selectfn(scope, query.params, alasql));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/40select.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ yy.Select.prototype.toJavaScript = function(context, tableid, defcols) {
// return this.expression.toJavaScript(context, tableid, defcols);
// console.log('Select.toJS', 81, this.queriesidx);
// var s = 'this.queriesdata['+(this.queriesidx-1)+'][0]';
//console.log(this);

var s = 'alasql.utils.flatArray(this.queriesfn['+(this.queriesidx-1)+'](this.params,null,'+context+'))[0]';
// s = '(console.log(this.queriesfn[0]),'+s+')';

Expand Down
5 changes: 3 additions & 2 deletions src/41exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ yy.Select.prototype.compileQueries = function(query) {
});
};

//
// Prepare subqueries and exists
//
alasql.precompile = function(statement,databaseid,params){
// console.log(statement);
if(!statement) return;
Expand All @@ -48,6 +51,4 @@ alasql.precompile = function(statement,databaseid,params){
return ex.compile(databaseid || statement.database.databaseid);
});
};


}
7 changes: 6 additions & 1 deletion src/423groupby.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
yy.Select.prototype.compileGroup = function(query) {
// console.log(this.group);
var self = this;
var tableid = query.sources[0].alias;
if(query.sources.length > 0) {
var tableid = query.sources[0].alias;
} else {
// If SELECT contains group aggregators without source tables
var tableid = '';
}
var defcols = query.defcols;
// console.log(16,tableid, defcols);

Expand Down
2 changes: 1 addition & 1 deletion src/424select.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ yy.Select.prototype.compileSelect1 = function(query) {
}
yy.Select.prototype.compileSelect2 = function(query) {

var s = query.selectfns ;
var s = query.selectfns;
// console.log(s);
return new Function('p,params,alasql',s+'return r');
};
Expand Down
2 changes: 1 addition & 1 deletion src/50expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ yy.ExpressionStatement.prototype.execute = function (databaseid, params, cb) {
if(this.expression) {
// console.log(this.expression.toJavaScript('','', null));
// console.log(this.expression.toJavaScript('','', null));
var expr = new Function("params,alasql,p",'return '+this.expression.toJavaScript('','', null));
var expr = new Function("params,alasql,p",'return '+this.expression.toJavaScript('({})','', null));
var res = expr(params,alasql);
if(cb) res = cb(res);
return res;
Expand Down
3 changes: 2 additions & 1 deletion src/55functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ stdlib.MID = function(a,b,c){
else if(arguments.length == 3) return '('+a+').substr('+b+'-1,'+c+')';
};

stdlib.NULLIF = function(a,b){return '('+a+'=='+b+'?null:'+a+')'};
// Here we uses undefined instead of null
stdlib.NULLIF = function(a,b){return '('+a+'=='+b+'?undefined:'+a+')'};

stdlib.POWER = function(a,b) {return 'Math.pow('+a+','+b+')'};

Expand Down
8 changes: 5 additions & 3 deletions src/57case.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ yy.CaseValue.prototype.findAggregator = function (query){
if(w.when.findAggregator) w.when.findAggregator(query);
if(w.then.findAggregator) w.then.findAggregator(query);
});
}
};
if(this.elses && this.elses.findAggregator) this.elses.findAggregator(query);
};

yy.CaseValue.prototype.toJavaScript = function(context, tableid, defcols) {

var s = '(function('+context+',params,alasql){var r;';
var s = '((function('+context+',params,alasql){var r;';
if(this.expression) {
// this.expression.toJavaScript(context, tableid)
s += 'v='+this.expression.toJavaScript(context, tableid, defcols)+';';
Expand All @@ -43,7 +44,8 @@ yy.CaseValue.prototype.toJavaScript = function(context, tableid, defcols) {
+') {r='+w.then.toJavaScript(context,tableid, defcols)+'}'; }).join(' else ');
if(this.elses) s += ' else {r='+this.elses.toJavaScript(context,tableid,defcols)+'}';
}
s += 'return r;})('+context+',params,alasql)';
// TODO remove bind from CASE
s += ';return r;}).bind(this))('+context+',params,alasql)';

return s;
};
6 changes: 4 additions & 2 deletions src/65createindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ yy.CreateIndex.prototype.toString = function() {
}

// CREATE TABLE
yy.CreateIndex.prototype.execute = function (databaseid) {
yy.CreateIndex.prototype.execute = function (databaseid,params,cb) {
// var self = this;
var db = alasql.databases[databaseid];
var tableid = this.table.tableid;
Expand Down Expand Up @@ -55,7 +55,9 @@ yy.CreateIndex.prototype.execute = function (databaseid) {
}
}
};

var res = 1;
if(cb) res = cb(res);
return res;
};


6 changes: 4 additions & 2 deletions src/68if.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ yy.If.prototype.toString = function() {
yy.If.prototype.execute = function (databaseid,params,cb){
var res;
// console.log(this);
// console.log(this.expression.toJavaScript());
var fn = new Function('params,alasql,p','return '+this.expression.toJavaScript()).bind(this);
// console.log(this.expression.toJavaScript('{}','',null));
// console.log();
var fn = new Function('params,alasql,p','return '+this.expression.toJavaScript('({})','',null)).bind(this);
// var fn = new Function('params,alasql,p','console.log(this.thenstat);return '+this.expression.toJavaScript('({})','',null)).bind(this);
if(fn(params,alasql)) res = this.thenstat.execute(databaseid,params,cb);
else {
if(this.elsestat) res = this.elsestat.execute(databaseid,params,cb);
Expand Down
2 changes: 1 addition & 1 deletion src/77declare.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ yy.Declare.prototype.execute = function (databaseid,params,cb) {
if(declare.expression) {
// console.log(this.expression.toJavaScript('','', null));
alasql.vars[declare.variable] = new Function("params,alasql","return "
+declare.expression.toJavaScript('','', null))(params,alasql);
+declare.expression.toJavaScript('({})','', null))(params,alasql);
if(alasql.declares[declare.variable]) {
alasql.vars[declare.variable] = alasql.stdfn.CONVERT(alasql.vars[declare.variable],alasql.declares[declare.variable]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/79set.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ yy.SetVariable.prototype.execute = function (databaseid,params,cb) {
} else if(this.expression) {
// console.log(this.expression.toJavaScript('','', null));
var res = new Function("params,alasql","return "
+this.expression.toJavaScript('','', null))(params,alasql);
+this.expression.toJavaScript('({})','', null))(params,alasql);
if(alasql.declares[this.variable]) {
res = alasql.stdfn.CONVERT(res,alasql.declares[this.variable]);
}
Expand Down
98 changes: 47 additions & 51 deletions src/alasqlparser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ NOT\s+LIKE return 'NOT_LIKE'
'TABLES' return 'TABLES'
'TARGET' return 'TARGET'
'TD' return 'TD'
'TEMP' return 'TEMP'
'TEMPORARY' return 'TEMPORARY'
'TEXTSTRING' return 'TEXTSTRING'
'TH' return 'TH'
'THEN' return 'THEN'
Expand Down Expand Up @@ -532,8 +534,14 @@ IntoClause
FromClause
: FROM FromTablesList
{ $$ = { from: $2 }; }
| FROM FromTable JoinTablesList
/* | FROM FromTable JoinTablesList
{ $$ = { from: [$2], joins: $3 }; }
*/ | FROM FromTablesList JoinTablesList
{ $$ = { from: $2, joins: $3 }; }
/* | FROM LPAR FromTable JoinTablesList RPAR
{ $$ = { from: [$3], joins: $4 }; }
*/ | FROM LPAR FromTablesList JoinTablesList RPAR
{ $$ = { from: $3, joins: $4 }; }
|
{ $$ = undefined; }
;
Expand Down Expand Up @@ -1370,26 +1378,21 @@ ColumnsList
/* CREATE TABLE */

CreateTable
/*
: CREATE TemporaryClause TABLE IfNotExists Table LPAR CreateTableDefClause RPAR CreateTableOptionsClause
*/
: CREATE TABLE IfNotExists Table LPAR CreateTableDefClause RPAR CreateTableOptionsClause
{
$$ = new yy.CreateTable({table:$4});
//yy.extend($$,$2);
yy.extend($$,$3);
yy.extend($$,$6);
$$ = new yy.CreateTable({table:$5});
yy.extend($$,$2);
yy.extend($$,$4);
yy.extend($$,$7);
yy.extend($$,$9);
}
| CREATE TABLE IfNotExists Table
{
$$ = new yy.CreateTable({table:$4});
}
/* | CREATE TABLE IfNotExists Literal DOT Literal
| CREATE TemporaryClause TABLE IfNotExists Table
{
$$ = new yy.CreateTable({table:new yy.Table({tableid:$6, databaseid:$4})});
$$ = new yy.CreateTable({table:$5});
yy.extend($$,$2);
yy.extend($$,$4);
}
*/ ;
;

CreateTableOptionsClause
:
Expand Down Expand Up @@ -1508,6 +1511,18 @@ ColsList
{ $$ = $1; $1.push($3); }
;

/*
OrderedColsList
: Literal
{ $$ = [$1]; }
| STRING
{ $$ = [$1]; }
| OrderedColsList COMMA Literal
{ $$ = $1; $1.push($3); }
| OrderedColsList COMMA STRING
{ $$ = $1; $1.push($3); }
;
*/
ColumnDefsList
: ColumnDef
{ $$ = [$1];}
Expand Down Expand Up @@ -1664,9 +1679,9 @@ DropDatabase
/* INDEXES */

CreateIndex
: CREATE INDEX Literal ON Table LPAR ColsList RPAR
: CREATE INDEX Literal ON Table LPAR OrderExpressionsList RPAR
{ $$ = new yy.CreateIndex({indexid:$3, table:$5, columns:$7})}
| CREATE UNIQUE INDEX Literal ON Table LPAR ColsList RPAR
| CREATE UNIQUE INDEX Literal ON Table LPAR OrderExpressionsList RPAR
{ $$ = new yy.CreateIndex({indexid:$4, table:$6, columns:$8, unique:true})}
;

Expand Down Expand Up @@ -1721,48 +1736,25 @@ ShowCreateTable
;

CreateView

: CREATE VIEW IfNotExists Table LPAR ColumnsList RPAR AS Select
{
$$ = new yy.CreateTable({table:$4,view:true,select:$9,viewcolumns:$6});
yy.extend($$,$3);
: CREATE TemporaryClause VIEW IfNotExists Table LPAR ColumnsList RPAR AS Select
{
$$ = new yy.CreateTable({table:$5,view:true,select:$10,viewcolumns:$7});
yy.extend($$,$2);
yy.extend($$,$4);
}
| CREATE VIEW IfNotExists Table AS Select
| CREATE TemporaryClause VIEW IfNotExists Table AS Select
{
$$ = new yy.CreateTable({table:$4,view:true,select:$6});
$$ = new yy.CreateTable({table:$5,view:true,select:$7});
yy.extend($$,$2);
yy.extend($$,$4);
}
;
/*
: CREATE VIEW IfNotExists View AS Select
{ $$ = new yy.CreateTable({table:new yy.Table({tableid:$4}), view:true, select: $5}); }
| CREATE VIEW View LPAR ColsList RPAR AS Select
{ $$ = new yy.CreateTable({table:new yy.Table({tableid:$4}),view:true, select: $5}); }
;
| CREATE TABLE IfNotExists Literal
{
$$ = new yy.CreateTable({table:new yy.Table({tableid:$4})});
}
| CREATE TABLE IfNotExists Literal DOT Literal
{
$$ = new yy.CreateTable({table:new yy.Table({tableid:$6, databaseid:$4})});
}
;
*/

DropView
: DROP VIEW IfExists Table
{ $$ = new yy.DropTable({table:$4, view:true}); yy.extend($$, $3); }
;
/*
View
: Literal
{ $$ = new yy.View({viewid: $1}); }
| Literal DOT Literal
{ $$ = new yy.View({databaseid:$1, viewid: $3}); }
;
*/
/*
DeclareCursor
: DECLARE Literal CURSOR FOR Select
{ $$ = new yy.DeclareCursor({cursorid:$2, select:$5}); }
Expand Down Expand Up @@ -1998,7 +1990,11 @@ If
}

| IF Expression AStatement
{ $$ = new yy.If({expression:$2,thenstat:$3}); }
{
$$ = new yy.If({expression:$2,thenstat:$3});
if($3.exists) $$.exists = $3.exists;
if($3.queries) $$.queries = $3.queries;
}
;

ElseStatement
Expand Down
Loading

0 comments on commit 6951162

Please sign in to comment.