FEAT: Support correct type handling of None parameters in parameter binding by gargsaumya · Pull Request #208 · microsoft/mssql-python

Work Item / Issue Reference

AB#38339

GitHub Issue: #<ISSUE_NUMBER>


Summary

This pull request adds support for using the SQLDescribeParam ODBC API to determine the correct SQL type for parameters with unknown types (such as None values), 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 call SQLDescribeParam when needed.

ODBC API Integration:

  • Added the SQLDescribeParamFunc typedef and declared/defined the SQLDescribeParam_ptr function pointer to enable calling SQLDescribeParam from the driver. [1] [2] [3] [4] [5]

Parameter Binding Improvements:

  • Updated the logic in BindParameters to call SQLDescribeParam for parameters with unknown types, ensuring correct SQL type, column size, and decimal digits are used for None values and improving support for binary columns.

Minor Cleanups:

  • Removed a TODO comment in _map_sql_type as type detection is now handled more robustly.