Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

SqlClient: fix BulkCopy double and single null widening handling#37603

Merged
cheenamalhotra merged 2 commits into
dotnet:masterfrom
Wraith2:sqlbug-37465
Aug 12, 2019
Merged

SqlClient: fix BulkCopy double and single null widening handling#37603
cheenamalhotra merged 2 commits into
dotnet:masterfrom
Wraith2:sqlbug-37465

Conversation

@Wraith2
Copy link
Copy Markdown
Contributor

@Wraith2 Wraith2 commented May 11, 2019

fixes https://github.com/dotnet/corefx/issues/37465

When using bulk copy with an inexact numeric source which is null and a decimal target the conversion from numeric to decimal creates an appropriately typed source variable and then attempts to pass that into a SqlDecimal constructor using the source Value property. This action fails when the source field is null because the Value property throws on null.

SqlDecimal does not expose a public constructor that allows setting null. It does have explicit conversion operators defined that do handle null values correctly so I have changed it to use these and noted why in the source. I have added a test which contains both real and float types. Manual and functional tests pass. This should be simple to pull up into Micosoft.Data.SqlServer.

/cc area owners @afsanehr, @Gary-Zh , @David-Engel and problem reporter @sergii-kryzh

@Wraith2 Wraith2 changed the title SqlClient: change BulkCopy double and single null widening handling SqlClient: fix BulkCopy double and single null widening handling May 11, 2019
@karelz
Copy link
Copy Markdown
Member

karelz commented May 22, 2019

@afsanehr @Gary-Zh just checking if this PR is on your radar ... (11 days no response ...)

@AfsanehR-zz AfsanehR-zz added this to the 1.0.x milestone May 22, 2019
@AfsanehR-zz
Copy link
Copy Markdown
Contributor

@Wraith2 Will take this one as 1.0 milestone. Will start running the tests.

@stephentoub
Copy link
Copy Markdown
Member

Will take this one as 1.0 milestone

@afsanehr, I'm confused, what does this mean?

@Wraith2
Copy link
Copy Markdown
Contributor Author

Wraith2 commented Jul 1, 2019

I interpretted that to mean it'll be in the Micosoft.Data.SqlClient first release. Being a bug fix it's also a good idea to have it in the System version as well in my opinion.

@stephentoub
Copy link
Copy Markdown
Member

Thanks.

The milestones here are about .NET Core. This is definitely not going to be in .NET Core 1.0.

If it's not going to be in System.Data.SqlClient, we shouldn't have a PR open for it here.

@afsanehr, what should be done here?

@stephentoub stephentoub removed this from the 1.0.x milestone Jul 1, 2019
@Wraith2
Copy link
Copy Markdown
Contributor Author

Wraith2 commented Jul 1, 2019

If it's not going to be in System.Data.SqlClient, we shouldn't have a PR open for it here.

As i said, since it's a bug fix it makes sense to me to include it in System.Data.SqlClient since the work has been done and is very simple. It's a two line change and an additional test the only thing stopping it being merged is the lack of time to do so.

@Gary-Zh
Copy link
Copy Markdown
Contributor

Gary-Zh commented Jul 8, 2019

Hi, sorry for the delay, currently we are encountering issues in our corefx testing pipelines, which is blocking the merge of this PR. Once we fix the pipeline and this PR passes all the tests we'll merge it immediately. This PR has been reviewed already.

@karelz karelz added this to the 5.0 milestone Aug 3, 2019
@cheenamalhotra
Copy link
Copy Markdown
Member

@Wraith2 This PR is being tracked and will be picked up for dotnet/SqlClient. Appreciate your patience for some more time while we come back to review and merge your contributions! 🙏

@eiriktsarpalis
Copy link
Copy Markdown
Member

@cheenamalhotra I'll assign this PR to you while it's being worked out if you don't mind.

Copy link
Copy Markdown
Member

@cheenamalhotra cheenamalhotra left a comment

Choose a reason for hiding this comment

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

PR changes have been tested and should be ready to merge once comments are addressed.

@cheenamalhotra cheenamalhotra merged commit 97ddad9 into dotnet:master Aug 12, 2019
@Wraith2 Wraith2 deleted the sqlbug-37465 branch September 29, 2019 11:38
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…net/corefx#37603)

* change BulkCopy double and single handling to handle Null values when converting to decimal without throwing and add tests

* address feedback


Commit migrated from dotnet/corefx@97ddad9
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants