Skip to content

Conversation

gargsaumya
Copy link
Contributor

@gargsaumya gargsaumya commented Aug 28, 2025

Work Item / Issue Reference

AB#33395

GitHub Issue: #<ISSUE_NUMBER>


Summary

This pull request focuses on improving type safety and error handling for parameter binding and execution in the MSSQL Python driver, especially for string and binary types. The changes ensure that only supported Python types are bound to SQL parameters and that errors are raised for unsupported types, preventing silent failures. Additionally, the data-at-execution (DAE) streaming path for strings is now more robust and explicit.

Parameter type safety and error handling:

  • Changed _map_sql_type in cursor.py to raise a TypeError for unsupported parameter types instead of defaulting to SQL_VARCHAR, preventing silent type mismatches.
  • In ddbc_bindings.cpp, added explicit type checks for SQL_C_CHAR and SQL_C_BINARY bindings, raising an error if the Python object is not a string or bytes-like object.

DAE (Data At Execution) streaming improvements:

  • Enhanced the DAE streaming logic for SQL_C_CHAR in ddbc_bindings.cpp to handle string parameters more robustly, including chunked streaming via SQLPutData.
  • Added support for chunked DAE streaming of Python str objects mapped to SQL_C_CHAR, ensuring large strings are sent in manageable pieces.

Platform-specific encoding for wide strings:

  • Ensured that wide string (SQL_C_WCHAR) parameters are correctly converted to the platform-specific encoding before streaming.

@gargsaumya gargsaumya changed the title varcharmax streaming support in execute FEAT: varcharmax streaming support in execute Aug 28, 2025
@github-actions github-actions bot added the pr-size: small Minimal code update label Aug 28, 2025
@gargsaumya gargsaumya force-pushed the saumya/nvarcharmax-execute branch 2 times, most recently from 8e53235 to 48338d6 Compare August 28, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-size: small Minimal code update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant