Skip to content

Commit

Permalink
Adds BETWEEN op scenario to the toString prototype for yy.Ops class (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sljohnsondev committed May 19, 2020
1 parent c610d72 commit 4779e00
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 18 deletions.
4 changes: 2 additions & 2 deletions dist/alasql-worker.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! AlaSQL v0.6.0-develop-d96b07b7undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
//! AlaSQL v0.6.0-develop-c610d72cundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
/*
@module alasql
@version 0.6.0-develop-d96b07b7undefined
@version 0.6.0-develop-c610d72cundefined
AlaSQL - JavaScript SQL database
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
Expand Down
2 changes: 1 addition & 1 deletion dist/alasql-worker.min.js
100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions dist/alasql.fs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! AlaSQL v0.6.0-develop-d96b07b7undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
//! AlaSQL v0.6.0-develop-c610d72cundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
/*
@module alasql
@version 0.6.0-develop-d96b07b7undefined
@version 0.6.0-develop-c610d72cundefined

AlaSQL - JavaScript SQL database
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
Expand Down Expand Up @@ -142,7 +142,7 @@ var alasql = function(sql, params, cb, scope) {
Current version of alasql
@constant {string}
*/
alasql.version = '0.6.0-develop-d96b07b7undefined';
alasql.version = '0.6.0-develop-c610d72cundefined';

/**
Debug flag
Expand Down Expand Up @@ -10547,7 +10547,7 @@ yy.Over.prototype.toString = function() {

/**
Expression statement ( = 2*2; )
@class
@class
@param {object} params Initial parameters
*/
yy.ExpressionStatement = function(params) {
Expand Down Expand Up @@ -10796,6 +10796,12 @@ yy.Op.prototype.toString = function() {

return s;
}
if (this.op === 'BETWEEN') {
var s = this.left.toString() + ' ' + this.op + ' '
+ this.right1.toString() + ' AND ' + this.right2.toString();

return s;
}
return (
this.left.toString() +
' ' +
Expand Down
14 changes: 10 additions & 4 deletions dist/alasql.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! AlaSQL v0.6.0-develop-d96b07b7undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
//! AlaSQL v0.6.0-develop-c610d72cundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
/*
@module alasql
@version 0.6.0-develop-d96b07b7undefined
@version 0.6.0-develop-c610d72cundefined

AlaSQL - JavaScript SQL database
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
Expand Down Expand Up @@ -142,7 +142,7 @@ var alasql = function(sql, params, cb, scope) {
Current version of alasql
@constant {string}
*/
alasql.version = '0.6.0-develop-d96b07b7undefined';
alasql.version = '0.6.0-develop-c610d72cundefined';

/**
Debug flag
Expand Down Expand Up @@ -10542,7 +10542,7 @@ yy.Over.prototype.toString = function() {

/**
Expression statement ( = 2*2; )
@class
@class
@param {object} params Initial parameters
*/
yy.ExpressionStatement = function(params) {
Expand Down Expand Up @@ -10791,6 +10791,12 @@ yy.Op.prototype.toString = function() {

return s;
}
if (this.op === 'BETWEEN') {
var s = this.left.toString() + ' ' + this.op + ' '
+ this.right1.toString() + ' AND ' + this.right2.toString();

return s;
}
return (
this.left.toString() +
' ' +
Expand Down
4 changes: 2 additions & 2 deletions dist/alasql.min.js

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions src/50expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
Expression statement ( = 2*2; )
@class
@class
@param {object} params Initial parameters
*/
yy.ExpressionStatement = function(params) {
Expand Down Expand Up @@ -263,6 +263,12 @@ yy.Op.prototype.toString = function() {

return s;
}
if (this.op === 'BETWEEN') {
var s = this.left.toString() + ' ' + this.op + ' '
+ this.right1.toString() + ' AND ' + this.right2.toString();

return s;
}
return (
this.left.toString() +
' ' +
Expand Down Expand Up @@ -495,7 +501,7 @@ yy.Op.prototype.toJS = function(context, tableid, defcols) {
if(this.right instanceof yy.Op && this.right.op == 'AND') {
return ref('(('+this.right.left)+'<='+leftJS()+')&&'+
ref('('+leftJS()+'<='+this.right.right)+'))';
ref('('+leftJS()+'<='+this.right.right)+'))';
} else {
throw new Error('Wrong BETWEEN operator without AND part');
Expand Down Expand Up @@ -1044,7 +1050,7 @@ yy.AggrValue.prototype.findAggregator = function(query) {

var found = false;

/*/*
/*/*
for(var i=0;i<query.selectGroup.length;i++){
if(query.selectGroup[i].nick==colas) {
colas = colas+':'+i;
Expand Down Expand Up @@ -1102,7 +1108,7 @@ yy.AggrValue.prototype.toJS = function(/*context, tableid, defcols*/) {
// s += ')';
// if(this.alias) s += ' AS '+this.alias;
// return s;
// var s = '';
// var s = '';
//if(this.as) console.log(499,this.as);
// var colas = this.as;
*/
Expand Down
2 changes: 1 addition & 1 deletion test/test805.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (typeof exports === 'object') {
}

var current_timestamp = "CURRENT_TIMESTAMP";
var test = '804'; // insert test file number
var test = '805'; // insert test file number

describe('Test ' + test + ' - yy.FuncValue for CURRENT_TIMESTAMP returning correct variable string, NOT function string', function() {

Expand Down
25 changes: 25 additions & 0 deletions test/test810.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
}

var test = '810'; // insert test file number

describe('Test ' + test + ' - yy.Op for BETWEEN returning correct toString() result', function() {

it('yy.Op.toString() returns correct value when op === BETWEEN', function() {
var expectedResult = "id BETWEEN 1 AND 3"

var betweenOp = new alasql.yy.Op({
"left": new alasql.yy.Column({columnid: "id"}),
"op": "BETWEEN",
"right1": new alasql.yy.NumValue({value: 1}),
"right2": new alasql.yy.NumValue({value: 3})
});

var result = betweenOp.toString();


assert.equal(result, expectedResult);
});
});

0 comments on commit 4779e00

Please sign in to comment.