Repository navigation
Fix empty arrays decoding as List<Object?> instead of a list of their element type - #472
Merged
Merged
Conversation
…ir element type.
Since 3.5.18 an empty array, `'{}'::text[]` say, decoded as an empty
`List<Object?>` while a non-empty one decodes as `List<String>`, so a
cast like `row[0] as List<String>` threw for empty arrays only. An
empty array is a list of its element type again.
…e in the hand-built ones.
isoos
approved these changes
Oct 4, 2026
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.
Since 3.5.18 (the multi-dimensional array change), an empty array loses its element type when it is decoded:
SELECT '{a}'::text[]List<String>List<String>List<String>SELECT '{}'::text[]List<String?>List<Object?>List<String>So code that casts an array column, such as
row[0] as List<String>, works for non-empty arrays and throws for empty ones:type 'List<Object?>' is not a subtype of type 'List<String>'.An empty array now decodes as a list of its element type, as a non-empty one does.
List<String>satisfies bothas List<String>andas List<String?>.Tests: the existing "Decodes an empty array" test compared the result with
<int>[], and list equality ignores the element type. New tests check the decoded type of emptyint4,int8,text,varchar,bool,float8anduuidarrays. They fail before this change and pass after. The full suite passes.