Skip to content

Commit

Permalink
Worker + SQL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agershun committed Jan 9, 2015
1 parent e5cb66b commit a2c8b1c
Show file tree
Hide file tree
Showing 122 changed files with 54,462 additions and 1,775 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

### 0.0.37 "Ararat" (09.01.2015 - .01.2015)

* Added test for "? IN @(?)"
* Convert -> correct DATE("20141008")
* TRUNCATE TABLE table;
* Fixed bug when COUNT and SUM() aggregators shows 'undefined' with zero groups
* test-sql tests: world.sql, speedtest.sql
* SELECT TEXT -> SELECT TEXTSTRING (do not conflict with TEXT data type)
* Fixed bug: different databases for different FROM and JOIN parts

### 0.0.36 "New Year version" (23.12.2014 - 08.01.2015)

Expand Down Expand Up @@ -30,7 +39,7 @@
* IF expr statement
* OBJECT_ID(tableid) function
* IS NULL and IS NOT NULL operators
* SET variable value (ON/OFF)
* SET option value (ON/OFF)
* OVER PARTITION ORDER BY syntax
* SET option ON/OFF (alasql.options.autocommit)
* SUM(DISTINCT a)
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Alasql.js - pure JavaScript client-side SQL database with support of localStorage and IndexedDB
# Alasql.js - JavaScript SQL database library with support of localStorage, IndexedDB, and Excel

Version: 0.0.36 Date: January 08, 2014 [Change log](CHANGELOG.md), [Release plan](RELEASES.md)
Version: 0.0.37 "Ararat" Date: January 09, 2014 [Change log](CHANGELOG.md), [Release plan](RELEASES.md)

Alasql - '[à la SQL](http://en.wiktionary.org/wiki/%C3%A0_la)' - is a lightweight JavaScript SQL database designed to work in browser and Node.js. It supports traditional SQL with some NoSQL functionality. Current version of Alasql can work in memory or use IndexedDB and localStorage as a persistent storage.

Expand Down Expand Up @@ -644,5 +644,9 @@ and other people for useful tools, which make our work much easier.

## License

(c) 2014, Andrey Gershun (agershun@gmail.com), [MIT licence information](LICENSE)
[MIT licence information](LICENSE).

The MIT license on this repo covers all contents of the repo, but does not supercede the existing licenses for products used for this work, including the Chinook Database (covered by the Microsoft Public License) and other products.

(c) 2014, Andrey Gershun (agershun@gmail.com),

17 changes: 8 additions & 9 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,42 @@

## Next Releases:

### Version "Ararat" 0.0.37 (20.01.2015)
### Version "Armenia" 0.0.40 (20.01.2015)

* SQL Tests
* T-SQL compatibility and multiple SQL Tests
* Documentation
* API documentation with JsDoc
* Multiple COUNT bug
* CSV bug and headers
* If-then-else JISON problem
* UNION ORDER BY bug
* WorkerJS for Node (primarily for test)

### Version "Sigirya" 0.0.40 (01.02.2015)
### Version "Sigirya" 0.0.45 (01.02.2015)

* packege.json
* Constraint and Foreign Keys
* CONTINUE/BREAK/FOR/LOOP

### Version "Elbrus" 0.0.45 (10.02.2015)
### Version "Elbrus" 0.0.50 (10.02.2015)

* Transactions

### Version "Prague" 0.0.50 (20.02.2015)
### Version "Prague" 0.0.55 (20.02.2015)

* PIVOT/UNPIVOT
* CROSS APPLY/OUTER APPLY
* VIEWS

### Version "Manila" 0.0.55 (01.03.2015)
### Version "Manila" 0.0.60 (01.03.2015)

* GROUP BY HIERARCHY, TOTAL, DETAIL

### Version "Menlo Park" 0.0.60 (10.03.2015)
### Version "Menlo Park" 0.0.65 (10.03.2015)

* Bugs
* Documentation

### Version "Vorkuta" 0.0.65 (20.03.2015)
### Version "Vorkuta" 0.0.70 (20.03.2015)

* Bugs
* Documentation
Expand Down
27 changes: 27 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@

## Next Versions

* DECLARE @var type = expression;
* DECLARE @var type, @var type...


0. MS SQL compatibility
* ROW_NUMBER() aggregator
* BEGIN TRAN, COMMIT TRAN
* N'string'
* DECLARE @var TABLE(coldefs)
* Database names starting with #
* INSERT INTO @aaa(cols) VALUES ()...
* COALESCE() - http://msdn.microsoft.com/en-us/library/ms190349.aspx
* DB_ID(databaseid)
* CREATE INDEX syntax
* SET IDENTITY_INSERT table ON;
* NUMERIC(a,b) data type and CONVERSION, MONEY, SMALLINT, BIGINT, NVARCHAR(MAX), DECIMAL(a,b)
* CREATE VIEW
* SYSDATETIME(), DATEADD(), DATEDIFF(), RIGHT(), LEFT(), CHAR(), ASCII(), ABS(), NEWID(), SUBSTRING()
* CONSTRAINT CHECK(expression)
* SET NOCOUNT OFF
* WITH (Select) AS Literal, ... Select

BIG
* OVER
* PIVOT
* CROSS APPLY

1. SET a->b = 10;
2. Fluent interface
3. Break Continue Loop
Expand Down
70 changes: 50 additions & 20 deletions alasql-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,65 @@ function alasql(sql,params,cb){
alasql.webworker.postMessage({id:id,sql:sql,params:params});
};

alasql.lastid = 0;
alasql.buffer = {};
// alasql.lastid = 0;
// alasql.buffer = {};
/**
Run webworker
*/
var path;
var sc = document.getElementsByTagName('script');
for(var i=0;i<sc.length;i++) {
if (sc[i].src.substr(-16).toLowerCase() == 'alasql-worker.js') {
path = sc[i].src.substr(0,sc[i].src.length-16)+'alasql.min.js';
break;

alasql.worker = function(path, paths, cb) {
// var path;
if(typeof path == "undefined" || path === true) {
var sc = document.getElementsByTagName('script');
for(var i=0;i<sc.length;i++) {
if (sc[i].src.substr(-16).toLowerCase() == 'alasql-worker.js') {
path = sc[i].src.substr(0,sc[i].src.length-16)+'alasql.min.js';
break;
}
}
}
}
if(typeof path == "undefined") {
throw new Error('Path to alasql.js is not specified');
} else if(path !== false) {
alasql.lastid = 0;
alasql.buffer = {};

if(typeof path == "undefined") {
throw new Error('Path to alasql.js is not specified');
};
var js = "importScripts('";
js += path;
js+="');\
self.onmessage = function(event) {\
alasql(event.data.sql,event.data.params, function(data){\
postMessage({id:event.data.id, data:data});\
});\
}";

alasql.webworker = new Worker(path);
var blob = new Blob([js], {"type": "text\/plain"});
alasql.webworker = new Worker(URL.createObjectURL(blob));

alasql.webworker.onmessage = function(event) {
var id = event.data.id;
alasql.buffer[id](event.data.data);
delete alasql.buffer[id];
};
alasql.webworker.onmessage = function(event) {
var id = event.data.id;
alasql.buffer[id](event.data.data);
delete alasql.buffer[id];
};

alasql.webworker.onerror = function(e){
throw e;
alasql.webworker.onerror = function(e){
throw e;
}

if(arguments.length > 1) {
var sql = 'REQUIRE ' + paths.map(function(p){
return '"'+p+'"';
}).join(",");
alasql(sql,[],cb);
}

} else if(path === false) {
delete alasql.webworker;
return;
}
}

alasql.worker();

return alasql;
}));
1,196 changes: 640 additions & 556 deletions alasql.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

70 changes: 50 additions & 20 deletions console/alasql-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,65 @@ function alasql(sql,params,cb){
alasql.webworker.postMessage({id:id,sql:sql,params:params});
};

alasql.lastid = 0;
alasql.buffer = {};
// alasql.lastid = 0;
// alasql.buffer = {};
/**
Run webworker
*/
var path;
var sc = document.getElementsByTagName('script');
for(var i=0;i<sc.length;i++) {
if (sc[i].src.substr(-16).toLowerCase() == 'alasql-worker.js') {
path = sc[i].src.substr(0,sc[i].src.length-16)+'alasql.min.js';
break;

alasql.worker = function(path, paths, cb) {
// var path;
if(typeof path == "undefined" || path === true) {
var sc = document.getElementsByTagName('script');
for(var i=0;i<sc.length;i++) {
if (sc[i].src.substr(-16).toLowerCase() == 'alasql-worker.js') {
path = sc[i].src.substr(0,sc[i].src.length-16)+'alasql.min.js';
break;
}
}
}
}
if(typeof path == "undefined") {
throw new Error('Path to alasql.js is not specified');
} else if(path !== false) {
alasql.lastid = 0;
alasql.buffer = {};

if(typeof path == "undefined") {
throw new Error('Path to alasql.js is not specified');
};
var js = "importScripts('";
js += path;
js+="');\
self.onmessage = function(event) {\
alasql(event.data.sql,event.data.params, function(data){\
postMessage({id:event.data.id, data:data});\
});\
}";

alasql.webworker = new Worker(path);
var blob = new Blob([js], {"type": "text\/plain"});
alasql.webworker = new Worker(URL.createObjectURL(blob));

alasql.webworker.onmessage = function(event) {
var id = event.data.id;
alasql.buffer[id](event.data.data);
delete alasql.buffer[id];
};
alasql.webworker.onmessage = function(event) {
var id = event.data.id;
alasql.buffer[id](event.data.data);
delete alasql.buffer[id];
};

alasql.webworker.onerror = function(e){
throw e;
alasql.webworker.onerror = function(e){
throw e;
}

if(arguments.length > 1) {
var sql = 'REQUIRE ' + paths.map(function(p){
return '"'+p+'"';
}).join(",");
alasql(sql,[],cb);
}

} else if(path === false) {
delete alasql.webworker;
return;
}
}

alasql.worker();

return alasql;
}));
16 changes: 8 additions & 8 deletions console/alasql.min.js

Large diffs are not rendered by default.

70 changes: 50 additions & 20 deletions dist/alasql-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,65 @@ function alasql(sql,params,cb){
alasql.webworker.postMessage({id:id,sql:sql,params:params});
};

alasql.lastid = 0;
alasql.buffer = {};
// alasql.lastid = 0;
// alasql.buffer = {};
/**
Run webworker
*/
var path;
var sc = document.getElementsByTagName('script');
for(var i=0;i<sc.length;i++) {
if (sc[i].src.substr(-16).toLowerCase() == 'alasql-worker.js') {
path = sc[i].src.substr(0,sc[i].src.length-16)+'alasql.min.js';
break;

alasql.worker = function(path, paths, cb) {
// var path;
if(typeof path == "undefined" || path === true) {
var sc = document.getElementsByTagName('script');
for(var i=0;i<sc.length;i++) {
if (sc[i].src.substr(-16).toLowerCase() == 'alasql-worker.js') {
path = sc[i].src.substr(0,sc[i].src.length-16)+'alasql.min.js';
break;
}
}
}
}
if(typeof path == "undefined") {
throw new Error('Path to alasql.js is not specified');
} else if(path !== false) {
alasql.lastid = 0;
alasql.buffer = {};

if(typeof path == "undefined") {
throw new Error('Path to alasql.js is not specified');
};
var js = "importScripts('";
js += path;
js+="');\
self.onmessage = function(event) {\
alasql(event.data.sql,event.data.params, function(data){\
postMessage({id:event.data.id, data:data});\
});\
}";

alasql.webworker = new Worker(path);
var blob = new Blob([js], {"type": "text\/plain"});
alasql.webworker = new Worker(URL.createObjectURL(blob));

alasql.webworker.onmessage = function(event) {
var id = event.data.id;
alasql.buffer[id](event.data.data);
delete alasql.buffer[id];
};
alasql.webworker.onmessage = function(event) {
var id = event.data.id;
alasql.buffer[id](event.data.data);
delete alasql.buffer[id];
};

alasql.webworker.onerror = function(e){
throw e;
alasql.webworker.onerror = function(e){
throw e;
}

if(arguments.length > 1) {
var sql = 'REQUIRE ' + paths.map(function(p){
return '"'+p+'"';
}).join(",");
alasql(sql,[],cb);
}

} else if(path === false) {
delete alasql.webworker;
return;
}
}

alasql.worker();

return alasql;
}));
Loading

0 comments on commit a2c8b1c

Please sign in to comment.