Commit 5d62207
committed
Merged PR 5249: Enhance Data Handling and Conversion in DDBC Bindings
This PR introduces several improvements and fixes to the DDBC bindings, focusing on data handling and conversion for various SQL data types. The key changes include:
Handling SQL_NUMERIC and SQL_DECIMAL:
Introduced the NumericData class to encapsulate the precision, scale, sign, and value of numeric data.
Added a method to_double in NumericData to convert the internal representation to a Python numeric type.
Updated the PyBind11 bindings to expose the NumericData class and its methods.
Handling SQL_SS_TIME2:
Defined SQL_SS_TIME2 and SQL_SS_TIME2_STRUCT to handle SQL Server-specific time types with fractional seconds.
Added logic to fetch and convert SQL_SS_TIME2 data to Python tuples.
Improved Null-Termination for Wide Character Strings:
Ensured proper null-termination for wide character strings (SQL_WCHAR, SQL_WVARCHAR, SQL_WLONGVARCHAR) by always adding a null terminator at the correct position.
Handling Binary Data:
Ensured binary data (SQL_BINARY, SQL_VARBINARY, SQL_LONGVARBINARY) is handled correctly without unnecessary null-termination.
Used smart pointers to manage memory for binary data buffers.
Handling Tiny Integers:
Added logic to handle both signed (SQL_C_STINYINT) and unsigned (SQL_C_UTINYINT) tiny integers correctly.
Ensured proper conversion and appending of tiny integer values to the result rows.
General Code Improvements:
Refactored and cleaned up the code for better readability and maintainability.
Added comments and explanations to clarify the purpose and functionality of various code sections.
Testing:
Updated the test script testing_ddbc_bindings.py to include test cases for the newly handled data types and conversions.
Verified that the data is fetched and converted correctly for various SQL data types, including numeric, time, and binary types.
Impact:
These changes enhance the robustness and accuracy of data handling in the DDBC bindings, ensuring that various SQL data types are correctly fetched, converted, and appended to the result rows.
The improvements also make the codebase more maintainable and easier to understand.
Reviewer Notes:
Please review the changes to the NumericData class and the handling of SQL_SS_TIME2.
Verify that the test cases in testing_ddbc_bindings.py cover all the newly handled data types and conversions.
Ensure that the code changes do not introduce any regressions or performance issues.
Thank you for reviewing this PR!
----
#### AI description (iteration 1)
#### PR Classification
Bug fix
#### PR Summary
Enhances data handling and conversion in DDBC bindings to fix issues with fetch APIs.
- `ddbc_bindings.cpp`: Added support for `SQL_TINYINT`, `SQL_BIT`, `SQL_TYPE_TIMESTAMP`, and `SQL_NUMERIC` data types.
- Introduced `NumericData` struct with methods for conversion to Python numeric types.
- Improved handling of `SQL_CHAR`, `SQL_VARCHAR`, and binary data types to ensure proper null-termination and memory management.
- Updated `SQLGetData_wrap` and `SQLBindColums` functions to handle...1 parent 6d2f65b commit 5d62207
3 files changed
Lines changed: 140 additions & 45 deletions
Binary file not shown.
0 commit comments