-
Notifications
You must be signed in to change notification settings - Fork 315
Fix | Pass Empty List for SqlDataRecord (#2971) #3518
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for taking a stab at working on this issue. It needs a lot of work though... Please take a look at the comments and let me know your thoughts.
} | ||
|
||
if (!_pendingCancel) | ||
{ |
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.
I don't understand this change at all, especially since they seem to be completely unrelated to the focus of the PR. We don't want to be removing braces for if statements, and in this particular instance it completely upends the logic of the method.
asyncWrite, | ||
isRetry, | ||
methodName); | ||
|
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.
This doesn't really help readability.
{ | ||
completion.TrySetResult(retryTask.Result); | ||
} | ||
}, |
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.
This change also makes no sense, and I don't see how it compiles at all. Why was this change made?
} | ||
|
||
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/ExecuteXmlReaderAsync[@name="default"]/*'/> | ||
public Task<XmlReader> ExecuteXmlReaderAsync() => |
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.
This change seems completely random, unrelated to the focus of the PR, and likely doesn't compile.
task: out unused, | ||
usedCache: out _, | ||
method: method); | ||
|
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.
Again, removing this line doesn't really aid readability and is unrelated to the PR focus.
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.
All changes above could be because I enable formatting document after saving
@benrr101
} | ||
} | ||
|
||
#region fixing "Change SqlParameter to allow empty IEnumerable<SqlDataRecord>? #2971" |
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.
I'm not sure what to do about these tests. I think someone with a bit more experience in the test area could provide more concrete feedback. @mdaigle ?
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.
All changes above could be because I enable formatting document after saving
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.
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.
If there any test need to be done i will do it?
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
Show resolved
Hide resolved
Without wanting to step on @benrr101's toes, does this address the issue and support I've written a simple test - gist for it is here. This test returns an enumerator which isn't backed by an ICollection (and can't be - it's an iterator method.) The test as-is fails with the error:
One possible approach which might allow iterator methods to work is here. It's enough to prove the principle and hopefully it helps a little, but it's definitely not complete. For a quick overview:
I've not ported this over to the .NET Framework version. I've also only tested this in one specific situation - it's worth testing to prove this behaves properly with multiple table-valued parameters, empty lists, empty arrays and any other situations which come to mind. I'm sure there'll be some feedback on the way the test is written too - it's just to demonstrate the existing code which eliminates the need to create and drop databases manually. |
@edwardneal so impressive what you do,IF I need to still on this issue i need to do? what i need to learn? to complete this issue? |
Sorry for the delayed response. I think we're dealing with the problem in nearly the same place - the difference here is that your approach sets the I think the Ben's already pointed out a few of the unrelated changes to SqlCommand.cs, those need to be reverted. Once that's done (and the PR only contains the needed changes) then you can find a working method to fix the problem. After you've found that method, just make sure the two SqlCommand code files (one in netcore and one in netfx) have been changed in the same way. |
@edwardneal thanks for help,curently I working on it by solution based on my previous one if your testcase fail i will try yours beacuse we try soolve the same problem and each of us look on it some respective, but whenI fetch orgin and run testcases and it build the package it responed with errors |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
This PR doesn't compile in its current state, and it has merge conflicts with the current main branch. Please let us know what you want to do with it in the next week otherwise we'll probably close this PR. |
@benrr101 close this issue the project in my machine doesn't compile also for that I will stop in this issue,I am sorry if I waste your time |
Description
Important topics to cover include:
Enable Passing Empty List of type SqlDataRecord and make it functionality like when value is null
I remove exception from SqlParameter.cs and in SqlCommand I figure where it if parameter is null what happen and adding small condition
Issues
Fixes issue #2971
Testing
I create database and delete it when test finish to make test work and

first test when list is empty and second one when it null and it works correctly
and this photo captured from my sql server profiler to prove that it sends default