Repository navigation
Fix incorrect result when grouping by two columns with the same name - #2307
Conversation
Co-authored-by: mathiasrw <[email protected]>
|
@copilot Continue |
The issue was in compileSelectGroup2 where it checked if col.nick was in query.ingroup. When columns were renamed to avoid duplicates (e.g., 'x' becomes 'x:1'), the renamed columns wouldn't match what's in query.ingroup, causing them to not be populated. The fix checks if a column is part of GROUP BY by comparing columnid and tableid, and then uses the GROUP BY column's nick to fetch the value from the group object. Fixes #941 Co-authored-by: mathiasrw <[email protected]>
- Avoid duplicate GROUP BY column lookup by reusing groupCol variable - Add check to skip SELECT * columns in compileSelectGroup2 (fixes test1797) - All 1814 tests passing Co-authored-by: mathiasrw <[email protected]>
Replace O(n*m) find operation with O(1) map lookup for better performance with queries that have many columns and GROUP BY clauses. Co-authored-by: mathiasrw <[email protected]>
I've completed the fix for issue #941. The problem was in Changes made in commit a743b3d:
The fix now correctly handles:
|
Co-authored-by: mathiasrw <[email protected]>
Co-authored-by: mathiasrw <[email protected]>
|
@copilot Continue |
Co-authored-by: mathiasrw <[email protected]>
|
@copilot Continue |
Added comprehensive edge case tests covering: - SELECT * with GROUP BY and duplicate columns - Multiple aggregates (MAX, MIN, SUM, AVG) with duplicate columns - Multiple GROUP BY columns with duplicates in SELECT - HAVING clause with duplicate columns - Subqueries with duplicate columns - DISTINCT with duplicate columns All 1821 tests passing. Co-authored-by: mathiasrw <[email protected]>
I've completed the work with commit 68fd86c: Test Coverage Expansion:
Results:
The fix correctly handles all scenarios for duplicate column names in GROUP BY queries. |
|
Run yarn test-format-all |
Ran yarn format-all to fix formatting issues in: - src/424select.js (trailing whitespace) - test/test941.js (array formatting) All tests still passing. Co-authored-by: mathiasrw <[email protected]>
Summary
Successfully fixed issue #941 where GROUP BY queries with duplicate column names would result in undefined values.
Changes:
compileSelectGroup2in424select.jsto properly handle columns with renamed nicks38query.jsto prevent premature deletion of shared nick valuesTesting:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.