Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

GROUP_CONCAT was converting NULL values to the string "null" instead of skipping them, causing incorrect concatenation results like "x,null,z" and failing with DISTINCT.

Changes

src/55functions.js

  • Skip NULL/undefined values during concatenation stages
  • Return NULL when all aggregated values are NULL
  • Handle accumulator initialization when first value is NULL

test/test942.js

  • Validate NULL skipping in concatenation
  • Validate NULL return for all-NULL groups
  • Validate DISTINCT with NULLs
  • Cover grouped and non-grouped queries

Before/After

// Before
GROUP_CONCAT(b) with ['x', null, 'z']  "x,null,z"
GROUP_CONCAT(b) with [null, null]      "null,null"
GROUP_CONCAT(DISTINCT b) with ['x', null, 'x', null]  "x,null"

// After
GROUP_CONCAT(b) with ['x', null, 'z']  "x,z"
GROUP_CONCAT(b) with [null, null]      null
GROUP_CONCAT(DISTINCT b) with ['x', null, 'x', null]  "x"
Original prompt

This section details on the original issue you should resolve

<issue_title>GROUP_CONCAT is treating null as "null"</issue_title>
<issue_description>When using GROUP_CONCAT null values are grouped like strings, for example it will group 2 rows with null into "null,null".

When used with DISTINCT it will return a single "null" instead of a JS null.

If I remember / have time I'll come back and see if I can easily make a PR for this, but just wanted to document the issue for now.
</issue_description>

Comments on the Issue (you are @copilot in this section)

@mathiasrw Thank you so much for looking into this. Please let me know if you find out something.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix GROUP_CONCAT handling of null values Fix GROUP_CONCAT to handle NULL values per SQL semantics Dec 22, 2025
Copilot AI requested a review from mathiasrw December 22, 2025 02:48
@mathiasrw mathiasrw marked this pull request as ready for review December 22, 2025 09:19
@mathiasrw mathiasrw merged commit 8aa97be into develop Dec 22, 2025
11 checks passed
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 is treating null as "null"

2 participants