Repository navigation
Read empty multidimensional array - #2916
Merged
Merged
Conversation
Contributor
|
Oh, thank you for the improvement! I'm going to merge it for 5.0 as an enhancement, but at some point it looks like a bug fix and suites for 4.1.4. @roji what are your thoughts on it? |
YohDeadfall
approved these changes
Apr 6, 2020
Member
|
@YohDeadfall I think this qualifies for patching, do you want to backport this? |
This was referenced Oct 18, 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.
Current handling for empty arrays returns Array.Empty, which is always one-dimensional. This is problematic when the array is expected to be multidimensional when not empty. This fixes that so, when requesting an array with more than one dimension and the array from the database happens to be empty, an empty array with the correct number of dimensions is created and returned. When not given an array type, or the given array type has one dimension, it still uses Array.Empty.
I also went ahead and made it throw an exception if the requested number of dimensions doesn't match the number of dimensions in the returned array. This just prevents it from needlessly creating an array with the wrong number of dimensions just to ultimately throw an InvalidCastException, so this isn't really necessary. If you'd like this done differently or not at all, I can change it or remove it.