-
Notifications
You must be signed in to change notification settings - Fork 25
FEAT: Support for Native_UUID Attribute #282
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
base: main
Are you sure you want to change the base?
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 introduces a new native_uuid
global setting to control whether UUID values are returned as uuid.UUID
objects or strings, with a default value of False
for backward compatibility.
Key changes:
- Added
native_uuid
setting to global configuration with backward-compatible default - Updated row processing logic to convert UUID objects to strings when
native_uuid=False
- Enhanced test coverage to verify UUID handling behavior for both setting states
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
mssql_python/init.py | Added native_uuid setting initialization and module-level access |
mssql_python/row.py | Implemented UUID conversion logic based on native_uuid setting |
mssql_python/cursor.py | Removed unused UUID mapping code |
tests/test_004_cursor.py | Added comprehensive tests for native_uuid setting and updated existing UUID tests |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
self.lowercase = False | ||
# Use the pre-determined separator - no locale access here | ||
self.decimal_separator = _DEFAULT_DECIMAL_SEPARATOR | ||
self.native_uuid = False # Default to False for backwards compatibility |
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.
Please add a boolean-only, locked setter for native_uuid (reject non-bool inputs)
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.
Made the required changes
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.
Left a few comments
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.