FEAT: Support for Native_UUID Attribute #282
Open
+96
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request introduces a new global setting,
native_uuid
, to themssql_python
package, allowing users to control whether UUID values are returned asuuid.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:
native_uuid
setting to the global configuration inmssql_python/__init__.py
, defaulting toFalse
for backward compatibility. This setting controls whether UUIDs are returned asuuid.UUID
objects or as strings.Row
class inmssql_python/row.py
to check thenative_uuid
setting and convert UUID values to strings whennative_uuid
isFalse
, ensuring consistent output based on configuration.Testing Enhancements:
tests/test_004_cursor.py
to verify correct UUID handling for bothnative_uuid=True
andnative_uuid=False
, including new tests for the setting and resetting of thenative_uuid
option.Internal Refactoring:
mssql_python/cursor.py
that is now handled via the new setting and row processing logic.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.