-
Notifications
You must be signed in to change notification settings - Fork 27
FIX: Handle empty data + tests #212
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 fixes empty data handling in the DDBC bindings by properly handling cases where SQL data has zero length. The change ensures that empty strings are correctly processed instead of being incorrectly handled by existing assertion logic.
- Added explicit handling for zero-length data in
SQLGetData_wrapfunction - Updated assertion to allow zero-length data in
FetchBatchDatafunction
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
… bewithgaurav/fix_blank_columns
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.
@bewithgaurav Left a few comments. Please see if we can fix them
… bewithgaurav/fix_blank_columns
…icrosoft/mssql-python into bewithgaurav/fix_blank_columns
Work Item / Issue Reference
Summary
This pull request improves the handling of empty string and binary values in the MSSQL Python bindings, ensuring that empty data is correctly distinguished from NULL values and does not cause assertion failures. It also adds comprehensive tests to verify correct behavior for these edge cases.
Improvements to empty value handling:
SQLGetData_wrapinddbc_bindings.cppto append an empty string ("") or empty bytes (b"") when the returned data length is zero, instead of causing assertion failures or misinterpreting the value as NULL. This change applies to both string and binary column types. [1] [2] [3]FetchBatchDatato allow zero-length data, ensuring that empty values are handled gracefully instead of triggering errors.Testing improvements:
tests/test_004_cursor.pyto verify correct handling of empty strings and binary data, including distinguishing empty values from NULLs, batch fetching, and various edge cases for empty strings. These tests ensure that the fixes work as intended and prevent regressions.Minor code cleanup:
ddbc_bindings.cppfor better code clarity.