Skip to content

Conversation

jahnvi480
Copy link
Contributor

@jahnvi480 jahnvi480 commented Oct 7, 2025

Work Item / Issue Reference

AB#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.

@Copilot Copilot AI review requested due to automatic review settings October 7, 2025 06:25
Copy link
Contributor

@Copilot 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 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.

@github-actions github-actions bot added the pr-size: medium Moderate update size label Oct 7, 2025
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.

2 participants