Skip to content

Read empty multidimensional array - #2916

Merged
YohDeadfall merged 3 commits into
npgsql:devfrom
dvick:read-empty-multidimensional-array
Apr 6, 2020
Merged

YohDeadfall merged 3 commits into
npgsql:devfrom
dvick:read-empty-multidimensional-array

Conversation

@dvick

@dvick dvick commented Apr 3, 2020

Copy link
Copy Markdown
Contributor

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.

@YohDeadfall YohDeadfall added this to the 5.0 milestone Apr 6, 2020
@YohDeadfall

Copy link
Copy Markdown
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
YohDeadfall merged commit 5153554 into npgsql:dev Apr 6, 2020
@roji

roji commented Apr 10, 2020

Copy link
Copy Markdown
Member

@YohDeadfall I think this qualifies for patching, do you want to backport this?

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.

3 participants