Support setting array columns to empty array instead of setting those to null#762
Merged
BenoitRanque merged 2 commits intomainfrom May 12, 2025
Merged
Support setting array columns to empty array instead of setting those to null#762BenoitRanque merged 2 commits intomainfrom
BenoitRanque merged 2 commits intomainfrom
Conversation
danieljharvey
approved these changes
May 12, 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.
What
Attempting to set an array column to
[]would instead set the column toNULL.This happened because we process the incoming values using
array_agg, which returns null if aggregating over no rows.How
We wrap the array aggregation in
COALESCE, with a default value of an empty array cast to the right type.The new behavior when updating an array column is now
The PR also adds snapshot tests for all 3 cases. The snapshotted SQL has been tested and verified to behave as intended.
Some other snapshots are also updated due to the change in generated SQL.
It seems we use the functions in
values.rsevery time we have some kind of json input.This is not what I set out to fix, and there could be issues if we're relying on the null behavior here, but I don't think we are.