Skip to content

Commit

Permalink
Merge branch 'release/0.3.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasrw committed Nov 9, 2016
2 parents 77e2178 + da87745 commit 5add0f2
Show file tree
Hide file tree
Showing 28 changed files with 18,367 additions and 18,358 deletions.
22 changes: 15 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Changelog


_0.3.4 "....." (xx.11.2016)_
_0.3.5 "Maiao" (xx.12.2016)_
* ...



### 0.3.4 "Fitii" (09.11.2016)
* Added: trigger `AFTER DELETE`
* Fix: `TRUNCATE TABLE` now works for local storage DB
* Fix: `JOIN` a sub select
* Removed: The `HELP` command (to save space)


### 0.3.3 "Makemo" (13.10.2016)
* Add: support for VALUE inside checks
* Add: Conflate null and undefined
* Add: Load CSV data from a string
* Add: Warn when server side uses browser build of lib
* Add: support for VALUE inside checks
* Add: Conflate null and undefined
* Add: Load CSV data from a string
* Add: Warn when server side uses browser build of lib
* Update: typescript definition for native import
* Update: filesaver.js updated to 1.3.2


### 0.3.2 "Maumu" (05.09.2016)
* Added: Postgres arrays like array[] and text[]
Expand Down
56 changes: 29 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ _Got a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask?


[![Build status](https://api.travis-ci.org/agershun/alasql.svg)](https://travis-ci.org/agershun/alasql?123)
[![NPM downloads](http://img.shields.io/npm/dm/alasql.svg?style=flat&label=npm%20downloads)](https://npmjs.org/package/alasql?)
[![NPM downloads](http://img.shields.io/npm/dm/alasql.svg?style=flat&label=npm%20downloads)](https://npm-stat.com/charts.html?package=alasql)
[![ghit.me](https://ghit.me/badge.svg?repo=agershun/alasql)](https://ghit.me/repo/agershun/alasql)
![Release](https://img.shields.io/github/release/agershun/alasql.svg?label=Last%20release&a)
![Stars](https://img.shields.io/github/stars/agershun/alasql.svg?label=Github%20%E2%98%85&a)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/agershun/alasql.svg)](http://isitmaintained.com/project/agershun/alasql "Average time to resolve an issue")
[![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)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/328/badge)](https://bestpractices.coreinfrastructure.org/projects/328)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/agershun/alasql.svg)](http://isitmaintained.com/project/agershun/alasql "Average time to resolve an issue")

<div align="center"><a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/19309516/94f8007e-9085-11e6-810f-62fd60b42185.png" alt="AlaSQL logo" styl="max-width:80%"/></a>
</div>



Expand All @@ -22,6 +19,11 @@ _Got a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask?

_( [à la](http://en.wiktionary.org/wiki/%C3%A0_la) [SQL](http://en.wikipedia.org/wiki/SQL) ) [ælæ ɛskju:ɛl]_ - AlaSQL is a free and open source SQL database for Javascript with a strong focus on query speed and datasource flexibility for relational data, schemaless data, and graph data. It works in your browser, Node.js, IO.js and Cordova.

<div align="center"><a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/19309516/94f8007e-9085-11e6-810f-62fd60b42185.png" alt="AlaSQL logo" styl="max-width:80%"/></a>
</div>



The library is designed for:

* Fast SQL data processing in-memory for BI and ERP applications on fat clients
Expand Down Expand Up @@ -434,17 +436,17 @@ AlaSQL extends "good old" SQL to make it closer to JavaScript. The "sugar" inclu
### localStorage and DOM-storage
### localStorage and DOM-storage (experimental)
You can use browser localStorage and [DOM-storage](https://github.com/node-browser-compat/dom-storage) as a data storage. Here is a sample:
```
alasql('CREATE localStorage DATABASE IF NOT EXISTS Atlas');
alasql('ATTACH localStorage DATABASE Atlas AS MyAtlas');
alasql('CREATE TABLE IF NOT EXISTS MyAtlas.City (city string, population number)');
alasql('SELECT * INTO MyAtlas.City FROM ?',[[{city:'Vienna', population:1731000},
```js
alasql('CREATE localStorage DATABASE IF NOT EXISTS Atlas');
alasql('ATTACH localStorage DATABASE Atlas AS MyAtlas');
alasql('CREATE TABLE IF NOT EXISTS MyAtlas.City (city string, population number)');
alasql('SELECT * INTO MyAtlas.City FROM ?',[[{city:'Vienna', population:1731000},
{city:'Budapest', population:1728000}]]);
var res = alasql('SELECT * FROM MyAtlas.City');
console.log(res);
var res = alasql('SELECT * FROM MyAtlas.City');
console.log(res);
```
Try this sample in [jsFiddle](http://jsfiddle.net/agershun/x1gq3wf2/). Run this sample
Expand All @@ -455,21 +457,22 @@ You can use localStorage in two modes: SET AUTOCOMMIT ON to immediate save data
to localStorage after each statement or SET AUTOCOMMIT OFF. In this case you need
to use COMMIT statement to save all data from in-memory mirror to localStorage.
### Work with CSV, TAB, TXT, and JSON files
You can use files in these formats directly from AlaSQL (in sync and async modes):
### CSV, TAB, TXT, and JSON files
You can import from and export to CSV, TAB, TXT, and JSON files directly from AlaSQL. Calls to files will always be [[async]] so the approach is to chain the queries if you have more than one:
```js
var res1 = alasq("select * from txt('mytext.txt') where [0] like 'M%'");
var res2 = alasq("select * from tab('mydata.tab') order by [1]");
var res3 = alasq("select [3] as city,[4] as population from csv('cities.csv')");
alasq("select * from json('array.json')",[],function(res4){
console.log(res4)
});
var tabFile = 'mydata.tab'
alasql.promise([
"select * from txt('mytext.txt') where [0] like 'M%'",
["select * from tab(?) order by [1]", [tabFile]], // note how to pass parameter when promises are chained
"select [3] as city,[4] as population from csv('cities.csv')",
"select * from json('array.json')"
]).then(function(results){
console.log(results)
}).catch(console.error)
```
See [test157.js](test/test157.js) as an example.
### JSON-object
You can use JSON objects in your databases (do not forget use == and !== operators for deep comparision of objects):
Expand Down Expand Up @@ -579,15 +582,14 @@ Please be aware that AlaSQL ~~may~~ have [bugs](https://github.com/agershun/alas
0. At the moment Alasql does not work with jszip 3.0.0 - please use version 2.x
0. At the moment Alasql is incompatible with xlsx.js 0.8 on the website - please use version [7.x](https://cdnjs.com/libraries/xlsx/0.7.12) by using `<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.7.12/xlsx.core.min.js"></script>` on your website
Probably, there are many of others. Please, help us to fix them by [submitting it as an issue](https://github.com/agershun/alasql/issues). Thank you!
## Bleeding edge
If you want to try the last development version of the library please download [this file](https://github.com/agershun/alasql/blob/develop/dist/alasql.fs.js) or visit the [testbench](https://rawgit.com/agershun/alasql/develop/utils/testbench.html) to play around in the browser console.
If you want to try the last development version of the library please download [this file](https://github.com/agershun/alasql/blob/develop/dist/alasql.fs.js) or visit the [testbench](https://rawgit.com/agershun/alasql/develop/test/testbench.html) to play around in the browser console.
## Tests
Expand Down Expand Up @@ -644,7 +646,7 @@ MIT - see [MIT licence information](LICENSE)
* [Mathias Rangel Wulff](https://twitter.com/rangelwulff)
* [Aubert Grégoire](https://github.com/gregaubert)
[![Throughput Graph](https://graphs.waffle.io/agershun/alasql/throughput.svg)](https://waffle.io/agershun/alasql/metrics/throughput)
<!--[![Throughput Graph](https://graphs.waffle.io/agershun/alasql/throughput.svg)](https://waffle.io/agershun/alasql/metrics/throughput)-->
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.3"
"version": "0.3.4"
}
47 changes: 45 additions & 2 deletions console/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,62 @@ <h1>AlaSQL - JavaScript SQL database console</h1>
<p>This is a demo console for AlaSQL javascript database. Read more information and documentation on
<a href="https://github.com/agershun/alasql">https://github.com/agershun/alasql</a></p>

<p>Type <b>HELP</b> for the list of commands.</p>

<p>Enter <b>SOURCE 'world.sql'</b> to load sample database, then <b>SHOW TABLES</b>, and then <b>SELECT TOP 10 * FROM City</b>. Then enter <b>SELECT VALUE COUNT(*) FROM TXT('world.sql') WHERE LEN([0])>20</b> to count number of lines with length more than 20 characters</p>





<div id='myconsole'></div>



<p>
<tt></tt><span id="useid">alasql</span> &gt;</tt> <input id='myprompt' autofocus/>
<tt><span id="useid">alasql</span> &gt;</tt> <input id='myprompt' autofocus/>
</p>


<p><center><button onClick="showHelp()">Show list of commands</button></center></p>

<script>
var first = decodeURI(location.search.substr(1));
alasql.options.logtarget = 'myconsole';
alasql.prompt('myprompt','useid');
alasql.prompt('myprompt','useid', first);


function showHelp(){
alasql.log([
{command:'ALTER TABLE table RENAME TO table'},
{command:'ALTER TABLE table ADD COLUMN column coldef'},
{command:'ALTER TABLE table MODIFY COLUMN column coldef'},
{command:'ALTER TABLE table RENAME COLUMN column TO column'},
{command:'ALTER TABLE table DROP column'},
{command:'ATTACH engine DATABASE database'},
{command:'ASSERT value'},
{command:'CREATE [engine] DATABASE [IF NOT EXISTS] database'},
{command:'CREATE TABLE [IF NOT EXISTS] table (column definitions)'},
{command:'DELETE FROM table [WHERE expression]'},
{command:'DETACH DATABASE database'},
{command:'DROP [engine] DATABASE [IF EXISTS] database'},
{command:'DROP TABLE [IF EXISTS] table'},
{command:'INSERT INTO table VALUES value,...'},
{command:'INSERT INTO table DEFAULT VALUES'},
{command:'INSERT INTO table SELECT select'},
{command:'SELECT [modificator] columns [INTO table] [FROM table,...] [[mode] JOIN [ON] [USING]] [WHERE ] [GROUP BY] [HAVING] [ORDER BY] '},
{command:'SET option value'},
{command:'SHOW [engine] DATABASES'},
{command:'SHOW TABLES'},
{command:'SHOW CREATE TABLE table'},
{command:'UPDATE table SET column1 = expression1, ... [WHERE expression]'},
{command:'USE [DATABASE] database'},
{command:'See <a href="http://github/agershun/alasql">http://github/agershun/alasql</a> for more information'}
])
}



</script>


Expand Down
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.3 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
//! AlaSQL v0.3.4 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
/*
@module alasql
@version 0.3.3
@version 0.3.4
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,636 changes: 803 additions & 833 deletions dist/alasql.fs.js

Large diffs are not rendered by default.

1,636 changes: 803 additions & 833 deletions dist/alasql.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions dist/alasql.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ gulp.task('js-merge', function () {
'./src/84from.js',
'./src/843xml.js',
'./src/844gexf.js',
'./src/85help.js',
// './src/85help.js',
'./src/86print.js',
'./src/87source.js',
'./src/88require.js',
Expand Down
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": "Versatile SQL database for browser or node. Handles relational data and nested JSON (noSQL). Export to and import from Excel, localStorage or IndexedDB",
"version": "0.3.3",
"version": "0.3.4",
"author": "Andrey Gershun <[email protected]>",
"contributors": [
{
Expand Down
13 changes: 0 additions & 13 deletions src/60createtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,19 +506,6 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
table.uniqs[uk.hh][ukaddr]=undefined;
});
}

// Trigger prevent functionality
for(var tr in table.afterdelete) {
var trigger = table.afterdelete[tr];
if(trigger) {
if(trigger.funcid) {
alasql.fn[trigger.funcid](r);
} else if(trigger.statement) {
trigger.statement.execute(databaseid);
}
}
};

};

table.deleteall = function() {
Expand Down
13 changes: 13 additions & 0 deletions src/72delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ yy.Delete.prototype.compile = function (databaseid) {
}
// table.data = table.data.filter(function(r){return !;});
table.data = newtable;

// Trigger prevent functionality
for(var tr in table.afterdelete) {
var trigger = table.afterdelete[tr];
if(trigger) {
if(trigger.funcid) {
alasql.fn[trigger.funcid]();
} else if(trigger.statement) {
trigger.statement.execute(databaseid);
}
}
};

var res = orignum - table.data.length;
if(alasql.options.autocommit && db.engineid && db.engineid == 'LOCALSTORAGE') {
alasql.engines[db.engineid].saveTableData(databaseid,tableid);
Expand Down
6 changes: 4 additions & 2 deletions src/85help.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// NOT included when building

/*
//
// HELP for Alasql.js
Expand Down Expand Up @@ -43,7 +45,7 @@ var helpdocs = [
{command:'UPDATE table SET column1 = expression1, ... [WHERE expression]'},
{command:'USE [DATABASE] database'},
{command:'expression'},
{command:'See also <a href="http://github/agershun/alasq">http://github/agershun/alasq</a> for more information'}
{command:'See also <a href="http://github/agershun/alasql">http://github/agershun/alasql</a> for more information'}
];

// execute
Expand All @@ -52,7 +54,7 @@ yy.Help.prototype.execute = function (databaseid, params, cb) {
if(!this.subject) {
ss = helpdocs;
} else {
ss.push('See also <a href="http://github/agershun/alasq">http://github/agershun/alasq</a> for more information');
ss.push('See also <a href="http://github/agershun/alasql">http://github/agershun/alasql</a> for more information');
}
if(cb) ss = cb(ss);
return ss;
Expand Down
Loading

0 comments on commit 5add0f2

Please sign in to comment.