Skip to content

SqlBulkCopy: Explicitly state column name that mismatches(#3170) #3183

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

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

JNjenga
Copy link
Contributor

@JNjenga JNjenga commented Feb 26, 2025

Throwing SQL.BulkLoadNonMatchingColumnMapping exception when column mappings mismatch does not provide enough information about where the error occurred. Throwing SQL.BulkLoadNonMatchingColumnName exception is more appropriate.

Fixes (#3170)

@JNjenga
Copy link
Contributor Author

JNjenga commented Feb 26, 2025

@dotnet-policy-service agree

@paulmedynski paulmedynski requested a review from a team February 27, 2025 17:13

if(!columnMapping._matchedOrRejected)
{
throw (SQL.BulkLoadNonMatchingColumnName(columnMapping.SourceColumn));
Copy link
Contributor

Choose a reason for hiding this comment

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

Does changing from SQL.BulkLoadNonMatchingColumnMapping() to SQL.BulkLoadNonMatchingColumnName() affect our API promises? They both end up throwing InvalidOperationException, so probably not. Callers shouldn't be depending on the message of the exception, but you never know!

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Great idea overall, with a few improvements noted.

@paulmedynski paulmedynski merged commit 509e7b8 into dotnet:main Mar 5, 2025
1 check passed
@paulmedynski
Copy link
Contributor

@JNjenga - Thanks for the changes!

@mdaigle mdaigle added this to the 7.0-preview1 milestone Mar 21, 2025
This was referenced Aug 15, 2025
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.

5 participants