-
Notifications
You must be signed in to change notification settings - Fork 27
FEAT: Support correct type handling of None parameters in parameter binding #208
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
Conversation
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.
Pull Request Overview
This PR adds support for using the ODBC SQLDescribeParam API to properly handle parameter binding for None values, particularly improving type detection for binary columns. Previously, None parameters used a default SQL type which could cause issues with binary columns.
- Added ODBC
SQLDescribeParamfunction pointer integration to query parameter metadata - Updated parameter binding logic to call
SQLDescribeParamwhen parameter type is unknown - Removed TODO comment related to binary column handling since the issue is now resolved
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| mssql_python/pybind/ddbc_bindings.h | Added SQLDescribeParam function typedef and pointer declaration |
| mssql_python/pybind/ddbc_bindings.cpp | Implemented SQLDescribeParam loading and parameter binding logic using the API |
| mssql_python/cursor.py | Removed TODO comment about adding SQLDescribeParam support |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
c3185ed to
0b7e699
Compare
sumitmsft
left a comment
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.
Work Item / Issue Reference
Summary
This pull request adds support for using the
SQLDescribeParamODBC API to determine the correct SQL type for parameters with unknown types (such asNonevalues), improving parameter binding accuracy—especially for binary columns. The changes include adding the necessary function pointer, loading it from the driver, and updating the parameter binding logic to callSQLDescribeParamwhen needed.ODBC API Integration:
SQLDescribeParamFunctypedef and declared/defined theSQLDescribeParam_ptrfunction pointer to enable callingSQLDescribeParamfrom the driver. [1] [2] [3] [4] [5]Parameter Binding Improvements:
BindParametersto callSQLDescribeParamfor parameters with unknown types, ensuring correct SQL type, column size, and decimal digits are used forNonevalues and improving support for binary columns.Minor Cleanups:
_map_sql_typeas type detection is now handled more robustly.