Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ Inputs to improvement? [Open an issue](https://github.com/agershun/alasql/issues

**All contributions are much welcome and greatly appreciated(!)**

1. Fork the repo here on Github
0. Clone your forked repo and install dependencies `git clone https://github.com/MYUSERNAME/alasql/ && cd alasql && npm install`
0. Please work with the code from the develop branch `git checkout develop`
0. Add a test for the issue: Copy `test/test000.js` and replace `000` with a new number.
0. Impelement a test that reflects the issue.
0. Run `npm test` to verify only the new test fails
0. Implement your contributions in `src/`
0. Run `npm test` and verify all tests are OK
0. Commit changes to git and push to your forked repo
0. Click "Create Pull-request" when looking at your forked repo on Github
- Fork the repo here on Github
- Clone your forked repo and install dependencies `git clone https://github.com/MYUSERNAME/alasql/ && cd alasql && npm install`
- Please work with the code from the develop branch `git checkout develop`
- Add a test for the issue: Copy `test/test000.js` and replace `000` with a new number.
- Impelement a test that reflects the issue.
- Run `npm test` to verify only the new test fails
- Implement your contributions in `src/`
- Run `npm test` and verify all tests are OK
- Commit changes to git and push to your forked repo
- Click "Create Pull-request" when looking at your forked repo on Github

_Please note that `npm test` will compile from `src/` before running tests_

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.4.11-develop-d00d3b02undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
//! AlaSQL v0.4.11-develop-df603f27undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
/*
@module alasql
@version 0.4.11-develop-d00d3b02undefined
@version 0.4.11-develop-df603f27undefined

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.

70 changes: 33 additions & 37 deletions dist/alasql.fs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! AlaSQL v0.4.11-develop-d00d3b02undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
//! AlaSQL v0.4.11-develop-df603f27undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
/*
@module alasql
@version 0.4.11-develop-d00d3b02undefined
@version 0.4.11-develop-df603f27undefined

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.4.11-develop-d00d3b02undefined';
alasql.version = '0.4.11-develop-df603f27undefined';

/**
Debug flag
Expand Down Expand Up @@ -7576,49 +7576,45 @@ function doJoin(query, scope, h) {

// STEP 2

if (h + 1 < query.sources.length) {
if (
nextsource.joinmode == 'OUTER' ||
nextsource.joinmode == 'RIGHT' ||
nextsource.joinmode == 'ANTI'
) {
scope[source.alias] = {};

var j = 0;
var jlen = nextsource.data.length;
var dataw;

while (
(dataw = nextsource.data[j]) ||
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
j < jlen
if (h == 0) {
for (var nh = h + 1; nh < query.sources.length; nh++) {
if (
nextsource.joinmode == 'OUTER' ||
nextsource.joinmode == 'RIGHT' ||
nextsource.joinmode == 'ANTI'
) {
if (nextsource.getfn && !nextsource.dontcache) {
nextsource.data[j] = dataw;
}
scope[source.alias] = {};

if (dataw._rightjoin) {
delete dataw._rightjoin;
} else {
// delete dataw._rightjoin;
var j = 0;
var jlen = nextsource.data.length;
var dataw;

if (h == 0) {
scope[nextsource.alias] = dataw;
doJoin(query, scope, h + 2);
while (
(dataw = nextsource.data[j]) ||
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
j < jlen
) {
if (nextsource.getfn && !nextsource.dontcache) {
nextsource.data[j] = dataw;
}

if (dataw._rightjoin) {
delete dataw._rightjoin;
} else {
//scope[nextsource.alias] = dataw;
//doJoin(query, scope, h+2);
// delete dataw._rightjoin;

scope[nextsource.alias] = dataw;
doJoin(query, scope, nh + 1);
}
j++;
}
j++;
}
// debugger;
} else {
// debugger;
} else {

}
source = query.sources[nh];
nextsource = query.sources[nh + 1];
}
} else {

}

scope[tableid] = undefined;
Expand Down
70 changes: 33 additions & 37 deletions dist/alasql.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! AlaSQL v0.4.11-develop-d00d3b02undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
//! AlaSQL v0.4.11-develop-df603f27undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
/*
@module alasql
@version 0.4.11-develop-d00d3b02undefined
@version 0.4.11-develop-df603f27undefined

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.4.11-develop-d00d3b02undefined';
alasql.version = '0.4.11-develop-df603f27undefined';

/**
Debug flag
Expand Down Expand Up @@ -7571,49 +7571,45 @@ function doJoin(query, scope, h) {

// STEP 2

if (h + 1 < query.sources.length) {
if (
nextsource.joinmode == 'OUTER' ||
nextsource.joinmode == 'RIGHT' ||
nextsource.joinmode == 'ANTI'
) {
scope[source.alias] = {};

var j = 0;
var jlen = nextsource.data.length;
var dataw;

while (
(dataw = nextsource.data[j]) ||
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
j < jlen
if (h == 0) {
for (var nh = h + 1; nh < query.sources.length; nh++) {
if (
nextsource.joinmode == 'OUTER' ||
nextsource.joinmode == 'RIGHT' ||
nextsource.joinmode == 'ANTI'
) {
if (nextsource.getfn && !nextsource.dontcache) {
nextsource.data[j] = dataw;
}
scope[source.alias] = {};

if (dataw._rightjoin) {
delete dataw._rightjoin;
} else {
// delete dataw._rightjoin;
var j = 0;
var jlen = nextsource.data.length;
var dataw;

if (h == 0) {
scope[nextsource.alias] = dataw;
doJoin(query, scope, h + 2);
while (
(dataw = nextsource.data[j]) ||
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
j < jlen
) {
if (nextsource.getfn && !nextsource.dontcache) {
nextsource.data[j] = dataw;
}

if (dataw._rightjoin) {
delete dataw._rightjoin;
} else {
//scope[nextsource.alias] = dataw;
//doJoin(query, scope, h+2);
// delete dataw._rightjoin;

scope[nextsource.alias] = dataw;
doJoin(query, scope, nh + 1);
}
j++;
}
j++;
}
// debugger;
} else {
// debugger;
} else {

}
source = query.sources[nh];
nextsource = query.sources[nh + 1];
}
} else {

}

scope[tableid] = undefined;
Expand Down
4 changes: 2 additions & 2 deletions dist/alasql.min.js

Large diffs are not rendered by default.

76 changes: 36 additions & 40 deletions src/39dojoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,50 +158,46 @@ function doJoin(query, scope, h) {

// STEP 2

if (h + 1 < query.sources.length) {
if (
nextsource.joinmode == 'OUTER' ||
nextsource.joinmode == 'RIGHT' ||
nextsource.joinmode == 'ANTI'
) {
scope[source.alias] = {};

var j = 0;
var jlen = nextsource.data.length;
var dataw;

while (
(dataw = nextsource.data[j]) ||
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
j < jlen
if (h == 0) {
for (var nh = h + 1; nh < query.sources.length; nh++) {
if (
nextsource.joinmode == 'OUTER' ||
nextsource.joinmode == 'RIGHT' ||
nextsource.joinmode == 'ANTI'
) {
if (nextsource.getfn && !nextsource.dontcache) {
nextsource.data[j] = dataw;
}
scope[source.alias] = {};

var j = 0;
var jlen = nextsource.data.length;
var dataw;

while (
(dataw = nextsource.data[j]) ||
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
j < jlen
) {
if (nextsource.getfn && !nextsource.dontcache) {
nextsource.data[j] = dataw;
}

// console.log(169,dataw._rightjoin,scope);
if (dataw._rightjoin) {
delete dataw._rightjoin;
} else {
// delete dataw._rightjoin;
// console.log(163,h,scope);
if (h == 0) {
scope[nextsource.alias] = dataw;
doJoin(query, scope, h + 2);
// console.log(169,dataw._rightjoin,scope);
if (dataw._rightjoin) {
delete dataw._rightjoin;
} else {
//scope[nextsource.alias] = dataw;
//doJoin(query, scope, h+2);
// console.log(169,scope);
// delete dataw._rightjoin;
// console.log(163,h,scope);
scope[nextsource.alias] = dataw;
doJoin(query, scope, nh + 1);
}
j++;
}
j++;
// debugger;
} else {
//console.log(180,scope);
}
// debugger;
} else {
//console.log(180,scope);
source = query.sources[nh];
nextsource = query.sources[nh + 1];
}
} else {
// console.log(179,scope);
}

scope[tableid] = undefined;
Expand All @@ -210,7 +206,7 @@ function doJoin(query, scope, h) {
if(h+1 < query.sources.length) {
var nextsource = query.sources[h+1];

if(nextsource.joinmode == "OUTER" || nextsource.joinmode == "RIGHT"
if(nextsource.joinmode == "OUTER" || nextsource.joinmode == "RIGHT"
|| nextsource.joinmode == "ANTI") {


Expand All @@ -224,7 +220,7 @@ function doJoin(query, scope, h) {
//debugger;
// var source = query.sources[h];

// var tableid = source.alias || source.tableid;
// var tableid = source.alias || source.tableid;
// var data = source.data;

// Reduce data for looping if there is optimization hint
Expand Down Expand Up @@ -254,7 +250,7 @@ function doJoin(query, scope, h) {
// scope[tableid] = {};
// console.log(scope);
doJoin(query,scope,h+2);
}
}
};

// Additional join for LEFT JOINS
Expand Down
9 changes: 9 additions & 0 deletions test/test800.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ if (typeof exports === 'object') {
}

describe('Test 800 - OUTER JOIN missing ids', function() {
before(function() {
alasql('CREATE DATABASE test800;USE test800');
});

after(function() {
alasql.options.modifier = undefined;
alasql('DROP DATABASE test800');
});

it('1. ARRAY()', function(done) {
var t1 = [
{id: '1', a: 'one'},
Expand Down
Loading