Skip to content

Commit a06a7f2

Browse files
committed
Merged #1105
1 parent ac1eccc commit a06a7f2

File tree

9 files changed

+181
-129
lines changed

9 files changed

+181
-129
lines changed

.github/CONTRIBUTING.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ Inputs to improvement? [Open an issue](https://github.com/agershun/alasql/issues
99

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

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

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

dist/alasql-worker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! AlaSQL v0.4.11-update-dependencies-7c54b63cundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
1+
//! AlaSQL v0.4.11-update-dependencies-ac1eccc0undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
22
/*
33
@module alasql
4-
@version 0.4.11-update-dependencies-7c54b63cundefined
4+
@version 0.4.11-update-dependencies-ac1eccc0undefined
55
66
AlaSQL - JavaScript SQL database
77
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff

dist/alasql-worker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/alasql.fs.js

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! AlaSQL v0.4.11-update-dependencies-7c54b63cundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
1+
//! AlaSQL v0.4.11-update-dependencies-ac1eccc0undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
22
/*
33
@module alasql
4-
@version 0.4.11-update-dependencies-7c54b63cundefined
4+
@version 0.4.11-update-dependencies-ac1eccc0undefined
55

66
AlaSQL - JavaScript SQL database
77
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -142,7 +142,7 @@ var alasql = function(sql, params, cb, scope) {
142142
Current version of alasql
143143
@constant {string}
144144
*/
145-
alasql.version = '0.4.11-update-dependencies-7c54b63cundefined';
145+
alasql.version = '0.4.11-update-dependencies-ac1eccc0undefined';
146146

147147
/**
148148
Debug flag
@@ -7585,49 +7585,45 @@ function doJoin(query, scope, h) {
75857585

75867586
// STEP 2
75877587

7588-
if (h + 1 < query.sources.length) {
7589-
if (
7590-
nextsource.joinmode == 'OUTER' ||
7591-
nextsource.joinmode == 'RIGHT' ||
7592-
nextsource.joinmode == 'ANTI'
7593-
) {
7594-
scope[source.alias] = {};
7595-
7596-
var j = 0;
7597-
var jlen = nextsource.data.length;
7598-
var dataw;
7599-
7600-
while (
7601-
(dataw = nextsource.data[j]) ||
7602-
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
7603-
j < jlen
7588+
if (h == 0) {
7589+
for (var nh = h + 1; nh < query.sources.length; nh++) {
7590+
if (
7591+
nextsource.joinmode == 'OUTER' ||
7592+
nextsource.joinmode == 'RIGHT' ||
7593+
nextsource.joinmode == 'ANTI'
76047594
) {
7605-
if (nextsource.getfn && !nextsource.dontcache) {
7606-
nextsource.data[j] = dataw;
7607-
}
7595+
scope[source.alias] = {};
76087596

7609-
if (dataw._rightjoin) {
7610-
delete dataw._rightjoin;
7611-
} else {
7612-
// delete dataw._rightjoin;
7597+
var j = 0;
7598+
var jlen = nextsource.data.length;
7599+
var dataw;
76137600

7614-
if (h == 0) {
7615-
scope[nextsource.alias] = dataw;
7616-
doJoin(query, scope, h + 2);
7601+
while (
7602+
(dataw = nextsource.data[j]) ||
7603+
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
7604+
j < jlen
7605+
) {
7606+
if (nextsource.getfn && !nextsource.dontcache) {
7607+
nextsource.data[j] = dataw;
7608+
}
7609+
7610+
if (dataw._rightjoin) {
7611+
delete dataw._rightjoin;
76177612
} else {
7618-
//scope[nextsource.alias] = dataw;
7619-
//doJoin(query, scope, h+2);
7613+
// delete dataw._rightjoin;
76207614

7615+
scope[nextsource.alias] = dataw;
7616+
doJoin(query, scope, nh + 1);
76217617
}
7618+
j++;
76227619
}
7623-
j++;
7624-
}
7625-
// debugger;
7626-
} else {
7620+
// debugger;
7621+
} else {
76277622

7623+
}
7624+
source = query.sources[nh];
7625+
nextsource = query.sources[nh + 1];
76287626
}
7629-
} else {
7630-
76317627
}
76327628

76337629
scope[tableid] = undefined;

dist/alasql.js

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! AlaSQL v0.4.11-update-dependencies-7c54b63cundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
1+
//! AlaSQL v0.4.11-update-dependencies-ac1eccc0undefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
22
/*
33
@module alasql
4-
@version 0.4.11-update-dependencies-7c54b63cundefined
4+
@version 0.4.11-update-dependencies-ac1eccc0undefined
55

66
AlaSQL - JavaScript SQL database
77
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -142,7 +142,7 @@ var alasql = function(sql, params, cb, scope) {
142142
Current version of alasql
143143
@constant {string}
144144
*/
145-
alasql.version = '0.4.11-update-dependencies-7c54b63cundefined';
145+
alasql.version = '0.4.11-update-dependencies-ac1eccc0undefined';
146146

147147
/**
148148
Debug flag
@@ -7580,49 +7580,45 @@ function doJoin(query, scope, h) {
75807580

75817581
// STEP 2
75827582

7583-
if (h + 1 < query.sources.length) {
7584-
if (
7585-
nextsource.joinmode == 'OUTER' ||
7586-
nextsource.joinmode == 'RIGHT' ||
7587-
nextsource.joinmode == 'ANTI'
7588-
) {
7589-
scope[source.alias] = {};
7590-
7591-
var j = 0;
7592-
var jlen = nextsource.data.length;
7593-
var dataw;
7594-
7595-
while (
7596-
(dataw = nextsource.data[j]) ||
7597-
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
7598-
j < jlen
7583+
if (h == 0) {
7584+
for (var nh = h + 1; nh < query.sources.length; nh++) {
7585+
if (
7586+
nextsource.joinmode == 'OUTER' ||
7587+
nextsource.joinmode == 'RIGHT' ||
7588+
nextsource.joinmode == 'ANTI'
75997589
) {
7600-
if (nextsource.getfn && !nextsource.dontcache) {
7601-
nextsource.data[j] = dataw;
7602-
}
7590+
scope[source.alias] = {};
76037591

7604-
if (dataw._rightjoin) {
7605-
delete dataw._rightjoin;
7606-
} else {
7607-
// delete dataw._rightjoin;
7592+
var j = 0;
7593+
var jlen = nextsource.data.length;
7594+
var dataw;
76087595

7609-
if (h == 0) {
7610-
scope[nextsource.alias] = dataw;
7611-
doJoin(query, scope, h + 2);
7596+
while (
7597+
(dataw = nextsource.data[j]) ||
7598+
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
7599+
j < jlen
7600+
) {
7601+
if (nextsource.getfn && !nextsource.dontcache) {
7602+
nextsource.data[j] = dataw;
7603+
}
7604+
7605+
if (dataw._rightjoin) {
7606+
delete dataw._rightjoin;
76127607
} else {
7613-
//scope[nextsource.alias] = dataw;
7614-
//doJoin(query, scope, h+2);
7608+
// delete dataw._rightjoin;
76157609

7610+
scope[nextsource.alias] = dataw;
7611+
doJoin(query, scope, nh + 1);
76167612
}
7613+
j++;
76177614
}
7618-
j++;
7619-
}
7620-
// debugger;
7621-
} else {
7615+
// debugger;
7616+
} else {
76227617

7618+
}
7619+
source = query.sources[nh];
7620+
nextsource = query.sources[nh + 1];
76237621
}
7624-
} else {
7625-
76267622
}
76277623

76287624
scope[tableid] = undefined;

dist/alasql.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/39dojoin.js

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -158,50 +158,46 @@ function doJoin(query, scope, h) {
158158

159159
// STEP 2
160160

161-
if (h + 1 < query.sources.length) {
162-
if (
163-
nextsource.joinmode == 'OUTER' ||
164-
nextsource.joinmode == 'RIGHT' ||
165-
nextsource.joinmode == 'ANTI'
166-
) {
167-
scope[source.alias] = {};
168-
169-
var j = 0;
170-
var jlen = nextsource.data.length;
171-
var dataw;
172-
173-
while (
174-
(dataw = nextsource.data[j]) ||
175-
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
176-
j < jlen
161+
if (h == 0) {
162+
for (var nh = h + 1; nh < query.sources.length; nh++) {
163+
if (
164+
nextsource.joinmode == 'OUTER' ||
165+
nextsource.joinmode == 'RIGHT' ||
166+
nextsource.joinmode == 'ANTI'
177167
) {
178-
if (nextsource.getfn && !nextsource.dontcache) {
179-
nextsource.data[j] = dataw;
180-
}
168+
scope[source.alias] = {};
169+
170+
var j = 0;
171+
var jlen = nextsource.data.length;
172+
var dataw;
173+
174+
while (
175+
(dataw = nextsource.data[j]) ||
176+
(nextsource.getfn && (dataw = nextsource.getfn(j))) ||
177+
j < jlen
178+
) {
179+
if (nextsource.getfn && !nextsource.dontcache) {
180+
nextsource.data[j] = dataw;
181+
}
181182

182-
// console.log(169,dataw._rightjoin,scope);
183-
if (dataw._rightjoin) {
184-
delete dataw._rightjoin;
185-
} else {
186-
// delete dataw._rightjoin;
187-
// console.log(163,h,scope);
188-
if (h == 0) {
189-
scope[nextsource.alias] = dataw;
190-
doJoin(query, scope, h + 2);
183+
// console.log(169,dataw._rightjoin,scope);
184+
if (dataw._rightjoin) {
185+
delete dataw._rightjoin;
191186
} else {
192-
//scope[nextsource.alias] = dataw;
193-
//doJoin(query, scope, h+2);
194-
// console.log(169,scope);
187+
// delete dataw._rightjoin;
188+
// console.log(163,h,scope);
189+
scope[nextsource.alias] = dataw;
190+
doJoin(query, scope, nh + 1);
195191
}
192+
j++;
196193
}
197-
j++;
194+
// debugger;
195+
} else {
196+
//console.log(180,scope);
198197
}
199-
// debugger;
200-
} else {
201-
//console.log(180,scope);
198+
source = query.sources[nh];
199+
nextsource = query.sources[nh + 1];
202200
}
203-
} else {
204-
// console.log(179,scope);
205201
}
206202

207203
scope[tableid] = undefined;
@@ -210,7 +206,7 @@ function doJoin(query, scope, h) {
210206
if(h+1 < query.sources.length) {
211207
var nextsource = query.sources[h+1];
212208
213-
if(nextsource.joinmode == "OUTER" || nextsource.joinmode == "RIGHT"
209+
if(nextsource.joinmode == "OUTER" || nextsource.joinmode == "RIGHT"
214210
|| nextsource.joinmode == "ANTI") {
215211
216212
@@ -224,7 +220,7 @@ function doJoin(query, scope, h) {
224220
//debugger;
225221
// var source = query.sources[h];
226222
227-
// var tableid = source.alias || source.tableid;
223+
// var tableid = source.alias || source.tableid;
228224
// var data = source.data;
229225
230226
// Reduce data for looping if there is optimization hint
@@ -254,7 +250,7 @@ function doJoin(query, scope, h) {
254250
// scope[tableid] = {};
255251
// console.log(scope);
256252
doJoin(query,scope,h+2);
257-
}
253+
}
258254
};
259255
260256
// Additional join for LEFT JOINS

test/test800.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ if (typeof exports === 'object') {
66
}
77

88
describe('Test 800 - OUTER JOIN missing ids', function() {
9+
before(function() {
10+
alasql('CREATE DATABASE test800;USE test800');
11+
});
12+
13+
after(function() {
14+
alasql.options.modifier = undefined;
15+
alasql('DROP DATABASE test800');
16+
});
17+
918
it('1. ARRAY()', function(done) {
1019
var t1 = [
1120
{id: '1', a: 'one'},

0 commit comments

Comments
 (0)