Open will-hinson opened 1 month ago
Hey, Will. This looks promising. Thanks for contributing!
Can we add a test to tests/sqlserver_test.py
that will exercise your code a bit?
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:
sql_type
of the ColumnInfo
struct to SQL_SS_VARIANT
after decoding. Without this, all values in the column would try to take on the type of the first value returned.sql_variant
columns and are defined in sqlext.h
. (See this MS doc)Please let me know if further action is required on my part. 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: