Repository navigation
Add regression test for GROUP BY with no matching rows - #2300
Merged
Merged
Conversation
Co-authored-by: mathiasrw <[email protected]>
Copilot
AI
changed the title
[WIP] Fix GROUP BY returning invalid result for empty query
Add regression test for GROUP BY with no matching rows
Dec 2, 2025
mathiasrw
approved these changes
Dec 2, 2025
mathiasrw
requested changes
Dec 2, 2025
Member
|
@copilot Continue |
Co-authored-by: mathiasrw <[email protected]>
Contributor
Author
mathiasrw
approved these changes
Dec 2, 2025
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.
Description
The issue reported that
SELECT Name FROM ? WHERE 1=0 GROUP BY Namewas returning[{Name: 'undefined'}]instead of an empty result set. This behavior has already been fixed in the codebase.The fix exists in
src/38query.js:102where the conditionif (query.groups.length === 0 && query.allgroups.length === 0)ensures artificial groups are only created when no GROUP BY clause exists. This correctly implements SQL standard behavior:[][{cnt: 0}])Changes
Added comprehensive test suite in
test/test79-B.jscovering:Example
Original prompt
<issue_description>If there is a query that has no results, but contains a GROUP BY, it returns one result regardless, with the data of "undefined"
</issue_description>
Comments on the Issue (you are @copilot in this section)
@agershun Thank you! For the second question you should: a) add Name to the GROUP BY clause b) Use FIRST() aggregatoror
For the first question - sorry, it still in progress...
</comment_new>
<comment_new>@agershun
Try this example in jsFiddle
</comment_new>
<comment_new>@mathiasrw
👍
</comment_new>
<comment_new>@agershun
Is there a way you can test if the fields are requested naked, to automatically apply the FROM() function when used in a GROUP BY?
I think, that the standard SQL reaction is to throw a error like "column is not found". I think, Alasql can check this, but only for SELECT with GROUP BY clause. Plus, it is hard to recognize these "naked" columns in expressions, like:
</comment_new>
<comment_new>@mathiasrw
Is this issue resolved?
</comment_new>
<comment_new>@mathiasrw
Well... its now returning
[{}]instead of the original problem - but its still not correct.Any help to resolve this would be awesome.
http://jsfiddle.net/t780pnz1/</comment_new>
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.