-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added GetFieldValue test to retrieve Stream #145
Conversation
97e4f5d
to
d12c87d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these be in the upstream tests? Or is the plan to remove these once they're implemented there?
Oops, didn't realize which repo I'm in 🤣
@YohDeadfall note that nobody has discussed making this a global requirement across all ADO.NET providers - this is just an idea we had in Npgsql. I'm not sure it belongs here until that happens.
What do you mean? As I understand the base class made to share tests across provides and all of them should support the behavior. |
As I understood Wraith2, this is supported by SqlClient and by Npgsql now. Moreover, getting |
I do agree this is a good to have as a standard provider behavior - I'm just not sure this has been properly discussed etc.
I tried running the following code with 2.1.0-preview1.20235.1: using var conn = new SqlConnection("...");
conn.Open();
using var cmd = new SqlCommand("SELECT @p", conn);
cmd.Parameters.AddWithValue("p", new byte[] { 1, 2, 3 });
using var reader = cmd.ExecuteReader();
reader.Read();
_ = reader.GetFieldValue<Stream>(0); This gives me the following exception message:
Maybe @Wraith2 can provide some info... |
I think the expectation in SqlClient is that if you want a stream you should call |
@Wraith2 IIRC we discussed this together at some point, and the reason for allowing Stream and TextReader as generic arguments to GetFieldValue was that there aren't async methods for these (i.e. GetStreamAsync, GetTextReaderAsync). Rather than adding these new APIs, it was suggested to simply allow them to be passed to GetFieldValueAsync (and therefore also to GetFieldValue for consistency). I think it was even you who proposed this 😄 |
I remember that. The work just hasn't been done for Stream, I was probaby distracted. Throw an issue into the sqlclient repo and to track i'll pick it up when I can. |
Thanks @Wraith2, no worries obviously. I've opened dotnet/SqlClient#732 to track, the original discussion between us on this starts in dotnet/runtime#28596 (comment). |
Thanks @YohDeadfall! I made a small change in 2efb473 to test for the database provider's standard exception type; this allows SqlClient to keep throwing |
I think I started this weirdness. While doing some initial investigation of dotnet/efcore#19991, I noticed that not everything was possible via |
I think I filed dotnet/runtime#26756 with the idea of allowing users to write a value converter that goes from XmlReader to XmlDocument/XDocument, but I don't think I ever followed up on that after it was fixed... |
Fixes #144