Skip to content

Allowed any type to be read as binary via GetStream#3152

Merged
YohDeadfall merged 5 commits intonpgsql:mainfrom
YohDeadfall:any-type-as-binary
Sep 20, 2020
Merged

Allowed any type to be read as binary via GetStream#3152
YohDeadfall merged 5 commits intonpgsql:mainfrom
YohDeadfall:any-type-as-binary

Conversation

@YohDeadfall
Copy link
Contributor

Fixes #2756

@YohDeadfall YohDeadfall requested a review from roji as a code owner September 18, 2020 11:50
@roji
Copy link
Member

roji commented Sep 18, 2020

Add a regression test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just suggesting a tiny new test that shows that a text or int value can be read as a Stream, nothing more. I wouldn't touch this test - it's a complicated one that tests SequentialAccess behavior as well, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complex tests aren't good tests in terms of unit testing. So this one just tests for an exceptions, while the existing does all other things as before. Moreover, it should be expanded to cover other types too, but a bit later (:

Copy link
Member

@roji roji Sep 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this test is a bit overly-complicated (because it tests multiple things). I just wouldn't touch it as part of this PR :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that these lines of code should be returned to GetStream?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I misunderstood your changes - now it's clearer. The splitting up of the complex test is a good thing.

But taking a closer look at the previous test, it tested more than what is being tested here, no? Your new test makes sure that you can't get a stream if another stream is already open on the column. The previous version checked other stuff too - that going back inside the column fails for SequentialAccess, but is OK otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure it's intentional: this doesn't create an array of 1024 consecutive byte values, but rather an array of 4096 byte values which represent 4-byte int data... Is there any reason? It's usually easier when debugging tests to have simple consecutive data, in order to understand what's going on.

Copy link
Contributor Author

@YohDeadfall YohDeadfall Sep 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously there was a comment containing a to-do. The idea was to test sequential mode truly, but for this we should have more data than the buffer could contain. So multiply 4096 by 2 and add some extra from the PostgreSQL protocol.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I misunderstood your changes - now it's clearer. The splitting up of the complex test is a good thing.

But taking a closer look at the previous test, it tested more than what is being tested here, no? Your new test makes sure that you can't get a stream if another stream is already open on the column. The previous version checked other stuff too - that going back inside the column fails for SequentialAccess, but is OK otherwise.

@YohDeadfall YohDeadfall requested a review from roji September 20, 2020 09:38
@YohDeadfall YohDeadfall merged commit f0433cd into npgsql:main Sep 20, 2020
@YohDeadfall YohDeadfall deleted the any-type-as-binary branch September 20, 2020 16:07
@oliverjanik
Copy link

Hello, which nuget version will this land in ?

@YohDeadfall
Copy link
Contributor Author

Hi! As the milestone in the issue states it's in 5.0 which should be released in November.

@roji roji changed the title Allowed any type to be read as binary Allowed any type to be read as binary via GetStream Apr 8, 2021
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.

Allow any type to be read as binary

3 participants