-
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
Type mismatch for None/NULL value in a cell in a table-valued parameter. #596
Comments
I can reproduce the issue, and I'm looking into fixing it |
I made a PR that seems to work for both this repro app and doesn't break any existing tests (including TVP). It basically skips type checking for NULLs. One "catch" is that the first line still has to have all the proper datatypes, because otherwise there is no way to know what the types are, but that's true regardless of my fix (I think you'd get an error trying to bind SQL_C_DEFAULT if you have a |
I'm assuming that the PR fixes this? Should we add "Fixes #xxx" to the PR commits so they close issues automatically? If I'm wrong, please reopen. |
I am still able to reproduce the issue if the first row is having None. |
A workaround for SQL Server 2016+ is documented here: |
Sys info
python: 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:09:58)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
pyodbc: 4.0.26 [...]/lib/python3.6/site-packages/pyodbc.cpython-36m-x86_64-linux-gnu.so
odbc: 03.52
driver: libmsodbcsql-17.3.so.1.1 17.03.0001
supports ODBC version 03.52
os: Ubuntu 16.04
DB: Azure SQL Server
Issue
When using a table-valued parameter (TVP) for a simple stored procedure that echos the input,
None
values in the TVP cells cause a pyodbc error because of a type mismatch with the parameter in the previous row.Stored procedure:
CREATE PROCEDURE TestSelectTVP @TVP TVPType READONLY AS SELECT * FROM @TVP;
TVP Type:
CREATE TYPE TVPType AS TABLE(c01 BIGINT, c02 BIGINT)
Call the SP:
Expected
Returned values:
Observed
Exception raised:
If None/NULL is in the first row, there is a different exception:
pyodbc.Error: ('HY090', '[HY090] [unixODBC][Driver Manager]Invalid string or buffer length (0) (SQLBindParameter)')
Other info
The exception is raised here:
https://github.com/mkleehammer/pyodbc/blob/4.0.26/src/cursor.cpp#L766
Doesn't this type check require non-NULL data, since it's testing strict type equality?
Script to reproduce:
The text was updated successfully, but these errors were encountered: