-
Notifications
You must be signed in to change notification settings - Fork 21
FEAT: varcharmax streaming support in execute #206
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
8e53235
to
48338d6
Compare
644c517
to
786ebef
Compare
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 enhances the MSSQL Python driver by adding support for VARCHAR(MAX) streaming through data-at-execution (DAE) and improving type safety for parameter binding. The changes focus on robust handling of large string parameters and preventing silent type mismatches.
Key changes:
- Added DAE streaming support for both SQL_C_CHAR and SQL_C_WCHAR parameter types with chunked data transmission
- Enhanced type validation in parameter binding to raise explicit errors for unsupported types
- Added comprehensive test coverage for VARCHAR(MAX) and NVARCHAR(MAX) operations in both LOB and non-LOB scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
mssql_python/pybind/ddbc_bindings.cpp | Implements DAE streaming logic for string parameters and adds type validation for SQL_C_CHAR and SQL_C_BINARY bindings |
tests/test_004_cursor.py | Adds test cases for VARCHAR(MAX) and NVARCHAR(MAX) insert operations covering both small and large data scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
581b297
to
72c6a18
Compare
Work Item / Issue Reference
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:
_map_sql_type
incursor.py
to raise aTypeError
for unsupported parameter types instead of defaulting toSQL_VARCHAR
, preventing silent type mismatches.ddbc_bindings.cpp
, added explicit type checks forSQL_C_CHAR
andSQL_C_BINARY
bindings, raising an error if the Python object is not a string or bytes-like object.DAE (Data At Execution) streaming improvements:
SQL_C_CHAR
inddbc_bindings.cpp
to handle string parameters more robustly, including chunked streaming viaSQLPutData
.str
objects mapped toSQL_C_CHAR
, ensuring large strings are sent in manageable pieces.Platform-specific encoding for wide strings:
SQL_C_WCHAR
) parameters are correctly converted to the platform-specific encoding before streaming.