-
Notifications
You must be signed in to change notification settings - Fork 564
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
Implemented support for the SQL Server sql_variant data type #1354
Implemented support for the SQL Server sql_variant data type #1354
Conversation
Hey, Will. This looks promising. Thanks for contributing! Can we add a test to |
Hello @gordthompson, Of course! I have pushed another commit with an added test for the sql_variant type. I also made the following related changes:
Please let me know if further action is required on my part. Thanks! |
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.
Looks good to me.
Comments @mkleehammer @v-chojas ? |
Not sure how much DBMS-specific stuff you want in pyODBC. |
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.
Looks good. Thanks.
This commit adds support for decoding the SQL Server
sql_variant
data type.Attempting to read records containing
sql_variant
columns in the current version ofpyodbc
(5.1.0) results in the following exception:As mentioned in #307, it is not trivial to write a custom output converter for
sql_variant
as the bytes returned by SQL Server give no indication as to the underlying data type of each value.This commit adds a
GetData_SqlVariant()
method which retrieves the underlying data type per the Microsoft documentation usingSQLColAttribute()
:This underlying data type is then patched into the
ColumnInfo
struct for the current column andGetData()
is invoked using this new type:The
sql_variant
type is used by a number of system functions and views and this commit adds support for reading them: