Skip to content

Commit

Permalink
Merge branch 'release/0.0.50'
Browse files Browse the repository at this point in the history
  • Loading branch information
agershun committed Apr 22, 2015
2 parents bc39ec9 + 0391553 commit 2a02366
Show file tree
Hide file tree
Showing 28 changed files with 2,566 additions and 1,820 deletions.
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.50 "Seoul" (21.04.2015 - 22.04.2015)
* CREATE VERTEX and CREATE EDGE syntax
* Fixed MIN and MAX functions and aggregators #93
* Found UPDATE bug with column/columnid
* Fixed bug with valueOf in comparision

### 0.0.49 "Beijing" (19.04.2015 - 21.04.2015)
* CREATE CLASS
* INSERT INTO class
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.49 "Иушоштп" Date: April 21, 2015 [Change log](CHANGELOG.md), [Release plan](RELEASES.md)
Version: 0.0.50 "Seoul" Date: April 22, 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
18 changes: 18 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ This file contanis unstructured ideas for future development of Alasql.

## Ideas

### Graph Database

#### Edges & Vertices

SEARCH OUT(),OUTE(),OUTV() FROM ?
SEARCH OUT(Like,Love) FROM ?
SEARCH IN(),INE(),INV() FROM ?
SEARCH IN(Like,Love) FROM ?
SEARCH BOTH(),BOTHE(), BOTHV() FROM ?
SEARCH BOTH(Like,Love) FROM ?

???
SEARCH EXPAND(name) FROM Person; -- all people names
SEARCH FIRST(name) FROM Person; -- all people names
SEARCH LAST(name) FROM Person; -- all people names
SEARCH COUNT(name) FROM Person; -- count number of children



### Version "Sapsan" 0.0.40 (25.01.2015)

Expand Down
1,292 changes: 707 additions & 585 deletions alasql.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

1,292 changes: 707 additions & 585 deletions dist/alasql.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/alasql.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions dist/alasql.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,14 @@ gulp.task('js-merge', function () {
'./src/50expression.js',
'./src/52linq.js',
'./src/55functions.js',
'./src/56datetime.js',
// './src/56sprintf.js',
'./src/57case.js',
'./src/58json.js',
'./src/59convert.js',
'./src/60createtable.js',
'./src/61date.js',
'./src/62droptable.js',
'./src/63createvertex.js',
'./src/64altertable.js',
'./src/65createindex.js',
'./src/66dropindex.js',
Expand Down
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@
"example": "examples",
"test": "test"
},
"devDependencies": {},
"devDependencies": {
"dom-storage":"2.0.1",
"gulp":"3.8.11",
"gulp-changed":"1.2.1",
"gulp-concat-sourcemap":"1.3.1",
"gulp-shell":"0.4.1",
"jison":"0.4.15",
"lodash":"3.7.0",
"xlsjs":"0.7.15",
"xlsx":"0.8.0"
},
"engines": [
"node"
],
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: 21.04.2015
// Version: 0.0.49
// Date: 22.04.2015
// Version: 0.0.50
// (ñ) 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.49";
alasql.version = "0.0.50";

8 changes: 4 additions & 4 deletions src/426orderby.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ yy.Select.prototype.compileOrder = function (query) {
// COLLATE NOCASE
if(ord.nocase) dg += '.toUpperCase()';

s += 'if(a[\''+columnid+"']"+dg+(ord.direction == 'ASC'?'>':'<')+'b[\''+columnid+"']"+dg+')return 1;';
s += 'if(a[\''+columnid+"']"+dg+'==b[\''+columnid+"']"+dg+'){';
s += 'if((a[\''+columnid+"']||'')"+dg+(ord.direction == 'ASC'?'>':'<')+'(b[\''+columnid+"']||'')"+dg+')return 1;';
s += 'if((a[\''+columnid+"']||'')"+dg+'==(b[\''+columnid+"']||'')"+dg+'){';

} else {
dg = '.valueOf()';
// COLLATE NOCASE
if(ord.nocase) dg += '.toUpperCase()';
s += 'if('+ord.toJavaScript('a','')+dg+(ord.direction == 'ASC'?'>':'<')+ord.toJavaScript('b','')+dg+')return 1;';
s += 'if('+ord.toJavaScript('a','')+dg+'=='+ord.toJavaScript('b','')+dg+'){';
s += 'if(('+ord.toJavaScript('a','')+"||'')"+dg+(ord.direction == 'ASC'?'>(':'<(')+ord.toJavaScript('b','')+"||'')"+dg+')return 1;';
s += 'if(('+ord.toJavaScript('a','')+"||'')"+dg+'==('+ord.toJavaScript('b','')+"||'')"+dg+'){';
}

// if(columnid == '_') {
Expand Down
4 changes: 2 additions & 2 deletions src/55functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ stdlib.LOWER = stdlib.LCASE = function(s) {return '('+s+').toLowerCase()';}

// LTRIM

stdlib.GREATEST = function(){
stdlib.MAX = stdlib.GREATEST = function(){
return 'Math.max('+Array.prototype.join.call(arguments, ',')+')'
};

stdlib.LEAST = function(){
stdlib.MIN = stdlib.LEAST = function(){
return 'Math.min('+Array.prototype.join.call(arguments, ',')+')'
};

Expand Down
6 changes: 0 additions & 6 deletions src/56datetime.js

This file was deleted.

144 changes: 144 additions & 0 deletions src/56sprintf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/**
* SPRINTF(format, argument_list)
*
* The string function like one in C/C++, PHP, Perl
* Each conversion specification is defined as below:
*
* %[index][alignment][padding][width][precision]type
*
* index An optional index specifier that changes the order of the
* arguments in the list to be displayed.
* alignment An optional alignment specifier that says if the result should be
* left-justified or right-justified. The default is
* right-justified; a "-" character here will make it left-justified.
* padding An optional padding specifier that says what character will be
* used for padding the results to the right string size. This may
* be a space character or a "0" (zero character). The default is to
* pad with spaces. An alternate padding character can be specified
* by prefixing it with a single quote ('). See the examples below.
* width An optional number, a width specifier that says how many
* characters (minimum) this conversion should result in.
* precision An optional precision specifier that says how many decimal digits
* should be displayed for floating-point numbers. This option has
* no effect for other types than float.
* type A type specifier that says what type the argument data should be
* treated as. Possible types:
*
* % - a literal percent character. No argument is required.
* b - the argument is treated as an integer, and presented as a binary number.
* c - the argument is treated as an integer, and presented as the character
* with that ASCII value.
* d - the argument is treated as an integer, and presented as a decimal number.
* u - the same as "d".
* f - the argument is treated as a float, and presented as a floating-point.
* o - the argument is treated as an integer, and presented as an octal number.
* s - the argument is treated as and presented as a string.
* x - the argument is treated as an integer and presented as a hexadecimal
* number (with lowercase letters).
* X - the argument is treated as an integer and presented as a hexadecimal
* number (with uppercase letters).
* h - the argument is treated as an integer and presented in human-readable format
* using powers of 1024.
* H - the argument is treated as an integer and presented in human-readable format
* using powers of 1000.
*/

stdfn.SPRINTF = function() {
var args = arguments;
var index = 0;

var x;
var ins;
var fn;

/*
* The callback function accepts the following properties
* x.index contains the substring position found at the origin string
* x[0] contains the found substring
* x[1] contains the index specifier (as \d+\$ or \d+#)
* x[2] contains the alignment specifier ("+" or "-" or empty)
* x[3] contains the padding specifier (space char, "0" or defined as '.)
* x[4] contains the width specifier (as \d*)
* x[5] contains the floating-point precision specifier (as \.\d*)
* x[6] contains the type specifier (as [bcdfosuxX])
*/
return args[0].replace(stdfn.SPRINTF.re, function()
{
if ( arguments[0] == "%%" ) {
return "%";
}

x = [];
for (var i = 0; i < arguments.length; i++) {
x[i] = arguments[i] || '';
}
x[3] = x[3].slice(-1) || ' ';

ins = args[+x[1] ? x[1] - 1 : index++];
// index++;

return alasql.stdfn.SPRINTF[x[6]](ins, x);
});
};

stdfn.SPRINTF.re = /%%|%(?:(\d+)[\$#])?([+-])?('.|0| )?(\d*)(?:\.(\d+))?([bcdfosuxXhH])/g;

stdfn.SPRINTF.b = function(ins, x)
{
return Number(ins).bin(x[2] + x[4], x[3]);
};
stdfn.SPRINTF.c = function(ins, x)
{
return String.fromCharCode(ins).padding(x[2] + x[4], x[3]);
};
stdfn.SPRINTF.d =
stdfn.SPRINTF.u = function(ins, x)
{
return Number(ins).radix(0x0A,x[2] + x[4], x[3]);
};
stdfn.SPRINTF.f = function(ins, x)
{
var ins = Number(ins);
// var fn = String.prototype.padding;
if (x[5]) {
ins = ins.toFixed(x[5]);
} else if (x[4]) {
ins = ins.toExponential(x[4]);
} else {
ins = ins.toExponential();
}
// Invert sign because this is not number but string
x[2] = x[2] == "-" ? "+" : "-";
return ins.padding(x[2] + x[4], x[3]);
// return fn.call(ins, x[2] + x[4], x[3]);
};
stdfn.SPRINTF.o = function(ins, x)
{
return Number(ins).oct(x[2] + x[4], x[3]);
};
stdfn.SPRINTF.s = function(ins, x)
{
return String(ins).padding(x[2] + x[4], x[3]);
};
stdfn.SPRINTF.x = function(ins, x)
{
return Number(ins).hexl(x[2] + x[4], x[3]);
};
stdfn.SPRINTF.X = function(ins, x)
{
return Number(ins).hex(x[2] + x[4], x[3]);
};
stdfn.SPRINTF.h = function(ins, x)
{
var ins = String.prototype.replace.call(ins, /,/g, '');
// Invert sign because this is not number but string
x[2] = x[2] == "-" ? "+" : "-";
return Number(ins).human(x[5], true).padding(x[2] + x[4], x[3]);
};
stdfn.SPRINTF.H = function(ins, x)
{
var ins = String.prototype.replace.call(ins, /,/g, '');
// Invert sign because this is not number but string
x[2] = x[2] == "-" ? "+" : "-";
return Number(ins).human(x[5], false).padding(x[2] + x[4], x[3]);
};
2 changes: 1 addition & 1 deletion src/58json.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

yy.Json = function (params) { return yy.extend(this, params); }
yy.Json.prototype.toString = function() {
var s = '@';
var s = ''; // '@'
s += JSONtoString(this.value);
s += '';
return s;
Expand Down
99 changes: 99 additions & 0 deletions src/63createvertex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
//
// CREATE VERTEX for AlaSQL
// Date: 21.04.2015
// (c) 2015, Andrey Gershun
//
*/

yy.CreateVertex = function (params) { return yy.extend(this, params); }
yy.CreateVertex.prototype.toString = function() {
var s = K('CREATE')+' '+K('VERTEX')+' ';
if(this.class) s += L(this.class)+' ';
if(this.sets) {
s += this.sets.toString();
} else if(this.content) {
s += this.content.toString();
} else if(this.select) {
s += this.select.toString();
}

return s;
}

yy.CreateVertex.prototype.toJavaScript = function(context, tableid, defcols) {
console.log('yy.CreateVertex.toJavaScript');
var s = 'this.queriesfn['+(this.queriesidx-1)+'](this.params,null,'+context+')';
return s;
};
// CREATE TABLE
yy.CreateVertex.prototype.execute = function (databaseid,params,cb) {
console.log('yy.CreateVertex.execute');

if(this.sets) {
var obj = {};
if(this.sets.length > 0) {
this.sets.forEach(function(st){
console.log(st);
});
}

} else if(this.content) {

} else if(this.select) {

}


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

yy.CreateVertex.prototype.compile = function (databaseid) {
console.log('yy.CreateVertex.compile');

if(this.sets) {
var s = 'var a={};';
if(this.sets.length > 0) {
this.sets.forEach(function(st){
console.log(st);
});
}

} else if(this.content) {

} else if(this.select) {

}

return statement;
};



yy.CreateEdge = function (params) { return yy.extend(this, params); }
yy.CreateEdge.prototype.toString = function() {
// console.log('here!');
var s = K('CREATE')+' '+K('EDGE')+' ';
if(this.class) s += L(this.class)+' ';
// SET
// CONTENT
// SELECT
return s;
}

yy.CreateEdge.prototype.toJavaScript = function(context, tableid, defcols) {
var s = 'this.queriesfn['+(this.queriesidx-1)+'](this.params,null,'+context+')';
return s;
};

// CREATE TABLE
yy.CreateEdge.prototype.execute = function (databaseid,params,cb) {
var res = 1;
if(cb) res = cb(res);
return res;
};

yy.CreateEdge.prototype.compile = function (databaseid) {
};
Loading

0 comments on commit 2a02366

Please sign in to comment.