Skip to content

Commit

Permalink
Merge branch 'release/0.0.49'
Browse files Browse the repository at this point in the history
  • Loading branch information
agershun committed Apr 21, 2015
2 parents 6951162 + b20540f commit bc39ec9
Show file tree
Hide file tree
Showing 25 changed files with 2,240 additions and 1,747 deletions.
2 changes: 1 addition & 1 deletion .bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alasql",
"description":"AlaSQL - JavaScript SQL database library",
"version": "0.0.48",
"version": "0.0.49",
"license": "MIT",
"keywords": ["javascript","sql","database","indexeddb","excel","localstorage"],
"authors": ["Andrey Gershun <agershun@gmail.com>"],
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

### 0.0.49 "Beijing" (19.04.2015 - 21.04.2015)
* CREATE CLASS
* INSERT INTO class
* INSERT INTO class returns inserted value
* # operator
* Classes support
* Tests with SEARCH syntax and tests for CREATE EDGE and CREATE VERTES
* Fixed bug with leaking to global.key

### 0.0.48 "Amsterdam" (18.04.2015 - 19.04.2015)
* Fixed bug indexedDB.webGetDatabaseNames in Firefox
* Some bugs from Sqllogictest fixed (see test258)
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.48 "Amsterdam" Date: April 19, 2015 [Change log](CHANGELOG.md), [Release plan](RELEASES.md)
Version: 0.0.49 "Иушоштп" Date: April 21, 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
1,203 changes: 636 additions & 567 deletions alasql.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

1,203 changes: 636 additions & 567 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.

17 changes: 9 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.48",
"version": "0.0.49",
"author": "Andrey Gershun <agershun@gmail.com>",
"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: 19.04.2015
// Version: 0.0.48
// Date: 21.04.2015
// Version: 0.0.49
// (ñ) 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.48";
alasql.version = "0.0.49";

2 changes: 1 addition & 1 deletion src/15utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ var deepEqual = utils.deepEqual = function (x, y) {
*/
var extend = utils.extend = function extend (a,b){
if(typeof a == 'undefined') a = {};
for(key in b) {
for(var key in b) {
if(b.hasOwnProperty(key)) {
a[key] = b[key]
}
Expand Down
4 changes: 4 additions & 0 deletions src/20database.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ var Database = alasql.Database = function (databaseid) {
self.tables = {};
self.views = {};

// Objects storage
self.objects = {};
self.counter = 0;

self.indices = {};
// self.fn = {};
self.resetSqlCache();
Expand Down
1 change: 1 addition & 0 deletions src/23table.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

// Table class
var Table = alasql.Table = function(params){

// Columns
this.columns = [];
this.xcolumns = {};
Expand Down
11 changes: 9 additions & 2 deletions src/50expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ yy.Op.prototype.toString = function() {
if(this.allsome) {
return this.left.toString()+" "+P(this.op)+" "+this.allsome+' ('+this.right.toString()+')';
}
if(this.op == '->') {
var s = this.left.toString()+"->";
if(this.op == '->' || this.op == '#') {
var s = this.left.toString()+this.op;
// console.log(this.right);
if(typeof this.right != 'string' && typeof this.right != 'number' ) s += '(';
s += this.right.toString();
Expand Down Expand Up @@ -172,6 +172,13 @@ yy.Op.prototype.toJavaScript = function(context,tableid,defcols) {
} else {
return this.left.toJavaScript(context,tableid, defcols)+'['+this.right.toJavaScript(context,tableid, defcols)+']';
}
};

if(this.op == '#') {
if(typeof this.right == "string") {
return 'alasql.databases[alasql.useid].objects['+this.left.toJavaScript(context,tableid, defcols)+']["'+this.right+'"]';
}
// TODO - add other cases
}

if(this.op == 'IS') {
Expand Down
7 changes: 6 additions & 1 deletion src/60createtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ yy.CreateTable.prototype.toString = function() {
var s = K('CREATE');
if(this.temporary) s+=' '+K('TEMPORARY');
if(this.view) s += ' '+K('VIEW');
else s += ' '+K('TABLE');
else s += ' '+(this.class?K('CLASS'):K('TABLE'));
if(this.ifnotexists) s += ' '+K('IF')+' '+K('NOT')+' '+K('EXISTS');
s += ' '+this.table.toString();
if(this.viewcolumns) {
Expand Down Expand Up @@ -77,6 +77,11 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {

var table = db.tables[tableid] = new alasql.Table(); // TODO Can use special object?

// If this is a class
if(this.class) {
table.isclass = true;
}

var ss = [];
if(this.columns) {
this.columns.forEach(function(col) {
Expand Down
36 changes: 34 additions & 2 deletions src/70insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ yy.Insert.prototype.toString = function() {
return s;
}

yy.Insert.prototype.toJavaScript = function(context, tableid, defcols) {
// console.log('Expression',this);
// if(this.expression.reduced) return 'true';
// return this.expression.toJavaScript(context, tableid, defcols);
// console.log('Select.toJS', 81, this.queriesidx);
// var s = 'this.queriesdata['+(this.queriesidx-1)+'][0]';

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

return s;
};

yy.Insert.prototype.compile = function (databaseid) {
var self = this;
databaseid = self.into.databaseid || databaseid
Expand All @@ -28,6 +42,7 @@ yy.Insert.prototype.compile = function (databaseid) {
var sw = '';
// var s = 'db.tables[\''+tableid+'\'].dirty=true;';
var s3 = 'var a,aa=[];';

var s33;


Expand Down Expand Up @@ -129,9 +144,18 @@ yy.Insert.prototype.compile = function (databaseid) {
} else {
s += 'a={'+ss.join(',')+'};';
}

// If this is a class
if(db.tables[tableid].isclass) {
s += 'var db=alasql.databases[\''+databaseid+'\'];';
s+= 'a.$class="'+tableid+'";';
s+= 'a.$id=db.counter++;';
s+= 'db.objects[a.$id]=a;';
};
// s += 'db.tables[\''+tableid+'\'].insert(r);';
if(db.tables[tableid].insert) {
s += 'alasql.databases[\''+databaseid+'\'].tables[\''+tableid+'\'].insert(a);';
s += 'var db=alasql.databases[\''+databaseid+'\'];';
s += 'db.tables[\''+tableid+'\'].insert(a);';
} else {
s += 'aa.push(a);';
}
Expand All @@ -146,7 +170,15 @@ yy.Insert.prototype.compile = function (databaseid) {
'alasql.databases[\''+databaseid+'\'].tables[\''+tableid+'\'].data.concat(aa);';
}

s += 'return '+self.values.length;
if(db.tables[tableid].insert) {
if(db.tables[tableid].isclass) {
s += 'return a.$id;';
} else {
s += 'return '+self.values.length;
}
} else {
s += 'return '+self.values.length;
}

//console.log(s);
var insertfn = new Function('db, params, alasql',s3+s);
Expand Down
14 changes: 13 additions & 1 deletion src/79set.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,21 @@ yy.SetVariable.prototype.execute = function (databaseid,params,cb) {
else if(val == 'OFF') val = false;
alasql.options[this.variable] = val;
} else if(this.expression) {

if(this.exists) {
this.existsfn = this.exists.map(function(ex) {
return ex.compile(databaseid);
});
}
if(this.queries) {
this.queriesfn = this.queries.map(function(q) {
return q.compile(databaseid);
});
}

// console.log(this.expression.toJavaScript('','', null));
var res = new Function("params,alasql","return "
+this.expression.toJavaScript('({})','', null))(params,alasql);
+this.expression.toJavaScript('({})','', null)).bind(this)(params,alasql);
if(alasql.declares[this.variable]) {
res = alasql.stdfn.CONVERT(res,alasql.declares[this.variable]);
}
Expand Down
Loading

0 comments on commit bc39ec9

Please sign in to comment.