You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Work Item / Issue Reference
<!--
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below (e.g.
AB#37452)
For external contributors: Insert Github Issue number below (e.g. #149)
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#39059](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/39059)
-------------------------------------------------------------------
### Summary
This pull request introduces a new global setting, `native_uuid`, to the
`mssql_python` package, allowing users to control whether UUID values
are returned as `uuid.UUID` objects or as strings. The implementation
includes updates to the package initialization, row processing logic,
and a comprehensive set of tests to verify the new behavior and ensure
backward compatibility.
**UUID Handling Improvements:**
* Added a `native_uuid` setting to the global configuration in
`mssql_python/__init__.py`, defaulting to `False` for backward
compatibility. This setting controls whether UUIDs are returned as
`uuid.UUID` objects or as strings.
* Updated the `Row` class in `mssql_python/row.py` to check the
`native_uuid` setting and convert UUID values to strings when
`native_uuid` is `False`, ensuring consistent output based on
configuration.
**Testing Enhancements:**
* Updated and extended tests in `tests/test_004_cursor.py` to verify
correct UUID handling for both `native_uuid=True` and
`native_uuid=False`, including new tests for the setting and resetting
of the `native_uuid` option.
**Internal Refactoring:**
* Removed unused UUID mapping logic in `mssql_python/cursor.py` that is
now handled via the new setting and row processing logic.
* Minor import and code organization cleanups in affected modules for
clarity and maintainability.
These changes provide greater flexibility and control over how UUIDs are
handled in query results, improving the usability of the package in
different application contexts.
---------
Co-authored-by: gargsaumya <saumyagarg.100@gmail.com>
0 commit comments