Skip to content

Conversation

@bewithgaurav
Copy link
Collaborator

@bewithgaurav bewithgaurav commented Aug 29, 2025

Work Item / Issue Reference

AB#<WORK_ITEM_ID>

GitHub Issue: #205


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:

  • Updated SQLGetData_wrap in ddbc_bindings.cpp to 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]
  • Changed assertions in FetchBatchData to allow zero-length data, ensuring that empty values are handled gracefully instead of triggering errors.

Testing improvements:

  • Added new tests in tests/test_004_cursor.py to 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:

  • Minor formatting and comment improvements in ddbc_bindings.cpp for better code clarity.

Copilot AI review requested due to automatic review settings August 29, 2025 08:27
Copy link
Contributor

Copilot AI left a 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_wrap function
  • Updated assertion to allow zero-length data in FetchBatchData function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions github-actions bot added the pr-size: medium Moderate update size label Aug 29, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 29, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 29, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 29, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 3, 2025
@bewithgaurav bewithgaurav changed the title FIX: Handle empty data FIX: Handle empty data + tests Sep 3, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 3, 2025
gargsaumya
gargsaumya previously approved these changes Sep 4, 2025
Copy link
Contributor

@sumitmsft sumitmsft left a 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

@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 5, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 5, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 5, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 5, 2025
@bewithgaurav bewithgaurav merged commit 1da4fa9 into main Sep 6, 2025
18 checks passed
@bewithgaurav bewithgaurav linked an issue Sep 8, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: medium Moderate update size

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when fetching data with empty values

4 participants