Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the select list part of #3110. The HAVING part of the issue is not touched, so the issue should stay open for it (this PR does not use a closing keyword for that reason).
The bug
In a grouped query, a bare column that only a later source of FROM defines was missing from the result.
The change
compileSelectGroupinsrc/select/columns.jscalledcol.toJSfor a column that stands alone without the default columns, so the lookup wrote a read of the first table of FROM. It now passesquery.defcols, and the lookup finds the source that has the name, as it does everywhere else.A name that two tables define is the exception. The default columns mark it as ambiguous and the lookup would throw. For such a name the call is made as before, without the default columns, so it keeps reading the first table and there is no new error. Making that an error is #2928.
src/select/having.jsis not changed. A bare column of a later source in HAVING still finds nothing, and waits for #3095.Tests
test/test3110.js, in the named databasetest3110.GROUP BY c+0).A, B, D and E fail on main. C, F and G pass on main and here.
Suite: 2745 pass, 213 skip, 0 fail. The run-state check gives an empty list.
The binding check
This bug was case 3 of the binding check of #3108. With the fix today's lookup and
bind.columnagree there, so the rule for case 3 is removed fromknownCaseintest/bind/record.jsand from the README, which now lists five cases. A return of the old reading would fail the check. Case 2c (a name two tables define, in a grouped select list) is still there and counts 6 references, 2 more than before, from test G.Parity differences
From the parity job of this PR, against the base (1169193) with the test files of this PR. 78,594 statements aligned in 588 files.
The 4 result differences are all in the new
test/test3110.js, and each is the fix. The base givescasundefined.SELECT c, SUM(b) AS s FROM test JOIN test1 ON test.a = test1.a GROUP BY test1.acundefined in 3 rowscis 7, 8, 7SELECT c, COUNT(*) AS n FROM test JOIN test1 ON test.a = test1.a[{c: undefined, n: 3}][{c: 7, n: 3}]SELECT c, SUM(b) AS s FROM test JOIN (SELECT a, c FROM test1) t1 ON test.a = t1.a GROUP BY t1.acundefined in 3 rowscis 7, 8, 7SELECT c, SUM(b) AS s FROM test JOIN test1 ON test.a = test1.a GROUP BY c+0cundefined in 2 rowscis 7, 8The 7 differences in generated code are the same one line each time. The read of the bare column in the grouped select list names the source that has it.
(this.groupSources.get(g) || g)['test']['c']to...['test1']['c']. For the subquery it becomes the per-row read('c' in Object(...['t1']) ? ...['t1']['c'] : undefined).SELECT c, SUM(b) AS s FROM test JOIN test1 ON test.a = test1.a GROUP BY cintest3110.js(1), with the same result.SELECT SUM(b) AS sb,a,c FROM test LEFT JOIN test1 ON test.a = test1.a GROUP BY c,test.aintest009.js(1), with the same result.SELECT c, SUM(b) AS s FROM one t0 JOIN (SELECT a,c FROM two) t1 ON t0.a=t1.a GROUP BY cintest832.js(1), with the same result.In the last three the column is also a GROUP BY key, so the value was and is copied from the group afterwards. No statement of the existing suite gives another result or error.
Sizes:
alasql.fs.js953,862 to 954,074 bytes (+0.02%),alasql.min.js543,459 to 543,544 bytes (+0.02%), gzip +18 bytes on the minified file.Supply chain
No change to
package.json, the lockfiles, the workflows, the grammar or the generated parser.