Skip to content

Sort GROUP_CONCAT by its ORDER BY items to close #2658 - #2995

Open
mateuscmtropical wants to merge 1 commit into
AlaSQL:developfrom
mateuscmtropical:fix-2658-group-concat-order-by
Open

mateuscmtropical wants to merge 1 commit into
AlaSQL:developfrom
mateuscmtropical:fix-2658-group-concat-order-by

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Closes #2658

GROUP_CONCAT(name ORDER BY age) sorted by name. Only the direction of the first ORDER BY item reached the aggregator, which then sorted the values themselves.

  • getGroupConcatParams in src/423groupby.js now also passes, for each row, the values of all ORDER BY items and their directions.
  • The GROUP_CONCAT aggregator in src/55functions.js keeps these keys next to the values and sorts by them at the end, item by item. Ties keep the order of the rows. NULL keys go last, as NULL values did before.
  • Ordering by the value itself gives the same result as before. Without ORDER BY nothing changes. A direct call with the old five arguments still works.

test/test2658.js covers ORDER BY another column ASC and DESC, several items, GROUP BY with SEPARATOR, and ORDER BY the value, no ORDER BY and DISTINCT as before. test2413 still passes. The new tests fail on develop and pass with the change. yarn test-only gives 2555 pass. The only failures are the 5 Test 418 cases that load data from the internet, and they fail the same way on develop in my environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GROUP_CONCAT(x ORDER BY y) sorts by x, not by y

2 participants