Fix issue with cast exception from sql_variant#1320
Merged
peterbae merged 8 commits intomicrosoft:devfrom May 12, 2020
Merged
Conversation
ulvii
reviewed
May 7, 2020
ulvii
reviewed
May 7, 2020
ulvii
reviewed
May 7, 2020
Member
|
Can we document the "supported" sql variant datatype casts for now and the ones that aren't? Just so users have a reference in case they notice inconsistencies. |
lilgreenbird
reviewed
May 7, 2020
ulvii
approved these changes
May 9, 2020
lilgreenbird
approved these changes
May 12, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes issue #1302.
Even though the code has remained this way for a long time, I think the current behavior of sql_variant is incorrect. The
jdbcTypevariable in dtv.java is the JDBC type that the user specifies when they try to retrieve the data. This variable is telling the driver what the user wants to retrieve the data as, but this variable was getting modified to become the base type of the server's column type when retrieving sql_variant data, causing this issue (this effectively ignores the data type that the user was asking to retrieve sql_variant as). LeavingjdbcTypeas it is (which we should, since that's what the user wants) solves the issue.However, when the driver performs bulk copy on a sql_variant column, the driver does need to designate
jdbcTypeas the underlying data type to perform datatype-specific conversions. This made it difficult for applying my changes to all datatypes (for the scope of this PR), and for now only the datatypes that do not require any specific conversions from going from one another (for example, numeric values and String values) have the fixes applied.